28169 1 周之前
父節點
當前提交
e1aba399ee

二進制
XT_New.exe 查看文件


+ 6 - 6
controllers/base_api_controller.go 查看文件

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

+ 10 - 14
controllers/common_api_controller.go 查看文件

@@ -1,15 +1,16 @@
1 1
 package controllers
2 2
 
3 3
 import (
4
+	"encoding/json"
5
+	"fmt"
6
+	"strconv"
7
+	"time"
8
+
4 9
 	"XT_New/enums"
5 10
 	"XT_New/models"
6 11
 	"XT_New/service"
7 12
 	"XT_New/utils"
8
-	"encoding/json"
9
-	"fmt"
10 13
 	"github.com/jinzhu/gorm"
11
-	"strconv"
12
-	"time"
13 14
 )
14 15
 
15 16
 type CommonApiController struct {
@@ -583,11 +584,10 @@ func (this *CommonApiController) GetTotalLapseCount() {
583 584
 func (this *CommonApiController) GetTotalSexCount() {
584 585
 	adminUser := this.GetAdminUserInfo()
585 586
 	orgid := adminUser.CurrentOrgId
586
-	fmt.Println("orgid", orgid)
587
-	startime, _ := this.GetInt64("startime")
588
-	fmt.Println("开始时间", startime)
589
-	endtime, _ := this.GetInt64("endtime")
590
-	fmt.Println("结束时间", endtime)
587
+	//startime, _ := this.GetInt64("startime")
588
+	//
589
+	//endtime, _ := this.GetInt64("endtime")
590
+
591 591
 	lapsetotype, _ := this.GetInt64("lapsetotype")
592 592
 	sourcetype, _ := this.GetInt64("sourcetype")
593 593
 	total := service.GetPatientTotalCount(orgid, lapsetotype, sourcetype)
@@ -642,11 +642,6 @@ func (this *CommonApiController) GetTotalInfectiouscount() {
642 642
 func (this *CommonApiController) GetTotalAgeCount() {
643 643
 	adminUser := this.GetAdminUserInfo()
644 644
 	orgid := adminUser.CurrentOrgId
645
-	fmt.Println("orgid", orgid)
646
-	startime, _ := this.GetInt64("startime")
647
-	fmt.Println("开始时间", startime)
648
-	endtime, _ := this.GetInt64("endtime")
649
-	fmt.Println("结束时间", endtime)
650 645
 	lapsetotype, _ := this.GetInt64("lapsetotype")
651 646
 	sourcetype, _ := this.GetInt64("sourcetype")
652 647
 	//统计透析总人数
@@ -1451,6 +1446,7 @@ func (this *CommonApiController) GetPatientscontrol() {
1451 1446
 	limit, _ := this.GetInt64("limit")
1452 1447
 
1453 1448
 	patients, total, err := service.GetPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix, page, limit)
1449
+
1454 1450
 	control, err := service.GetLastPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
1455 1451
 
1456 1452
 	infectiousControl, err := service.GetInfectiousControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)

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

@@ -2879,13 +2879,13 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
2879 2879
 			service.CreateDialysisFinish(finish)
2880 2880
 		}
2881 2881
 
2882
-		if adminUserInfo.CurrentOrgId == 9671 || adminUserInfo.CurrentOrgId == 3877 || adminUserInfo.CurrentOrgId == 10469 || adminUserInfo.CurrentOrgId == 10551 || adminUserInfo.CurrentOrgId == 10579 || adminUserInfo.CurrentOrgId == 10580 || adminUserInfo.CurrentOrgId == 10585 || adminUserInfo.CurrentOrgId == 10344 || adminUserInfo.CurrentOrgId == 10622 || adminUserInfo.CurrentOrgId == 10702 || adminUserInfo.CurrentOrgId == 10635 || adminUserInfo.CurrentOrgId == 10723 || adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10727 || adminUserInfo.CurrentOrgId == 10726 || adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10727 || adminUserInfo.CurrentOrgId == 10751 || adminUserInfo.CurrentOrgId == 10752 {
2882
+		if adminUserInfo.CurrentOrgId == 9671 || adminUserInfo.CurrentOrgId == 3877 || adminUserInfo.CurrentOrgId == 10469 || adminUserInfo.CurrentOrgId == 10551 || adminUserInfo.CurrentOrgId == 10579 || adminUserInfo.CurrentOrgId == 10580 || adminUserInfo.CurrentOrgId == 10585 || adminUserInfo.CurrentOrgId == 10344 || adminUserInfo.CurrentOrgId == 10622 || adminUserInfo.CurrentOrgId == 10702 || adminUserInfo.CurrentOrgId == 10635 || adminUserInfo.CurrentOrgId == 10723 || adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10727 || adminUserInfo.CurrentOrgId == 10726 || adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10727 || adminUserInfo.CurrentOrgId == 10751 || adminUserInfo.CurrentOrgId == 10752 || adminUserInfo.CurrentOrgId == 10480 || adminUserInfo.CurrentOrgId == 10293 || adminUserInfo.CurrentOrgId == 9478 {
2883 2883
 			var dewater_amount float64
2884 2884
 			dewater_amount = 0
2885 2885
 			if dry_weight > 0 {
2886 2886
 				dewater_amount = weight_before - dry_weight - additional_weight
2887 2887
 
2888
-				if adminUserInfo.CurrentOrgId != 10551 && adminUserInfo.CurrentOrgId != 10579 && adminUserInfo.CurrentOrgId != 10580 && adminUserInfo.CurrentOrgId != 10585 && adminUserInfo.CurrentOrgId != 10344 && adminUserInfo.CurrentOrgId != 10622 && adminUserInfo.CurrentOrgId != 10702 && adminUserInfo.CurrentOrgId != 10635 && adminUserInfo.CurrentOrgId != 10723 {
2888
+				if adminUserInfo.CurrentOrgId != 10551 && adminUserInfo.CurrentOrgId != 10579 && adminUserInfo.CurrentOrgId != 10580 && adminUserInfo.CurrentOrgId != 10585 && adminUserInfo.CurrentOrgId != 10344 && adminUserInfo.CurrentOrgId != 10622 && adminUserInfo.CurrentOrgId != 10702 && adminUserInfo.CurrentOrgId != 10635 && adminUserInfo.CurrentOrgId != 10723 && adminUserInfo.CurrentOrgId != 10480 && adminUserInfo.CurrentOrgId != 10293 && adminUserInfo.CurrentOrgId != 9478 {
2889 2889
 					dewater_amount = dewater_amount * 1000
2890 2890
 				}
2891 2891
 
@@ -3248,8 +3248,8 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
3248 3248
 		dewater_amount = 0
3249 3249
 		if evaluation.DryWeight > 0 {
3250 3250
 			dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
3251
-			if templateInfo.TemplateId == 17 || templateInfo.TemplateId == 22 || templateInfo.TemplateId == 21 || templateInfo.TemplateId == 34 || adminUserInfo.CurrentOrgId == 10551 || adminUserInfo.CurrentOrgId == 10751 || adminUserInfo.CurrentOrgId == 10757 {
3252
-				if adminUserInfo.CurrentOrgId != 10551 && adminUserInfo.CurrentOrgId != 10751 {
3251
+			if templateInfo.TemplateId == 17 || templateInfo.TemplateId == 22 || templateInfo.TemplateId == 21 || templateInfo.TemplateId == 34 || adminUserInfo.CurrentOrgId == 10551 || adminUserInfo.CurrentOrgId == 10751 || adminUserInfo.CurrentOrgId == 10757 || adminUserInfo.CurrentOrgId == 9478 {
3252
+				if adminUserInfo.CurrentOrgId != 10551 && adminUserInfo.CurrentOrgId != 10751 && adminUserInfo.CurrentOrgId != 9478 {
3253 3253
 					dewater_amount = dewater_amount * 1000
3254 3254
 				}
3255 3255
 
@@ -3526,7 +3526,7 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
3526 3526
 		}
3527 3527
 
3528 3528
 		//针对孝昌康桥超滤率计算问题
3529
-		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 {
3529
+		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 || adminUserInfo.CurrentOrgId == 9478 {
3530 3530
 			if assessmentBeforeDislysis.ID == 0 {
3531 3531
 				dialysisPrescribeOne, _ := service.MobileGetDialysisPrescribeOne(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
3532 3532
 				if dialysisPrescribeOne.ID > 0 && assessmentBeforeDislysis.ID > 0 {

+ 12 - 1
controllers/gobal_config_api_controller.go 查看文件

@@ -1150,6 +1150,13 @@ func (c *GobalConfigApiController) GetPrintInfo() {
1150 1150
 	idsInters := dataBody["ids"].([]interface{})
1151 1151
 	advice_type, _ := c.GetInt64("advice_type")
1152 1152
 	stop_type, _ := c.GetInt64("stop_type")
1153
+	his_str := c.GetString("his_str")
1154
+	if len(his_str) == 0 {
1155
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1156
+		return
1157
+	}
1158
+
1159
+	idStrs := strings.Split(his_str, ",")
1153 1160
 	if len(idsInters) == 0 {
1154 1161
 		if err != nil {
1155 1162
 			c.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除会员失败:(没有选择会员)")
@@ -1161,9 +1168,13 @@ func (c *GobalConfigApiController) GetPrintInfo() {
1161 1168
 		id := int64(idsInter.(float64))
1162 1169
 		ids = append(ids, id)
1163 1170
 	}
1171
+
1164 1172
 	getPrint, err := service.GetPrint(ids, OrgID, advice_type, stop_type)
1173
+
1174
+	hisPrint, _ := service.GetHisPrint(idStrs, OrgID)
1165 1175
 	c.ServeSuccessJSON(map[string]interface{}{
1166
-		"doctoradvice": getPrint,
1176
+		"doctoradvice":    getPrint,
1177
+		"hisdoctoradvice": hisPrint,
1167 1178
 	})
1168 1179
 }
1169 1180
 

+ 1 - 3
controllers/his_api_controller.go 查看文件

@@ -3494,7 +3494,7 @@ func (c *HisApiController) CreateHisPrescription() {
3494 3494
 	var adviceList []models.HisDoctorAdviceInfo
3495 3495
 	var projectList []models.HisPrescriptionProject
3496 3496
 
3497
-	if adminInfo.CurrentOrgId == 10489 || adminInfo.CurrentOrgId == 10510 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 10478 || adminInfo.CurrentOrgId == 10318 || adminInfo.CurrentOrgId == 10480 || adminInfo.CurrentOrgId == 10633 || adminInfo.CurrentOrgId == 10610 || adminInfo.CurrentOrgId == 10402 || adminInfo.CurrentOrgId == 10138 || adminInfo.CurrentOrgId == 10278 || adminInfo.CurrentOrgId == 10537 || adminInfo.CurrentOrgId == 10265 || adminInfo.CurrentOrgId == 10644 || adminInfo.CurrentOrgId == 10635 || adminInfo.CurrentOrgId == 10598 || adminInfo.CurrentOrgId == 10028 || adminInfo.CurrentOrgId == 10721 || adminInfo.CurrentOrgId == 10726 || adminInfo.CurrentOrgId == 10731 || adminInfo.CurrentOrgId == 10571 || adminInfo.CurrentOrgId == 10724 || adminInfo.CurrentOrgId == 9671 || adminInfo.CurrentOrgId == 10731 || adminInfo.CurrentOrgId == 10653 || adminInfo.CurrentOrgId == 10567 || adminInfo.CurrentOrgId == 10751 || adminInfo.CurrentOrgId == 10752 {
3497
+	if adminInfo.CurrentOrgId == 10489 || adminInfo.CurrentOrgId == 10510 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 10478 || adminInfo.CurrentOrgId == 10318 || adminInfo.CurrentOrgId == 10480 || adminInfo.CurrentOrgId == 10633 || adminInfo.CurrentOrgId == 10610 || adminInfo.CurrentOrgId == 10402 || adminInfo.CurrentOrgId == 10138 || adminInfo.CurrentOrgId == 10278 || adminInfo.CurrentOrgId == 10537 || adminInfo.CurrentOrgId == 10265 || adminInfo.CurrentOrgId == 10644 || adminInfo.CurrentOrgId == 10635 || adminInfo.CurrentOrgId == 10598 || adminInfo.CurrentOrgId == 10028 || adminInfo.CurrentOrgId == 10721 || adminInfo.CurrentOrgId == 10726 || adminInfo.CurrentOrgId == 10731 || adminInfo.CurrentOrgId == 10571 || adminInfo.CurrentOrgId == 10724 || adminInfo.CurrentOrgId == 9671 || adminInfo.CurrentOrgId == 10731 || adminInfo.CurrentOrgId == 10653 || adminInfo.CurrentOrgId == 10567 || adminInfo.CurrentOrgId == 10751 || adminInfo.CurrentOrgId == 10752 || adminInfo.CurrentOrgId == 9478 {
3498 3498
 		if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
3499 3499
 			prescriptions, _ := dataBody["prescriptions"].([]interface{})
3500 3500
 
@@ -3857,8 +3857,6 @@ func (c *HisApiController) CreateHisPrescription() {
3857 3857
 
3858 3858
 											}
3859 3859
 
3860
-											fmt.Println("s.ID==========================", s.ID)
3861
-
3862 3860
 											if s.ID > 0 {
3863 3861
 												//查询改药品是否已经停用
3864 3862
 												base, _ := service.GetBasedrugById(s.DrugId, s.UserOrgId)

+ 232 - 7
controllers/mobile_api_controllers/dialysis_api_controller.go 查看文件

@@ -3536,6 +3536,230 @@ func (c *DialysisAPIController) Finish() {
3536 3536
 
3537 3537
 	}
3538 3538
 
3539
+	//查找是否开启配置
3540
+	//orderSetting, _ := service.GetDialysisOrderSetting(adminUserInfo.Org.Id)
3541
+	////开启下机扣减
3542
+	//if orderSetting.IsOpen == 1 {
3543
+	//
3544
+	//	//查询今日患者排班的模式
3545
+	//	db := service.XTWriteDB()
3546
+	//	// 开始外部循环的事务
3547
+	//	tx := db.Begin()
3548
+	//	// 在函数结束时处理事务回滚
3549
+	//	defer func() {
3550
+	//		if r := recover(); r != nil {
3551
+	//			tx.Rollback()
3552
+	//		}
3553
+	//	}()
3554
+	//
3555
+	//	schedule, _ := service.GetDialysisOrderSchedule(id, recordDate.Unix(), adminUserInfo.Org.Id, tx)
3556
+	//
3557
+	//	if schedule.ModeId == 1 {
3558
+	//		//扣减库存
3559
+	//		service.ReducePatientCount(1, schedule.ModeId, id, tx)
3560
+	//
3561
+	//		patient, _ := service.GetSfPatientById(tx, id)
3562
+	//		var over_count int64
3563
+	//		if schedule.ModeId == 1 {
3564
+	//			over_count = patient.HdCount
3565
+	//		}
3566
+	//		if schedule.ModeId == 2 {
3567
+	//			over_count = patient.HdfCount
3568
+	//		}
3569
+	//
3570
+	//		if schedule.ModeId == 3 {
3571
+	//			over_count = patient.HdhpCount
3572
+	//		}
3573
+	//		if schedule.ModeId == 4 {
3574
+	//			over_count = patient.HpCount
3575
+	//		}
3576
+	//		if schedule.ModeId == 5 {
3577
+	//			over_count = patient.OtherCount
3578
+	//		}
3579
+	//		patientCountFlow := models.SfPatientCountFlow{
3580
+	//			PatientId:      id,
3581
+	//			ModeId:         schedule.ModeId,
3582
+	//			Count:          1,
3583
+	//			Status:         1,
3584
+	//			Ctime:          time.Now().Unix(),
3585
+	//			Mtime:          time.Now().Unix(),
3586
+	//			RecordDate:     recordDate.Unix(),
3587
+	//			UserOrgId:      adminUserInfo.Org.Id,
3588
+	//			Creater:        adminUserInfo.AdminUser.Id,
3589
+	//			IsType:         1,
3590
+	//			OverCount:      over_count,
3591
+	//			WarehouseOutId: 0,
3592
+	//		}
3593
+	//
3594
+	//		service.CreatePatientCountFlow(patientCountFlow, tx)
3595
+	//	}
3596
+	//
3597
+	//	if schedule.ModeId == 2 {
3598
+	//
3599
+	//		//扣减库存
3600
+	//		service.ReducePatientCount(1, schedule.ModeId, id, tx)
3601
+	//
3602
+	//		patient, _ := service.GetSfPatientById(tx, id)
3603
+	//		var over_count int64
3604
+	//		if schedule.ModeId == 1 {
3605
+	//			over_count = patient.HdCount
3606
+	//		}
3607
+	//		if schedule.ModeId == 2 {
3608
+	//			over_count = patient.HdfCount
3609
+	//		}
3610
+	//
3611
+	//		if schedule.ModeId == 3 {
3612
+	//			over_count = patient.HdhpCount
3613
+	//		}
3614
+	//		if schedule.ModeId == 4 {
3615
+	//			over_count = patient.HpCount
3616
+	//		}
3617
+	//		if schedule.ModeId == 5 {
3618
+	//			over_count = patient.OtherCount
3619
+	//		}
3620
+	//		patientCountFlow := models.SfPatientCountFlow{
3621
+	//			PatientId:      id,
3622
+	//			ModeId:         schedule.ModeId,
3623
+	//			Count:          1,
3624
+	//			Status:         1,
3625
+	//			Ctime:          time.Now().Unix(),
3626
+	//			Mtime:          time.Now().Unix(),
3627
+	//			RecordDate:     recordDate.Unix(),
3628
+	//			UserOrgId:      adminUserInfo.Org.Id,
3629
+	//			Creater:        adminUserInfo.AdminUser.Id,
3630
+	//			IsType:         2,
3631
+	//			OverCount:      over_count,
3632
+	//			WarehouseOutId: 0,
3633
+	//		}
3634
+	//
3635
+	//		service.CreatePatientCountFlow(patientCountFlow, tx)
3636
+	//	}
3637
+	//
3638
+	//	if schedule.ModeId == 3 {
3639
+	//
3640
+	//		//扣减库存
3641
+	//		service.ReducePatientCount(1, schedule.ModeId, id, tx)
3642
+	//
3643
+	//		patient, _ := service.GetSfPatientById(tx, id)
3644
+	//		var over_count int64
3645
+	//		if schedule.ModeId == 1 {
3646
+	//			over_count = patient.HdCount
3647
+	//		}
3648
+	//		if schedule.ModeId == 2 {
3649
+	//			over_count = patient.HdfCount
3650
+	//		}
3651
+	//
3652
+	//		if schedule.ModeId == 3 {
3653
+	//			over_count = patient.HdhpCount
3654
+	//		}
3655
+	//		if schedule.ModeId == 4 {
3656
+	//			over_count = patient.HpCount
3657
+	//		}
3658
+	//		if schedule.ModeId == 5 {
3659
+	//			over_count = patient.OtherCount
3660
+	//		}
3661
+	//		patientCountFlow := models.SfPatientCountFlow{
3662
+	//			PatientId:      id,
3663
+	//			ModeId:         schedule.ModeId,
3664
+	//			Count:          1,
3665
+	//			Status:         1,
3666
+	//			Ctime:          time.Now().Unix(),
3667
+	//			Mtime:          time.Now().Unix(),
3668
+	//			RecordDate:     recordDate.Unix(),
3669
+	//			UserOrgId:      adminUserInfo.Org.Id,
3670
+	//			Creater:        adminUserInfo.AdminUser.Id,
3671
+	//			IsType:         3,
3672
+	//			OverCount:      over_count,
3673
+	//			WarehouseOutId: 0,
3674
+	//		}
3675
+	//
3676
+	//		service.CreatePatientCountFlow(patientCountFlow, tx)
3677
+	//	}
3678
+	//	if schedule.ModeId == 4 {
3679
+	//
3680
+	//		//扣减库存
3681
+	//		service.ReducePatientCount(1, schedule.ModeId, id, tx)
3682
+	//
3683
+	//		patient, _ := service.GetSfPatientById(tx, id)
3684
+	//		var over_count int64
3685
+	//		if schedule.ModeId == 1 {
3686
+	//			over_count = patient.HdCount
3687
+	//		}
3688
+	//		if schedule.ModeId == 2 {
3689
+	//			over_count = patient.HdfCount
3690
+	//		}
3691
+	//
3692
+	//		if schedule.ModeId == 3 {
3693
+	//			over_count = patient.HdhpCount
3694
+	//		}
3695
+	//		if schedule.ModeId == 4 {
3696
+	//			over_count = patient.HpCount
3697
+	//		}
3698
+	//		if schedule.ModeId == 5 {
3699
+	//			over_count = patient.OtherCount
3700
+	//		}
3701
+	//		patientCountFlow := models.SfPatientCountFlow{
3702
+	//			PatientId:      id,
3703
+	//			ModeId:         schedule.ModeId,
3704
+	//			Count:          1,
3705
+	//			Status:         1,
3706
+	//			Ctime:          time.Now().Unix(),
3707
+	//			Mtime:          time.Now().Unix(),
3708
+	//			RecordDate:     recordDate.Unix(),
3709
+	//			UserOrgId:      adminUserInfo.Org.Id,
3710
+	//			Creater:        adminUserInfo.AdminUser.Id,
3711
+	//			IsType:         4,
3712
+	//			OverCount:      over_count,
3713
+	//			WarehouseOutId: 0,
3714
+	//		}
3715
+	//
3716
+	//		service.CreatePatientCountFlow(patientCountFlow, tx)
3717
+	//	}
3718
+	//	if schedule.ModeId != 1 && schedule.ModeId != 2 && schedule.ModeId != 3 && schedule.ModeId != 4 {
3719
+	//
3720
+	//		//扣减库存
3721
+	//		service.ReducePatientCount(1, schedule.ModeId, id, tx)
3722
+	//
3723
+	//		patient, _ := service.GetSfPatientById(tx, id)
3724
+	//		var over_count int64
3725
+	//		if schedule.ModeId == 1 {
3726
+	//			over_count = patient.HdCount
3727
+	//		}
3728
+	//		if schedule.ModeId == 2 {
3729
+	//			over_count = patient.HdfCount
3730
+	//		}
3731
+	//
3732
+	//		if schedule.ModeId == 3 {
3733
+	//			over_count = patient.HdhpCount
3734
+	//		}
3735
+	//		if schedule.ModeId == 4 {
3736
+	//			over_count = patient.HpCount
3737
+	//		}
3738
+	//		if schedule.ModeId == 5 {
3739
+	//			over_count = patient.OtherCount
3740
+	//		}
3741
+	//		patientCountFlow := models.SfPatientCountFlow{
3742
+	//			PatientId:      id,
3743
+	//			ModeId:         schedule.ModeId,
3744
+	//			Count:          1,
3745
+	//			Status:         1,
3746
+	//			Ctime:          time.Now().Unix(),
3747
+	//			Mtime:          time.Now().Unix(),
3748
+	//			RecordDate:     recordDate.Unix(),
3749
+	//			UserOrgId:      adminUserInfo.Org.Id,
3750
+	//			Creater:        adminUserInfo.AdminUser.Id,
3751
+	//			IsType:         5,
3752
+	//			OverCount:      over_count,
3753
+	//			WarehouseOutId: 0,
3754
+	//		}
3755
+	//
3756
+	//		service.CreatePatientCountFlow(patientCountFlow, tx)
3757
+	//	}
3758
+	//
3759
+	//	tx.Commit()
3760
+	//	return
3761
+	//}
3762
+
3539 3763
 }
3540 3764
 
3541 3765
 func (c *DialysisAPIController) GetAllZone() {
@@ -3916,7 +4140,7 @@ func (this *DialysisAPIController) StartDialysis() {
3916 4140
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
3917 4141
 			}
3918 4142
 
3919
-			if adminUserInfo.Org.Id == 10742 || adminUserInfo.Org.Id == 10740 || adminUserInfo.Org.Id == 10745 {
4143
+			if adminUserInfo.Org.Id == 10742 || adminUserInfo.Org.Id == 10740 || adminUserInfo.Org.Id == 10745 || adminUserInfo.Org.Id == 9478 {
3920 4144
 				ultrafiltration_rate = math.Floor(prescription.PrescriptionWater / float64(totalMin) * 60 * 1000)
3921 4145
 			}
3922 4146
 
@@ -4091,7 +4315,7 @@ func (this *DialysisAPIController) StartDialysis() {
4091 4315
 				}
4092 4316
 			}
4093 4317
 
4094
-			if adminUserInfo.Org.Id == 10702 || adminUserInfo.Org.Id == 10731 || adminUserInfo.Org.Id == 10727 {
4318
+			if adminUserInfo.Org.Id == 10702 || adminUserInfo.Org.Id == 10731 || adminUserInfo.Org.Id == 10727 || adminUserInfo.Org.Id == 10744 {
4095 4319
 				if prescription.ModeId == 2 {
4096 4320
 					totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
4097 4321
 					if totalMin == 0 {
@@ -5237,8 +5461,9 @@ func (this *DialysisAPIController) GetLastMonitorRecordTody() {
5237 5461
 			}
5238 5462
 
5239 5463
 			//重庆塘坝卫生院
5240
-			if adminInfo.Org.Id == 10742 || adminInfo.Org.Id == 10740 || adminInfo.Org.Id == 10745 {
5464
+			if adminInfo.Org.Id == 10742 || adminInfo.Org.Id == 10740 || adminInfo.Org.Id == 10745 || adminInfo.Org.Id == 9478 {
5241 5465
 				ultrafiltration_rate = math.Floor(prescription.PrescriptionWater / float64(totalMin) * 60 * 1000)
5466
+				fmt.Println("ultrafiltration_rate--------------------", ultrafiltration_rate)
5242 5467
 				record.UltrafiltrationRate = ultrafiltration_rate
5243 5468
 			}
5244 5469
 
@@ -5428,7 +5653,7 @@ func (this *DialysisAPIController) GetLastMonitorRecordTody() {
5428 5653
 	}
5429 5654
 
5430 5655
 	//长沙南雅
5431
-	if adminInfo.Org.Id == 10395 || adminInfo.Org.Id == 10138 || adminInfo.Org.Id == 10278 || adminInfo.Org.Id == 10432 || adminInfo.Org.Id == 10441 || adminInfo.Org.Id == 10445 || adminInfo.Org.Id == 10469 || adminInfo.Org.Id == 10375 || adminInfo.Org.Id == 10610 || adminInfo.Org.Id == 10537 || adminInfo.Org.Id == 10667 {
5656
+	if adminInfo.Org.Id == 10395 || adminInfo.Org.Id == 10138 || adminInfo.Org.Id == 10278 || adminInfo.Org.Id == 10432 || adminInfo.Org.Id == 10441 || adminInfo.Org.Id == 10445 || adminInfo.Org.Id == 10469 || adminInfo.Org.Id == 10375 || adminInfo.Org.Id == 10610 || adminInfo.Org.Id == 10537 || adminInfo.Org.Id == 10667 || adminInfo.Org.Id == 9478 {
5432 5657
 
5433 5658
 		if ultrafiltration_rate > 0 {
5434 5659
 			ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
@@ -5509,7 +5734,7 @@ func (this *DialysisAPIController) GetLastMonitorRecordTody() {
5509 5734
 		}
5510 5735
 	}
5511 5736
 
5512
-	if adminInfo.Org.Id == 10721 || adminInfo.Org.Id == 10757 {
5737
+	if adminInfo.Org.Id == 10721 || adminInfo.Org.Id == 10757 || adminInfo.Org.Id == 9478 || adminInfo.Org.Id == 10290 {
5513 5738
 		var replacement_rate float64
5514 5739
 		var displacement_quantity float64
5515 5740
 		totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
@@ -5533,7 +5758,7 @@ func (this *DialysisAPIController) GetLastMonitorRecordTody() {
5533 5758
 
5534 5759
 	}
5535 5760
 
5536
-	if adminInfo.Org.Id == 10740 || adminInfo.Org.Id == 10742 || adminInfo.Org.Id == 10745 {
5761
+	if adminInfo.Org.Id == 10740 || adminInfo.Org.Id == 10742 || adminInfo.Org.Id == 10745 || adminInfo.Org.Id == 9478 {
5537 5762
 
5538 5763
 		var replacement_rate float64
5539 5764
 		var displacement_quantity float64
@@ -5552,7 +5777,7 @@ func (this *DialysisAPIController) GetLastMonitorRecordTody() {
5552 5777
 		record.UltrafiltrationVolume = ultrafiltration_volume
5553 5778
 	}
5554 5779
 
5555
-	if adminInfo.Org.Id == 10731 || adminInfo.Org.Id == 10727 {
5780
+	if adminInfo.Org.Id == 10731 || adminInfo.Org.Id == 10727 || adminInfo.Org.Id == 10744 {
5556 5781
 
5557 5782
 		var replacement_rate float64
5558 5783
 		var displacement_quantity float64

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

@@ -3878,9 +3878,9 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
3878 3878
 	if evaluation.DryWeight > 0 {
3879 3879
 		dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
3880 3880
 
3881
-		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 {
3881
+		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 || adminUserInfo.Org.Id == 9478 {
3882 3882
 
3883
-			if adminUserInfo.Org.Id != 10551 && adminUserInfo.Org.Id != 10579 && adminUserInfo.Org.Id != 10580 && adminUserInfo.Org.Id != 10585 && adminUserInfo.Org.Id != 10752 {
3883
+			if adminUserInfo.Org.Id != 10551 && adminUserInfo.Org.Id != 10579 && adminUserInfo.Org.Id != 10580 && adminUserInfo.Org.Id != 10585 && adminUserInfo.Org.Id != 10752 && adminUserInfo.Org.Id != 9478 {
3884 3884
 				dewater_amount = dewater_amount * 1000
3885 3885
 			}
3886 3886
 
@@ -4603,7 +4603,7 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
4603 4603
 	}
4604 4604
 
4605 4605
 	//针对孝昌康桥超滤率计算问题
4606
-	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 {
4606
+	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 || adminUserInfo.Org.Id == 9478 {
4607 4607
 		if evaluation.ID == 0 {
4608 4608
 			dialysisPrescribeOne, _ := service.MobileGetDialysisPrescribeOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
4609 4609
 			if dialysisPrescribeOne.ID > 0 && evaluation.ID > 0 {

+ 19 - 1
controllers/new_mobile_api_controllers/staff_schedule_api_controller.go 查看文件

@@ -407,7 +407,7 @@ func (this *StaffScheduleApiController) GetAllZonePb() {
407 407
 	timenow := time.Now().Format("2006-01-02")
408 408
 	timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timenow)
409 409
 	//针对百霖和贝尔
410
-	if orgid == 10138 || orgid == 10278 || orgid == 3877 {
410
+	if orgid == 10138 || orgid == 10278 || orgid == 3877 || orgid == 10610 || orgid == 10537 {
411 411
 		//获取今日的排班数据
412 412
 		list, _ := service.GetMobileScheduleListByScheduleDate(orgid, startTime)
413 413
 		for _, item := range list {
@@ -1629,3 +1629,21 @@ func (c *StaffScheduleApiController) GetMobileDialysisCount() {
1629 1629
 		"order": order,
1630 1630
 	})
1631 1631
 }
1632
+
1633
+func (c *StaffScheduleApiController) GetPatientialysisSolutonByPatientId() {
1634
+
1635
+	patient_id, _ := c.GetInt64("patient_id")
1636
+
1637
+	record_date, _ := c.GetInt64("record_date")
1638
+
1639
+	orgId := c.GetAdminUserInfo().CurrentOrgId
1640
+
1641
+	schedule, _ := service.GetPatientScheduleByPatient(patient_id, record_date, orgId)
1642
+
1643
+	dialysisSolution, _ := service.GetDialysisSolutonByScheduleModeId(schedule.ModeId, patient_id, orgId)
1644
+
1645
+	c.ServeSuccessJSON(map[string]interface{}{
1646
+		"dialysisSolution": dialysisSolution,
1647
+	})
1648
+
1649
+}

+ 2 - 0
controllers/new_mobile_api_controllers/staff_schedule_api_router.go 查看文件

@@ -42,4 +42,6 @@ func StaffScheduleApiControllersRegisterRouters() {
42 42
 
43 43
 	beego.Router("/m/api/patient/getmobiledialysiscount", &StaffScheduleApiController{}, "Get:GetMobileDialysisCount")
44 44
 
45
+	beego.Router("/api/schedule/getpatientdialysissolutionbypatientid", &StaffScheduleApiController{}, "Get:GetPatientialysisSolutonByPatientId")
46
+
45 47
 }

+ 639 - 30
controllers/patient_api_controller.go 查看文件

@@ -233,7 +233,31 @@ func PatientApiRegistRouters() {
233 233
 
234 234
 	beego.Router("/api/patient/checkpatientcount", &PatientApiController{}, "Get:CheckPatientCount")
235 235
 
236
-	beego.Router("/api/patient/returncheckpatientcount", &PatientApiController{}, "Get:ReturnCheckPatientCount")
236
+	beego.Router("/api/patient/returncheck", &PatientApiController{}, "Get:ReturnCheckPatientCount")
237
+
238
+	beego.Router("/api/patient/deletepatientcount", &PatientApiController{}, "Get:DeletePatientCount")
239
+
240
+	beego.Router("/api/patient/savepatientoutcount", &PatientApiController{}, "Get:SavePatientOutCount")
241
+
242
+	beego.Router("/api/patient/getpatientoutcountlist", &PatientApiController{}, "Get:GetPatientOutCountList")
243
+
244
+	beego.Router("/api/patient/deletepatientoutcount", &PatientApiController{}, "Get:DeletePatientOutCount")
245
+
246
+	beego.Router("/api/patient/checkpatientoutcount", &PatientApiController{}, "Get:CheckPatientOutCount")
247
+
248
+	beego.Router("/api/patient/returnpatientoutlist", &PatientApiController{}, "Get:ReturnPatientOutList")
249
+
250
+	beego.Router("/api/patient/getpatientcountmaplist", &PatientApiController{}, "Get:GetPatientCountMapList")
251
+
252
+	beego.Router("/api/patient/getpatientcountflow", &PatientApiController{}, "Get:GetPatientCountFlow")
253
+
254
+	beego.Router("/api/patient/getdialysisordersetting", &PatientApiController{}, "Get:GetDialysisOrderSetting")
255
+
256
+	beego.Router("/api/patient/savepatientordersetting", &PatientApiController{}, "Get:SavePatientOrderSetting")
257
+
258
+	beego.Router("/api/patient/getpatientcountflowlist", &PatientApiController{}, "Get:GetPatientCountFlowList")
259
+
260
+	beego.Router("/api/patient/getpatientcountflowbyid", &PatientApiController{}, "Get:GetPatientCountFlowById")
237 261
 
238 262
 }
239 263
 func (c *PatientApiController) GetExportList() {
@@ -9111,25 +9135,6 @@ func (this *PatientApiController) SavePatientCount() {
9111 9135
 
9112 9136
 	nowtime := recordDate.Unix()
9113 9137
 
9114
-	patientInCount := models.SfPatientInCount{
9115
-		PatientId:  patient_id,
9116
-		UserOrgId:  orgId,
9117
-		HdCount:    hd_count,
9118
-		HdfCount:   hdf_count,
9119
-		HdhpCount:  hdhp_count,
9120
-		HpCount:    hp_count,
9121
-		Status:     1,
9122
-		Creater:    creater,
9123
-		Ctime:      time.Now().Unix(),
9124
-		Mtime:      time.Now().Unix(),
9125
-		IsCheck:    2,
9126
-		RecordDate: nowtime,
9127
-		Remark:     remark,
9128
-		OtherCount: other_count,
9129
-	}
9130
-
9131
-	fmt.Println(patientInCount)
9132
-
9133 9138
 	db := service.XTWriteDB()
9134 9139
 	// 开始外部循环的事务
9135 9140
 	tx := db.Begin()
@@ -9140,14 +9145,110 @@ func (this *PatientApiController) SavePatientCount() {
9140 9145
 		}
9141 9146
 	}()
9142 9147
 
9143
-	service.CreatePatientInCount(tx, patientInCount)
9148
+	if hd_count > 0 {
9149
+		patientInCount := models.SfPatientInCount{
9150
+			PatientId:  patient_id,
9151
+			UserOrgId:  orgId,
9152
+			IsType:     1,
9153
+			Count:      hd_count,
9154
+			Status:     1,
9155
+			Creater:    creater,
9156
+			Ctime:      time.Now().Unix(),
9157
+			Mtime:      time.Now().Unix(),
9158
+			IsCheck:    2,
9159
+			RecordDate: nowtime,
9160
+			Remark:     remark,
9161
+			StockCount: hd_count,
9162
+		}
9163
+
9164
+		service.CreatePatientInCount(tx, patientInCount)
9165
+
9166
+	}
9167
+
9168
+	if hdf_count > 0 {
9169
+
9170
+		patientInCount := models.SfPatientInCount{
9171
+			PatientId:  patient_id,
9172
+			UserOrgId:  orgId,
9173
+			IsType:     2,
9174
+			Count:      hdf_count,
9175
+			Status:     1,
9176
+			Creater:    creater,
9177
+			Ctime:      time.Now().Unix(),
9178
+			Mtime:      time.Now().Unix(),
9179
+			IsCheck:    2,
9180
+			RecordDate: nowtime,
9181
+			Remark:     remark,
9182
+			StockCount: hdf_count,
9183
+		}
9184
+
9185
+		service.CreatePatientInCount(tx, patientInCount)
9186
+
9187
+	}
9188
+
9189
+	if hdhp_count > 0 {
9190
+
9191
+		patientInCount := models.SfPatientInCount{
9192
+			PatientId:  patient_id,
9193
+			UserOrgId:  orgId,
9194
+			IsType:     3,
9195
+			Count:      hdhp_count,
9196
+			Status:     1,
9197
+			Creater:    creater,
9198
+			Ctime:      time.Now().Unix(),
9199
+			Mtime:      time.Now().Unix(),
9200
+			IsCheck:    2,
9201
+			RecordDate: nowtime,
9202
+			Remark:     remark,
9203
+			StockCount: hdhp_count,
9204
+		}
9205
+
9206
+		service.CreatePatientInCount(tx, patientInCount)
9207
+	}
9208
+
9209
+	if hp_count > 0 {
9210
+
9211
+		patientInCount := models.SfPatientInCount{
9212
+			PatientId:  patient_id,
9213
+			UserOrgId:  orgId,
9214
+			IsType:     4,
9215
+			Count:      hp_count,
9216
+			Status:     1,
9217
+			Creater:    creater,
9218
+			Ctime:      time.Now().Unix(),
9219
+			Mtime:      time.Now().Unix(),
9220
+			IsCheck:    2,
9221
+			RecordDate: nowtime,
9222
+			Remark:     remark,
9223
+			StockCount: hp_count,
9224
+		}
9225
+		service.CreatePatientInCount(tx, patientInCount)
9226
+	}
9227
+
9228
+	if other_count > 0 {
9229
+
9230
+		patientInCount := models.SfPatientInCount{
9231
+			PatientId:  patient_id,
9232
+			UserOrgId:  orgId,
9233
+			IsType:     5,
9234
+			Count:      other_count,
9235
+			Status:     1,
9236
+			Creater:    creater,
9237
+			Ctime:      time.Now().Unix(),
9238
+			Mtime:      time.Now().Unix(),
9239
+			IsCheck:    2,
9240
+			RecordDate: nowtime,
9241
+			Remark:     remark,
9242
+			StockCount: other_count,
9243
+		}
9144 9244
 
9145
-	service.ModifyPatientCount(tx, hd_count, hdf_count, hdhp_count, hp_count, patient_id)
9245
+		service.CreatePatientInCount(tx, patientInCount)
9246
+	}
9146 9247
 
9147 9248
 	tx.Commit()
9148 9249
 
9149 9250
 	this.ServeSuccessJSON(map[string]interface{}{
9150
-		"patientInCount": patientInCount,
9251
+		"msg": "保存成功",
9151 9252
 	})
9152 9253
 
9153 9254
 }
@@ -9155,14 +9256,43 @@ func (this *PatientApiController) SavePatientCount() {
9155 9256
 func (this *PatientApiController) GetPatientCountList() {
9156 9257
 
9157 9258
 	orgId := this.GetAdminUserInfo().CurrentOrgId
9259
+	appId := this.GetAdminUserInfo().CurrentAppId
9158 9260
 	patient_id, _ := this.GetInt64("patient_id")
9159 9261
 	page, _ := this.GetInt64("page")
9160 9262
 	limit, _ := this.GetInt64("limit")
9161
-	patient, total, _ := service.GetPatientCountList(orgId, patient_id, page, limit)
9263
+	start_time := this.GetString("start_time")
9264
+	end_time := this.GetString("end_time")
9265
+	timeLayout := "2006-01-02"
9266
+	loc, _ := time.LoadLocation("Local")
9267
+	var startTime int64
9268
+	if len(start_time) > 0 {
9269
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
9270
+		if err != nil {
9271
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9272
+			return
9273
+		}
9274
+		startTime = theTime.Unix()
9275
+	}
9276
+
9277
+	var endTime int64
9278
+	if len(end_time) > 0 {
9279
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
9280
+		if err != nil {
9281
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9282
+			return
9283
+		}
9284
+		endTime = theTime.Unix()
9285
+	}
9286
+	list, total, _ := service.GetPatientCountList(orgId, patient_id, page, limit, startTime, endTime)
9287
+	patient, _ := service.GetPatientMapListOne(orgId)
9288
+
9289
+	userList, _ := service.GetAllAdminUserList(orgId, appId)
9162 9290
 
9163 9291
 	this.ServeSuccessJSON(map[string]interface{}{
9164
-		"patient": patient,
9165
-		"total":   total,
9292
+		"list":     list,
9293
+		"total":    total,
9294
+		"patient":  patient,
9295
+		"userList": userList,
9166 9296
 	})
9167 9297
 }
9168 9298
 
@@ -9170,7 +9300,64 @@ func (this *PatientApiController) CheckPatientCount() {
9170 9300
 
9171 9301
 	id, _ := this.GetInt64("id")
9172 9302
 
9173
-	checkpatientcount, _ := service.CheckPatientCount(id)
9303
+	db := service.XTWriteDB()
9304
+	// 开始外部循环的事务
9305
+	tx := db.Begin()
9306
+	// 在函数结束时处理事务回滚
9307
+	defer func() {
9308
+		if r := recover(); r != nil {
9309
+			tx.Rollback()
9310
+		}
9311
+	}()
9312
+
9313
+	creater := this.GetAdminUserInfo().AdminUser.Id
9314
+
9315
+	recordDateStr := time.Now().Format("2006-01-02")
9316
+	recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
9317
+
9318
+	warehouseInfo, _ := service.GetPatientCountById(id, tx)
9319
+
9320
+	if warehouseInfo.ID > 0 {
9321
+		service.ModiftyPatientCount(warehouseInfo.Count, warehouseInfo.IsType, warehouseInfo.PatientId, tx)
9322
+		patient, _ := service.GetSfPatientById(tx, warehouseInfo.PatientId)
9323
+
9324
+		var over_count int64
9325
+		if warehouseInfo.IsType == 1 {
9326
+			over_count = patient.HdCount
9327
+		}
9328
+		if warehouseInfo.IsType == 2 {
9329
+			over_count = patient.HdfCount
9330
+		}
9331
+
9332
+		if warehouseInfo.IsType == 3 {
9333
+			over_count = patient.HdhpCount
9334
+		}
9335
+		if warehouseInfo.IsType == 4 {
9336
+			over_count = patient.HpCount
9337
+		}
9338
+		if warehouseInfo.IsType == 5 {
9339
+			over_count = patient.OtherCount
9340
+		}
9341
+		patientCountFlow := models.SfPatientCountFlow{
9342
+			UserOrgId:       warehouseInfo.UserOrgId,
9343
+			Count:           warehouseInfo.Count,
9344
+			ModeId:          warehouseInfo.IsType,
9345
+			IsType:          1,
9346
+			PatientId:       warehouseInfo.PatientId,
9347
+			Status:          1,
9348
+			Ctime:           time.Now().Unix(),
9349
+			Mtime:           time.Now().Unix(),
9350
+			OverCount:       over_count,
9351
+			RecordDate:      recordDate.Unix(),
9352
+			Creater:         creater,
9353
+			WarehouseInfoId: warehouseInfo.ID,
9354
+		}
9355
+		service.CreatePatientCountFlow(patientCountFlow, tx)
9356
+	}
9357
+
9358
+	checkpatientcount, _ := service.CheckPatientCount(id, tx)
9359
+
9360
+	tx.Commit()
9174 9361
 
9175 9362
 	this.ServeSuccessJSON(map[string]interface{}{
9176 9363
 		"checkpatientcount": checkpatientcount,
@@ -9191,11 +9378,13 @@ func (this *PatientApiController) ReturnCheckPatientCount() {
9191 9378
 		}
9192 9379
 	}()
9193 9380
 
9194
-	patientCount, _ := service.ReturnCheckPatientCount(id)
9381
+	patientCountObj, _ := service.GetPatientCountById(id, tx)
9195 9382
 
9196
-	patientCountObj, _ := service.GetPatientCountById(id)
9383
+	service.ReducePatientCount(patientCountObj.Count, patientCountObj.IsType, patientCountObj.PatientId, tx)
9197 9384
 
9198
-	service.UpdatePatientInCount(tx, patientCountObj.HdCount, patientCountObj.HdfCount, patientCountObj.HdhpCount, patientCountObj.HpCount, patientCountObj.PatientId)
9385
+	patientCount, _ := service.ReturnCheckPatientCount(id, tx)
9386
+
9387
+	service.UpdatePatientCountFlow(id, tx)
9199 9388
 
9200 9389
 	tx.Commit()
9201 9390
 	this.ServeSuccessJSON(map[string]interface{}{
@@ -9203,3 +9392,423 @@ func (this *PatientApiController) ReturnCheckPatientCount() {
9203 9392
 	})
9204 9393
 
9205 9394
 }
9395
+
9396
+func (this *PatientApiController) DeletePatientCount() {
9397
+
9398
+	id, _ := this.GetInt64("id")
9399
+
9400
+	service.DeletePatientCount(id)
9401
+
9402
+	this.ServeSuccessJSON(map[string]interface{}{
9403
+		"msg": "删除成功!",
9404
+	})
9405
+
9406
+}
9407
+
9408
+func (this *PatientApiController) SavePatientOutCount() {
9409
+
9410
+	patient_id, _ := this.GetInt64("patient_id")
9411
+
9412
+	count, _ := this.GetInt64("count")
9413
+
9414
+	remark := this.GetString("remark")
9415
+
9416
+	mode_id, _ := this.GetInt64("mode_id")
9417
+
9418
+	creater := this.GetAdminUserInfo().AdminUser.Id
9419
+
9420
+	recordDateStr := time.Now().Format("2006-01-02")
9421
+	recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
9422
+
9423
+	orgId := this.GetAdminUserInfo().CurrentOrgId
9424
+
9425
+	sfPatientOutCount := models.SfPatientOutCount{
9426
+		UserOrgId:  orgId,
9427
+		PatientId:  patient_id,
9428
+		ModeId:     mode_id,
9429
+		Count:      count,
9430
+		Remark:     remark,
9431
+		Creater:    creater,
9432
+		Status:     1,
9433
+		Ctime:      time.Now().Unix(),
9434
+		Mtime:      time.Now().Unix(),
9435
+		IsCheck:    2,
9436
+		RecordDate: recordDate.Unix(),
9437
+	}
9438
+
9439
+	service.CreateSfPatientOutCount(sfPatientOutCount)
9440
+
9441
+	this.ServeSuccessJSON(map[string]interface{}{
9442
+		"msg": "保存成功!",
9443
+	})
9444
+
9445
+}
9446
+
9447
+func (this *PatientApiController) GetPatientOutCountList() {
9448
+
9449
+	orgId := this.GetAdminUserInfo().CurrentOrgId
9450
+
9451
+	limit, _ := this.GetInt64("limit")
9452
+
9453
+	page, _ := this.GetInt64("page")
9454
+
9455
+	patient_id, _ := this.GetInt64("patient_id")
9456
+
9457
+	start_time := this.GetString("start_time")
9458
+	end_time := this.GetString("end_time")
9459
+	timeLayout := "2006-01-02"
9460
+	loc, _ := time.LoadLocation("Local")
9461
+	var startTime int64
9462
+	if len(start_time) > 0 {
9463
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
9464
+		if err != nil {
9465
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9466
+			return
9467
+		}
9468
+		startTime = theTime.Unix()
9469
+	}
9470
+
9471
+	var endTime int64
9472
+	if len(end_time) > 0 {
9473
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
9474
+		if err != nil {
9475
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9476
+			return
9477
+		}
9478
+		endTime = theTime.Unix()
9479
+	}
9480
+
9481
+	outcount, total, _ := service.GetPatientOutCountList(patient_id, orgId, limit, page, startTime, endTime)
9482
+
9483
+	patient, _ := service.GetPatientMapListOne(orgId)
9484
+
9485
+	appId := this.GetAdminUserInfo().CurrentAppId
9486
+	userList, _ := service.GetAllAdminUserList(orgId, appId)
9487
+	this.ServeSuccessJSON(map[string]interface{}{
9488
+		"list":     outcount,
9489
+		"total":    total,
9490
+		"patient":  patient,
9491
+		"userList": userList,
9492
+	})
9493
+
9494
+}
9495
+
9496
+func (this *PatientApiController) DeletePatientOutCount() {
9497
+
9498
+	id, _ := this.GetInt64("id")
9499
+
9500
+	service.DeletePatientOutCount(id)
9501
+
9502
+	this.ServeSuccessJSON(map[string]interface{}{
9503
+		"msg": "ok",
9504
+	})
9505
+
9506
+}
9507
+
9508
+func (this *PatientApiController) CheckPatientOutCount() {
9509
+
9510
+	id, _ := this.GetInt64("id")
9511
+	db := service.XTWriteDB()
9512
+	// 开始外部循环的事务
9513
+	tx := db.Begin()
9514
+	// 在函数结束时处理事务回滚
9515
+	defer func() {
9516
+		if r := recover(); r != nil {
9517
+			tx.Rollback()
9518
+		}
9519
+	}()
9520
+	outCountList, _ := service.GetPatientOutCountById(id, tx)
9521
+
9522
+	creater := this.GetAdminUserInfo().AdminUser.Id
9523
+
9524
+	orgId := this.GetAdminUserInfo().CurrentOrgId
9525
+
9526
+	recordDateStr := time.Now().Format("2006-01-02")
9527
+	recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
9528
+
9529
+	if outCountList.ID > 0 {
9530
+
9531
+		//扣减库存
9532
+		service.ReducePatientCount(outCountList.Count, outCountList.ModeId, outCountList.PatientId, tx)
9533
+
9534
+		patient, _ := service.GetSfPatientById(tx, outCountList.PatientId)
9535
+
9536
+		var over_count int64
9537
+		if outCountList.ModeId == 1 {
9538
+			over_count = patient.HdCount
9539
+		}
9540
+		if outCountList.ModeId == 2 {
9541
+			over_count = patient.HdfCount
9542
+		}
9543
+
9544
+		if outCountList.ModeId == 3 {
9545
+			over_count = patient.HdhpCount
9546
+		}
9547
+		if outCountList.ModeId == 4 {
9548
+			over_count = patient.HpCount
9549
+		}
9550
+		if outCountList.ModeId == 5 {
9551
+			over_count = patient.OtherCount
9552
+		}
9553
+
9554
+		patientCountFlow := models.SfPatientCountFlow{
9555
+			PatientId:      outCountList.PatientId,
9556
+			ModeId:         outCountList.ModeId,
9557
+			Count:          outCountList.Count,
9558
+			Status:         1,
9559
+			Ctime:          time.Now().Unix(),
9560
+			Mtime:          time.Now().Unix(),
9561
+			RecordDate:     recordDate.Unix(),
9562
+			UserOrgId:      orgId,
9563
+			Creater:        creater,
9564
+			IsType:         2,
9565
+			OverCount:      over_count,
9566
+			WarehouseOutId: outCountList.ID,
9567
+		}
9568
+
9569
+		service.CreatePatientCountFlow(patientCountFlow, tx)
9570
+
9571
+	}
9572
+	//审核
9573
+	service.CheckPatientOutCount(id, tx)
9574
+
9575
+	tx.Commit()
9576
+
9577
+	this.ServeSuccessJSON(map[string]interface{}{
9578
+		"msg": "ok",
9579
+	})
9580
+
9581
+}
9582
+
9583
+func (this *PatientApiController) ReturnPatientOutList() {
9584
+
9585
+	id, _ := this.GetInt64("id")
9586
+	db := service.XTWriteDB()
9587
+	// 开始外部循环的事务
9588
+	tx := db.Begin()
9589
+	// 在函数结束时处理事务回滚
9590
+	defer func() {
9591
+		if r := recover(); r != nil {
9592
+			tx.Rollback()
9593
+		}
9594
+	}()
9595
+	outCountList, _ := service.GetPatientOutCountById(id, tx)
9596
+
9597
+	if outCountList.ID > 0 {
9598
+		//回退库存
9599
+		service.ModiftyPatientCount(outCountList.Count, outCountList.ModeId, outCountList.PatientId, tx)
9600
+
9601
+		service.DeletePatientCountFlow(id, tx)
9602
+	}
9603
+	//反审核
9604
+	service.ReturnPatientOutCount(id, tx)
9605
+
9606
+	tx.Commit()
9607
+	this.ServeSuccessJSON(map[string]interface{}{
9608
+		"msg": "ok",
9609
+	})
9610
+}
9611
+
9612
+func (this *PatientApiController) GetPatientCountMapList() {
9613
+
9614
+	patient_id, _ := this.GetInt64("patient_id")
9615
+
9616
+	limit, _ := this.GetInt64("limit")
9617
+
9618
+	page, _ := this.GetInt64("page")
9619
+
9620
+	orgId := this.GetAdminUserInfo().CurrentOrgId
9621
+
9622
+	list, total, _ := service.GetPatientCountMapList(patient_id, limit, page, orgId)
9623
+
9624
+	patient, _ := service.GetPatientMapListOne(orgId)
9625
+
9626
+	this.ServeSuccessJSON(map[string]interface{}{
9627
+		"list":    list,
9628
+		"total":   total,
9629
+		"patient": patient,
9630
+	})
9631
+}
9632
+
9633
+func (this *PatientApiController) GetPatientCountFlow() {
9634
+
9635
+	patient_id, _ := this.GetInt64("patient_id")
9636
+	is_type, _ := this.GetInt64("is_type")
9637
+	mode_id, _ := this.GetInt64("mode_id")
9638
+	orgId := this.GetAdminUserInfo().CurrentOrgId
9639
+	start_time := this.GetString("start_time")
9640
+	end_time := this.GetString("end_time")
9641
+	timeLayout := "2006-01-02"
9642
+	loc, _ := time.LoadLocation("Local")
9643
+	var startTime int64
9644
+	if len(start_time) > 0 {
9645
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
9646
+		if err != nil {
9647
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9648
+			return
9649
+		}
9650
+		startTime = theTime.Unix()
9651
+	}
9652
+
9653
+	var endTime int64
9654
+	if len(end_time) > 0 {
9655
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
9656
+		if err != nil {
9657
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9658
+			return
9659
+		}
9660
+		endTime = theTime.Unix()
9661
+	}
9662
+
9663
+	list, total, _ := service.GetPatientCountFlow(patient_id, orgId, is_type, mode_id, startTime, endTime)
9664
+
9665
+	patient, _ := service.GetSfPatientByIdOne(patient_id)
9666
+
9667
+	appId := this.GetAdminUserInfo().CurrentAppId
9668
+	userList, _ := service.GetAllAdminUserList(orgId, appId)
9669
+
9670
+	this.ServeSuccessJSON(map[string]interface{}{
9671
+		"list":     list,
9672
+		"total":    total,
9673
+		"patient":  patient,
9674
+		"userList": userList,
9675
+	})
9676
+}
9677
+
9678
+func (this *PatientApiController) GetDialysisOrderSetting() {
9679
+
9680
+	orgId := this.GetAdminUserInfo().CurrentOrgId
9681
+
9682
+	order, _ := service.GetDialysisOrderSetting(orgId)
9683
+
9684
+	this.ServeSuccessJSON(map[string]interface{}{
9685
+		"order": order,
9686
+	})
9687
+}
9688
+
9689
+func (this *PatientApiController) SavePatientOrderSetting() {
9690
+
9691
+	is_open, _ := this.GetInt64("is_open")
9692
+
9693
+	orgId := this.GetAdminUserInfo().CurrentOrgId
9694
+
9695
+	orderSetting := models.XtDialysisOrderSetting{
9696
+		IsOpen:    is_open,
9697
+		UserOrgId: orgId,
9698
+		Ctime:     time.Now().Unix(),
9699
+		Mtime:     time.Now().Unix(),
9700
+		Status:    1,
9701
+	}
9702
+
9703
+	service.CreateDialysisOrder(orderSetting)
9704
+
9705
+	this.ServeSuccessJSON(map[string]interface{}{
9706
+		"order": orderSetting,
9707
+	})
9708
+}
9709
+
9710
+func (this *PatientApiController) GetPatientCountFlowList() {
9711
+
9712
+	patient_id, _ := this.GetInt64("patient_id")
9713
+
9714
+	start_time := this.GetString("start_time")
9715
+
9716
+	end_time := this.GetString("end_time")
9717
+
9718
+	limit, _ := this.GetInt64("limit")
9719
+
9720
+	page, _ := this.GetInt64("page")
9721
+
9722
+	is_type, _ := this.GetInt64("is_type")
9723
+
9724
+	orgId := this.GetAdminUserInfo().CurrentOrgId
9725
+
9726
+	timeLayout := "2006-01-02"
9727
+	loc, _ := time.LoadLocation("Local")
9728
+	var startTime int64
9729
+	if len(start_time) > 0 {
9730
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
9731
+		if err != nil {
9732
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9733
+			return
9734
+		}
9735
+		startTime = theTime.Unix()
9736
+	}
9737
+
9738
+	var endTime int64
9739
+	if len(end_time) > 0 {
9740
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
9741
+		if err != nil {
9742
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9743
+			return
9744
+		}
9745
+		endTime = theTime.Unix()
9746
+	}
9747
+
9748
+	list, total, _ := service.GetPatientCountFlowList(patient_id, startTime, endTime, limit, page, orgId, is_type)
9749
+
9750
+	flowList, _ := service.GetPatientCountListFlowOne(patient_id, startTime, endTime, is_type, orgId)
9751
+
9752
+	patient, _ := service.GetPatientMapListOne(orgId)
9753
+
9754
+	appId := this.GetAdminUserInfo().CurrentAppId
9755
+	userList, _ := service.GetAllAdminUserList(orgId, appId)
9756
+
9757
+	this.ServeSuccessJSON(map[string]interface{}{
9758
+		"list":     list,
9759
+		"total":    total,
9760
+		"patient":  patient,
9761
+		"userList": userList,
9762
+		"flowList": flowList,
9763
+	})
9764
+}
9765
+
9766
+func (this *PatientApiController) GetPatientCountFlowById() {
9767
+
9768
+	patient_id, _ := this.GetInt64("patient_id")
9769
+
9770
+	start_time := this.GetString("start_time")
9771
+
9772
+	end_time := this.GetString("end_time")
9773
+
9774
+	is_type, _ := this.GetInt64("is_type")
9775
+
9776
+	mode_id, _ := this.GetInt64("mode_id")
9777
+
9778
+	orgId := this.GetAdminUserInfo().CurrentOrgId
9779
+
9780
+	appId := this.GetAdminUserInfo().CurrentAppId
9781
+
9782
+	timeLayout := "2006-01-02"
9783
+	loc, _ := time.LoadLocation("Local")
9784
+	var startTime int64
9785
+	if len(start_time) > 0 {
9786
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
9787
+		if err != nil {
9788
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9789
+			return
9790
+		}
9791
+		startTime = theTime.Unix()
9792
+	}
9793
+
9794
+	var endTime int64
9795
+	if len(end_time) > 0 {
9796
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
9797
+		if err != nil {
9798
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9799
+			return
9800
+		}
9801
+		endTime = theTime.Unix()
9802
+	}
9803
+
9804
+	flowList, _ := service.GetPatientCountFlowByIdList(patient_id, orgId, mode_id, is_type, startTime, endTime)
9805
+
9806
+	patient, _ := service.GetPatientMapListOne(orgId)
9807
+
9808
+	userList, _ := service.GetAllAdminUserList(orgId, appId)
9809
+	this.ServeSuccessJSON(map[string]interface{}{
9810
+		"list":     flowList,
9811
+		"patient":  patient,
9812
+		"userList": userList,
9813
+	})
9814
+}

+ 3 - 0
controllers/pharmacy_controller.go 查看文件

@@ -1469,7 +1469,10 @@ func (this *PharmacyController) GetDrugTocalCount() {
1469 1469
 
1470 1470
 	adviceList, _ := service.GetDrugTocalCountByDrugId(drug_id, startTime, orgId)
1471 1471
 
1472
+	drug, _ := service.GetNewBaseDrugById(drug_id)
1473
+
1472 1474
 	this.ServeSuccessJSON(map[string]interface{}{
1473 1475
 		"adviceList": adviceList,
1476
+		"drug":       drug,
1474 1477
 	})
1475 1478
 }

+ 8 - 28
controllers/statistics_api_controller.go 查看文件

@@ -1,17 +1,18 @@
1 1
 package controllers
2 2
 
3 3
 import (
4
+	"fmt"
5
+	"sort"
6
+	"strconv"
7
+	"strings"
8
+	"time"
9
+
4 10
 	"XT_New/enums"
5 11
 	"XT_New/models"
6 12
 	"XT_New/service"
7 13
 	"XT_New/service/statistics_service"
8 14
 	"XT_New/utils"
9
-	"fmt"
10 15
 	"github.com/astaxie/beego"
11
-	"sort"
12
-	"strconv"
13
-	"strings"
14
-	"time"
15 16
 )
16 17
 
17 18
 type StatisticsApiController struct {
@@ -497,28 +498,7 @@ func (c *StatisticsApiController) GetDialysisTotalDetail() {
497 498
 	mode, _ := c.GetInt64("mode")
498 499
 	origin, _ := c.GetInt64("origin")
499 500
 	time_way, _ := c.GetInt64("time_way")
500
-	//timeLayout := "2006-01-02"
501
-	//loc, _ := time.LoadLocation("Local")
502
-	//var startTime int64
503
-	//if len(start_date) > 0 {
504
-	//	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_date+" 00:00:00", loc)
505
-	//	fmt.Println("err-----------", err)
506
-	//	if err != nil {
507
-	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
508
-	//		return
509
-	//	}
510
-	//	//startTime = theTime.Unix()
511
-	//}
512
-	//var endTime int64
513
-	//if len(end_date) > 0 {
514
-	//	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_date+" 23:59:59", loc)
515
-	//	if err != nil {
516
-	//		utils.ErrorLog(err.Error())
517
-	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
518
-	//		return
519
-	//	}
520
-	//	//endTime = theTime.Unix()
521
-	//}
501
+
522 502
 	dates, err := splitDateRange(start_date, end_date)
523 503
 	if err != nil {
524 504
 		fmt.Println("Error:", err)
@@ -1833,7 +1813,7 @@ func (c *StatisticsApiController) GetPatientCommonInspectionStatistisc() {
1833 1813
 	var startTime int64
1834 1814
 	if len(start_date) > 0 {
1835 1815
 		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_date+" 00:00:00", loc)
1836
-		fmt.Println("err-----------", err)
1816
+
1837 1817
 		if err != nil {
1838 1818
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1839 1819
 			return

+ 1 - 1
models/dialysis.go 查看文件

@@ -346,7 +346,7 @@ type PredialysisEvaluationList struct {
346 346
 	SystolicBloodPressure  float64 `gorm:"column:systolic_blood_pressure" json:"systolic_blood_pressure"`
347 347
 	DiastolicBloodPressure float64 `gorm:"column:diastolic_blood_pressure" json:"diastolic_blood_pressure"`
348 348
 	DryWeight              float64 `gorm:"column:dry_weight" json:"dry_weight"`
349
-	Height                 int64   `gorm:"column:height" json:"height" form:"height"`
349
+	Height                 string  `gorm:"column:height" json:"height" form:"height"`
350 350
 }
351 351
 
352 352
 func (PredialysisEvaluationList) TableName() string {

+ 30 - 0
models/his_models.go 查看文件

@@ -3091,3 +3091,33 @@ type NewHisPrescription struct {
3091 3091
 func (NewHisPrescription) TableName() string {
3092 3092
 	return "his_prescription"
3093 3093
 }
3094
+
3095
+type NBHisDoctorAdviceInfo struct {
3096
+	ID                    int64   `gorm:"column:id" json:"id" form:"id"`
3097
+	UserOrgId             int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
3098
+	PatientId             int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
3099
+	AdviceDate            int64   `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
3100
+	AdviceName            string  `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
3101
+	PrescribingNumber     float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
3102
+	PrescribingNumberUnit string  `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
3103
+	AdviceDoctor          int64   `gorm:"column:advice_doctor" json:"advice_doctor" form:"advice_doctor"`
3104
+	Status                int64   `gorm:"column:status" json:"status" form:"status"`
3105
+	DrugId                int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
3106
+	DrugCode              string  `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
3107
+}
3108
+
3109
+func (NBHisDoctorAdviceInfo) TableName() string {
3110
+	return "his_doctor_advice_info"
3111
+}
3112
+
3113
+type NBXtBaseDrug struct {
3114
+	ID       int64  `gorm:"column:id" json:"id" form:"id"`
3115
+	DrugName string `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
3116
+	Status   int64  `gorm:"column:status" json:"status" form:"status"`
3117
+	OrgId    int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
3118
+	ScanCode string `gorm:"column:scan_code" json:"scan_code" form:"scan_code"`
3119
+}
3120
+
3121
+func (NBXtBaseDrug) TableName() string {
3122
+	return "xt_base_drug"
3123
+}

+ 57 - 5
models/patient_models.go 查看文件

@@ -3134,6 +3134,7 @@ type SfPatients struct {
3134 3134
 	HdfCount    int64  `gorm:"column:hdf_count" json:"hdf_count" form:"hdf_count"`
3135 3135
 	HdhpCount   int64  `gorm:"column:hdhp_count" json:"hdhp_count" form:"hdhp_count"`
3136 3136
 	HpCount     int64  `gorm:"column:hp_count" json:"hp_count" form:"hp_count"`
3137
+	OtherCount  int64  `gorm:"column:other_count" json:"other_count" form:"other_count"`
3137 3138
 }
3138 3139
 
3139 3140
 func (SfPatients) TableName() string {
@@ -3144,10 +3145,7 @@ type SfPatientInCount struct {
3144 3145
 	ID         int64  `gorm:"column:id" json:"id" form:"id"`
3145 3146
 	PatientId  int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
3146 3147
 	UserOrgId  int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
3147
-	HdCount    int64  `gorm:"column:hd_count" json:"hd_count" form:"hd_count"`
3148
-	HdfCount   int64  `gorm:"column:hdf_count" json:"hdf_count" form:"hdf_count"`
3149
-	HdhpCount  int64  `gorm:"column:hdhp_count" json:"hdhp_count" form:"hdhp_count"`
3150
-	HpCount    int64  `gorm:"column:hp_count" json:"hp_count" form:"hp_count"`
3148
+	IsType     int64  `gorm:"column:is_type" json:"is_type" form:"is_type"`
3151 3149
 	Status     int64  `gorm:"column:status" json:"status" form:"status"`
3152 3150
 	Creater    int64  `gorm:"column:creater" json:"creater" form:"creater"`
3153 3151
 	Ctime      int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
@@ -3155,9 +3153,63 @@ type SfPatientInCount struct {
3155 3153
 	IsCheck    int64  `gorm:"column:is_check" json:"is_check" form:"is_check"`
3156 3154
 	RecordDate int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
3157 3155
 	Remark     string `gorm:"column:remark" json:"remark" form:"remark"`
3158
-	OtherCount int64  `gorm:"column:other_count" json:"other_count" form:"other_count"`
3156
+	Count      int64  `gorm:"column:count" json:"count" form:"count"`
3157
+	StockCount int64  `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
3159 3158
 }
3160 3159
 
3161 3160
 func (SfPatientInCount) TableName() string {
3162 3161
 	return "xt_patient_in_count"
3163 3162
 }
3163
+
3164
+type SfPatientOutCount struct {
3165
+	ID         int64  `gorm:"column:id" json:"id" form:"id"`
3166
+	PatientId  int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
3167
+	ModeId     int64  `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
3168
+	Count      int64  `gorm:"column:count" json:"count" form:"count"`
3169
+	Remark     string `gorm:"column:remark" json:"remark" form:"remark"`
3170
+	Creater    int64  `gorm:"column:creater" json:"creater" form:"creater"`
3171
+	Status     int64  `gorm:"column:status" json:"status" form:"status"`
3172
+	Ctime      int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
3173
+	Mtime      int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
3174
+	IsCheck    int64  `gorm:"column:is_check" json:"is_check" form:"is_check"`
3175
+	RecordDate int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
3176
+	UserOrgId  int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
3177
+}
3178
+
3179
+func (SfPatientOutCount) TableName() string {
3180
+	return "xt_patient_out_count"
3181
+}
3182
+
3183
+type SfPatientCountFlow struct {
3184
+	ID              int64 `gorm:"column:id" json:"id" form:"id"`
3185
+	UserOrgId       int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
3186
+	Count           int64 `gorm:"column:count" json:"count" form:"count"`
3187
+	ModeId          int64 `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
3188
+	IsType          int64 `gorm:"column:is_type" json:"is_type" form:"is_type"`
3189
+	PatientId       int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
3190
+	Status          int64 `gorm:"column:status" json:"status" form:"status"`
3191
+	Ctime           int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
3192
+	Mtime           int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
3193
+	OverCount       int64 `gorm:"column:over_count" json:"over_count" form:"over_count"`
3194
+	RecordDate      int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
3195
+	Creater         int64 `gorm:"column:creater" json:"creater" form:"creater"`
3196
+	WarehouseInfoId int64 `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
3197
+	WarehouseOutId  int64 `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
3198
+}
3199
+
3200
+func (SfPatientCountFlow) TableName() string {
3201
+	return "xt_patient_count_flow"
3202
+}
3203
+
3204
+type XtDialysisOrderSetting struct {
3205
+	ID        int64 `gorm:"column:id" json:"id" form:"id"`
3206
+	IsOpen    int64 `gorm:"column:is_open" json:"is_open" form:"is_open"`
3207
+	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
3208
+	Ctime     int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
3209
+	Mtime     int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
3210
+	Status    int64 `gorm:"column:status" json:"status" form:"status"`
3211
+}
3212
+
3213
+func (XtDialysisOrderSetting) TableName() string {
3214
+	return "xt_dialysis_order_setting"
3215
+}

+ 8 - 14
service/common_service.go 查看文件

@@ -293,13 +293,7 @@ func GetTotalRollOutPatientsTwo(orgid int64, startime int64, endtime int64, laps
293 293
 
294 294
 func GetPatientTotalCount(orgID int64, lapsetotype int64, sourcetype int64) (total int64) {
295 295
 	db := readDb.Table("xt_patients as x")
296
-	//if lapsetotype > 0 {
297
-	// db = db.Where("x.lapseto = ?", lapsetotype)
298
-	//}
299
-	//if sourcetype > 0 {
300
-	// db = db.Where("x.source = ?", sourcetype)
301
-	//}
302
-	db.Where("x.user_org_id=? and x.status=1", orgID).Count(&total)
296
+	db.Where("x.user_org_id=? and x.status=1 and x.patient_type=1", orgID).Count(&total)
303 297
 	return
304 298
 }
305 299
 
@@ -321,7 +315,7 @@ func GetManPatientTotalCount(orgid int64, starttime int64, endtime int64) (dialy
321 315
 
322 316
 func GetManPatientTotal(orgid int64, lapsetotype int64, sourcetype int64) (patients []*models.XtPatients, total int64, err error) {
323 317
 
324
-	db := XTReadDB().Table("xt_patients as x").Where("x.status  = 1")
318
+	db := XTReadDB().Table("xt_patients as x").Where("x.status  = 1 and x.patient_type =1")
325 319
 	if lapsetotype > 0 {
326 320
 		db = db.Where("x.lapseto = ?", lapsetotype)
327 321
 	}
@@ -333,7 +327,7 @@ func GetManPatientTotal(orgid int64, lapsetotype int64, sourcetype int64) (patie
333 327
 }
334 328
 
335 329
 func GetWoManPatientTotal(orgid int64, lapsetotype int64, sourcetype int64) (patients []*models.XtPatients, total int64, err error) {
336
-	db := XTReadDB().Table("xt_patients as x").Where("x.status  = 1")
330
+	db := XTReadDB().Table("xt_patients as x").Where("x.status  = 1 and x.patient_type =1")
337 331
 	if lapsetotype > 0 {
338 332
 		db = db.Where("x.lapseto = ?", lapsetotype)
339 333
 	}
@@ -352,18 +346,18 @@ func GetWoManPatientTotal(orgid int64, lapsetotype int64, sourcetype int64) (pat
352 346
 func GetPatientInfectiousCount(orgid int64, startime int64, endtime int64, lapsetotype int64, sourcetype int64) (counts []*models.PatientContagionsCountStruct, err error) {
353 347
 
354 348
 	if lapsetotype == 0 {
355
-		err = readDb.Table("xt_patients_infectious_diseases as x").Joins("join xt_patients as s on s.id = x.patient_id").Where("s.user_org_id = ? and s.status = 1 and x.status = 1 and x.updated_time>=? and x.updated_time<=?", orgid, startime, endtime).Select("x.disease_id,count(x.disease_id) as count").Group("x.disease_id").Scan(&counts).Error
349
+		err = readDb.Table("xt_patients_infectious_diseases as x").Joins("join xt_patients as s on s.id = x.patient_id").Where("s.user_org_id = ? and s.status = 1 and s.patient_type =1 and x.status = 1 and x.updated_time>=? and x.updated_time<=?", orgid, startime, endtime).Select("x.disease_id,count(x.disease_id) as count").Group("x.disease_id").Scan(&counts).Error
356 350
 	}
357 351
 	if sourcetype == 0 {
358
-		err = readDb.Table("xt_patients_infectious_diseases as x").Joins("join xt_patients as s on s.id = x.patient_id").Where("s.user_org_id = ? and s.status = 1 and x.status = 1 and x.updated_time>=? and x.updated_time<=?", orgid, startime, endtime).Select("x.disease_id,count(x.disease_id) as count").Group("x.disease_id").Scan(&counts).Error
352
+		err = readDb.Table("xt_patients_infectious_diseases as x").Joins("join xt_patients as s on s.id = x.patient_id").Where("s.user_org_id = ? and s.status = 1 and s.patient_type =1 and x.status = 1 and x.updated_time>=? and x.updated_time<=?", orgid, startime, endtime).Select("x.disease_id,count(x.disease_id) as count").Group("x.disease_id").Scan(&counts).Error
359 353
 	}
360 354
 
361 355
 	if lapsetotype > 0 {
362
-		err = readDb.Table("xt_patients_infectious_diseases as x").Joins("join xt_patients as s on s.id = x.patient_id").Where("s.user_org_id = ? and s.status = 1 and x.status = 1 and x.updated_time>=? and x.updated_time<=? and s.lapseto = ?", orgid, startime, endtime, lapsetotype).Select("x.disease_id,count(x.disease_id) as count").Group("x.disease_id").Scan(&counts).Error
356
+		err = readDb.Table("xt_patients_infectious_diseases as x").Joins("join xt_patients as s on s.id = x.patient_id").Where("s.user_org_id = ? and s.status = 1 and s.patient_type =1 and x.status = 1 and x.updated_time>=? and x.updated_time<=? and s.lapseto = ?", orgid, startime, endtime, lapsetotype).Select("x.disease_id,count(x.disease_id) as count").Group("x.disease_id").Scan(&counts).Error
363 357
 	}
364 358
 
365 359
 	if sourcetype > 0 {
366
-		err = readDb.Table("xt_patients_infectious_diseases as x").Joins("join xt_patients as s on s.id = x.patient_id").Where("s.user_org_id = ? and s.status = 1 and x.status = 1 and x.updated_time>=? and x.updated_time<=? and s.source = ?", orgid, startime, endtime, sourcetype).Select("x.disease_id,count(x.disease_id) as count").Group("x.disease_id").Scan(&counts).Error
360
+		err = readDb.Table("xt_patients_infectious_diseases as x").Joins("join xt_patients as s on s.id = x.patient_id").Where("s.user_org_id = ? and s.status = 1 and s.patient_type =1 and x.status = 1 and x.updated_time>=? and x.updated_time<=? and s.source = ?", orgid, startime, endtime, sourcetype).Select("x.disease_id,count(x.disease_id) as count").Group("x.disease_id").Scan(&counts).Error
367 361
 	}
368 362
 
369 363
 	return counts, err
@@ -388,7 +382,7 @@ func GetTotalAgeCount(orgid int64, lapsetotype int64, sourcetype int64) (counts
388 382
     WHEN ( substring( now( ), 1, 4 ) - substring( id_card_no, 7, 4 ) ) - ( substring( id_card_no, 11, 4 ) - date_format( now( ), '%m%d' ) > 0 )<=80 THEN '80'
389 383
     ELSE '150'
390 384
 	 END
391
-	 AS nnd FROM xt_patients as s  where s.user_org_id=? and s.status=1
385
+	 AS nnd FROM xt_patients as s  where s.user_org_id=? and s.status=1 and s.patient_type =1
392 386
 	 )a GROUP BY nnd`, orgid).Scan(&counts)
393 387
 
394 388
 	}

+ 6 - 0
service/gobal_config_service.go 查看文件

@@ -202,6 +202,12 @@ func GetPrint(ids []int64, orgid int64, advicetype int64, stoptype int64) (docto
202 202
 	return doctor, err
203 203
 }
204 204
 
205
+func GetHisPrint(ids []string, org_id int64) (advice []*models.HisDoctorAdviceInfo, err error) {
206
+
207
+	err = XTReadDB().Where("id in (?) and user_org_id = ?", ids, org_id).Order("execution_time asc").Find(&advice).Error
208
+	return advice, err
209
+}
210
+
205 211
 func GetExportLogByType(org_id int64, log_type int64) (log []*models.ExportLog, err error) {
206 212
 	err = readDb.Model(&models.ExportLog{}).Where("user_org_id = ? AND status = 1 AND log_type = ?", org_id, log_type).
207 213
 		Preload("ExportErrLog", "status = 1").Order("export_time desc").Find(&log).Error

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

@@ -634,6 +634,7 @@ func MobileGetReceiverTreatmentAccessRecord(orgID int64, patientID int64, record
634 634
 
635 635
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":receive_treatment_asses"
636 636
 	receive_treatment_asses_str, _ := redis.Get(key).Result()
637
+
637 638
 	if len(receive_treatment_asses_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
638 639
 		err = readDb.Model(&models.ReceiveTreatmentAsses{}).Where("patient_id = ? and user_org_id = ? and status = 1 and record_date = ?", patientID, orgID, recordDate).First(&record).Error
639 640
 		if err != nil {

+ 14 - 15
service/new_warehouse_service.go 查看文件

@@ -4508,9 +4508,9 @@ func HisStoryBloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, war
4508 4508
 
4509 4509
 	if lastWarehouse.MaxUnit != lastWarehouse.MinUnit && drup.MaxUnit != drup.MinUnit && lastWarehouse.MinUnit != "" {
4510 4510
 		if lastWarehouse.StockMinNumber >= drup.MinNumber {
4511
-			fmt.Println("hahhahahahahhaah")
4512 4511
 			var stockMax int64
4513 4512
 			var stockMin int64
4513
+
4514 4514
 			stockMax = lastWarehouse.StockMinNumber / drup.MinNumber
4515 4515
 			stockMin = lastWarehouse.StockMinNumber % drup.MinNumber
4516 4516
 
@@ -4522,7 +4522,6 @@ func HisStoryBloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, war
4522 4522
 	}
4523 4523
 
4524 4524
 	if lastWarehouse.MaxUnit == lastWarehouse.MinUnit && drup.MaxUnit != drup.MinUnit && lastWarehouse.MinUnit != "" {
4525
-		fmt.Println("ooowowowowowowowowowo")
4526 4525
 		lastWarehouse.StockMaxNumber = lastWarehouse.StockMaxNumber + lastWarehouse.StockMinNumber
4527 4526
 		ChangeNewMaxNumberOne(lastWarehouse.ID, lastWarehouse.StockMaxNumber, tx)
4528 4527
 
@@ -4547,8 +4546,8 @@ func HisStoryBloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, war
4547 4546
 
4548 4547
 	}
4549 4548
 
4550
-	fmt.Println("stock_number", stock_number)
4551
-	fmt.Println("deliver_number=============", deliver_number)
4549
+	//fmt.Println("stock_number", stock_number)
4550
+	//fmt.Println("deliver_number=============", deliver_number)
4552 4551
 	// 当库存数量大于或等于出库数量的话,则正常出库该批次
4553 4552
 	if stock_number >= deliver_number {
4554 4553
 
@@ -4558,8 +4557,8 @@ func HisStoryBloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, war
4558 4557
 		maxNumber = deliver_number / drup.MinNumber
4559 4558
 		minNumber = deliver_number % drup.MinNumber
4560 4559
 
4561
-		fmt.Println("max_Number=====================", maxNumber)
4562
-		fmt.Println("minNumber=====================", minNumber)
4560
+		//fmt.Println("max_Number=====================", maxNumber)
4561
+		//fmt.Println("minNumber=====================", minNumber)
4563 4562
 
4564 4563
 		if warehouse.StockMaxNumber == 0 && drup.MaxUnit == drup.MinUnit {
4565 4564
 			minNumber = maxNumber
@@ -4573,18 +4572,18 @@ func HisStoryBloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, war
4573 4572
 
4574 4573
 		if drup.MinUnit == warehouse.MaxUnit && drup.MaxUnit != drup.MinUnit {
4575 4574
 
4576
-			fmt.Println("金1")
4575
+			//fmt.Println("金1")
4577 4576
 
4578 4577
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber*drup.MinNumber
4579 4578
 		}
4580 4579
 
4581 4580
 		if drup.MaxUnit == warehouse.MaxUnit && drup.MaxUnit != drup.MinUnit {
4582
-			fmt.Println("jin2")
4581
+			//fmt.Println("jin2")
4583 4582
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
4584 4583
 		}
4585 4584
 
4586 4585
 		if drup.MaxUnit == warehouse.MaxUnit && drup.MaxUnit == drup.MinUnit {
4587
-			fmt.Println("jin3")
4586
+			//fmt.Println("jin3")
4588 4587
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
4589 4588
 		}
4590 4589
 
@@ -4597,8 +4596,8 @@ func HisStoryBloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, war
4597 4596
 
4598 4597
 		warehouse.Mtime = time.Now().Unix()
4599 4598
 
4600
-		fmt.Println("hahhahahah", warehouse.StockMinNumber)
4601
-		fmt.Println("howowowoowow", minNumber)
4599
+		//fmt.Println("hahhahahah", warehouse.StockMinNumber)
4600
+		//fmt.Println("howowowoowow", minNumber)
4602 4601
 		if warehouse.StockMinNumber < minNumber {
4603 4602
 
4604 4603
 			if warehouse.MaxUnit != warehouse.MinUnit {
@@ -4609,10 +4608,10 @@ func HisStoryBloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, war
4609 4608
 			if warehouse.MaxUnit != warehouse.MinUnit {
4610 4609
 				warehouse.StockMinNumber = warehouse.StockMinNumber + drup.MinNumber - minNumber
4611 4610
 			}
4612
-			fmt.Println("minNumber------", minNumber)
4613
-			fmt.Println("warehouse.StockMinNumber", warehouse.StockMinNumber)
4614
-			fmt.Println(" warehouse.MaxUnit", warehouse.MaxUnit)
4615
-			fmt.Println(" warehouse.MinUnit", warehouse.MinUnit)
4611
+			//fmt.Println("minNumber------", minNumber)
4612
+			//fmt.Println("warehouse.StockMinNumber", warehouse.StockMinNumber)
4613
+			//fmt.Println(" warehouse.MaxUnit", warehouse.MaxUnit)
4614
+			//fmt.Println(" warehouse.MinUnit", warehouse.MinUnit)
4616 4615
 
4617 4616
 			if warehouse.MaxUnit == warehouse.MinUnit {
4618 4617
 				//改动的地方

+ 456 - 10
service/patient_service.go 查看文件

@@ -589,7 +589,7 @@ func GetPatientListById(orgID int64, patientId int64) (patients models.PatientLi
589 589
 }
590 590
 
591 591
 func GetPatientCount(orgID int64) (total int64) {
592
-	readDb.Model(&models.Patients{}).Where("user_org_id=? and status=1 and lapseto = 1", orgID).Count(&total)
592
+	readDb.Model(&models.Patients{}).Where("user_org_id=? and status=1 and lapseto = 1 and patient_type = 1", orgID).Count(&total)
593 593
 	return
594 594
 }
595 595
 func GetLapsetoPatientCount(orgID int64, lapseto int64) (total int64) {
@@ -5074,6 +5074,20 @@ func GetPatientMapList(user_org_id int64, keyword string) (patient []*models.SfP
5074 5074
 	return patient, err
5075 5075
 }
5076 5076
 
5077
+func GetPatientMapListOne(user_org_id int64) (patient []*models.SfPatients, err error) {
5078
+
5079
+	err = XTReadDB().Where("user_org_id = ? and status=1 and lapseto =1", user_org_id).Find(&patient).Error
5080
+
5081
+	return patient, err
5082
+}
5083
+
5084
+func GetAllAdminUserList(org_id int64, app_id int64) (admin []*models.SgjUserAdminRole, err error) {
5085
+
5086
+	err = UserReadDB().Where("org_id = ? and app_id = ? and status=1", org_id, app_id).Find(&admin).Error
5087
+
5088
+	return admin, err
5089
+}
5090
+
5077 5091
 func CreatePatientInCount(tx *gorm.DB, patientCount models.SfPatientInCount) error {
5078 5092
 
5079 5093
 	err := tx.Create(&patientCount).Error
@@ -5085,7 +5099,7 @@ func CreatePatientInCount(tx *gorm.DB, patientCount models.SfPatientInCount) err
5085 5099
 	return err
5086 5100
 }
5087 5101
 
5088
-func ModifyPatientCount(tx *gorm.DB, hd_count int64, hdf_count int64, hdhp_count int64, hp_count int64, patient_id int64) (models.SfPatients, error) {
5102
+func ModifyPatientCount(tx *gorm.DB, hd_count int64, hdf_count int64, hdhp_count int64, hp_count int64, other_count int64, patient_id int64) (models.SfPatients, error) {
5089 5103
 
5090 5104
 	patients := models.SfPatients{}
5091 5105
 
@@ -5097,6 +5111,8 @@ func ModifyPatientCount(tx *gorm.DB, hd_count int64, hdf_count int64, hdhp_count
5097 5111
 
5098 5112
 	err = tx.Model(&patients).Where("id=?", patient_id).UpdateColumn("hp_count", gorm.Expr("hp_count + ?", hp_count)).Error
5099 5113
 
5114
+	err = tx.Model(&patients).Where("id=?", patient_id).UpdateColumn("other_count", gorm.Expr("other_count + ?", other_count)).Error
5115
+
5100 5116
 	return patients, err
5101 5117
 }
5102 5118
 
@@ -5115,7 +5131,89 @@ func UpdatePatientInCount(tx *gorm.DB, hd_count int64, hdf_count int64, hdhp_cou
5115 5131
 	return patients, err
5116 5132
 }
5117 5133
 
5118
-func GetPatientCountList(user_org_id int64, patient_id int64, page int64, limit int64) (patient []*models.SfPatientInCount, total int64, err error) {
5134
+func ModiftyPatientCount(count int64, is_type int64, patient_id int64, tx *gorm.DB) (models.SfPatients, error) {
5135
+
5136
+	patients := models.SfPatients{}
5137
+	if is_type == 1 {
5138
+		err = tx.Model(&models.SfPatients{}).Where("id=?", patient_id).UpdateColumn("hd_count", gorm.Expr("hd_count + ?", count)).Error
5139
+		if err != nil {
5140
+			tx.Rollback()
5141
+			return patients, err
5142
+		}
5143
+	}
5144
+	if is_type == 2 {
5145
+		err = tx.Model(&models.SfPatients{}).Where("id=?", patient_id).UpdateColumn("hdf_count", gorm.Expr("hdf_count + ?", count)).Error
5146
+		if err != nil {
5147
+			tx.Rollback()
5148
+			return patients, err
5149
+		}
5150
+	}
5151
+	if is_type == 3 {
5152
+		err = tx.Model(&models.SfPatients{}).Where("id=?", patient_id).UpdateColumn("hdhp_count", gorm.Expr("hdhp_count + ?", count)).Error
5153
+		if err != nil {
5154
+			tx.Rollback()
5155
+			return patients, err
5156
+		}
5157
+	}
5158
+	if is_type == 4 {
5159
+		err = tx.Model(&models.SfPatients{}).Where("id=?", patient_id).UpdateColumn("hp_count", gorm.Expr("hp_count + ?", count)).Error
5160
+		if err != nil {
5161
+			tx.Rollback()
5162
+			return patients, err
5163
+		}
5164
+	}
5165
+	if is_type == 5 {
5166
+		err = tx.Model(&models.SfPatients{}).Where("id=?", patient_id).UpdateColumn("other_count", gorm.Expr("other_count + ?", count)).Error
5167
+		if err != nil {
5168
+			tx.Rollback()
5169
+			return patients, err
5170
+		}
5171
+	}
5172
+	return patients, err
5173
+}
5174
+
5175
+func ReducePatientCount(count int64, is_type int64, patient_id int64, tx *gorm.DB) (models.SfPatients, error) {
5176
+
5177
+	patients := models.SfPatients{}
5178
+	if is_type == 1 {
5179
+		err = tx.Model(&models.SfPatients{}).Where("id=?", patient_id).UpdateColumn("hd_count", gorm.Expr("hd_count - ?", count)).Error
5180
+		if err != nil {
5181
+			tx.Rollback()
5182
+			return patients, err
5183
+		}
5184
+	}
5185
+	if is_type == 2 {
5186
+		err = tx.Model(&models.SfPatients{}).Where("id=?", patient_id).UpdateColumn("hdf_count", gorm.Expr("hdf_count - ?", count)).Error
5187
+		if err != nil {
5188
+			tx.Rollback()
5189
+			return patients, err
5190
+		}
5191
+	}
5192
+	if is_type == 3 {
5193
+		err = tx.Model(&models.SfPatients{}).Where("id=?", patient_id).UpdateColumn("hdhp_count", gorm.Expr("hdhp_count - ?", count)).Error
5194
+		if err != nil {
5195
+			tx.Rollback()
5196
+			return patients, err
5197
+		}
5198
+	}
5199
+	if is_type == 4 {
5200
+		err = tx.Model(&models.SfPatients{}).Where("id=?", patient_id).UpdateColumn("hp_count", gorm.Expr("hp_count - ?", count)).Error
5201
+		if err != nil {
5202
+			tx.Rollback()
5203
+			return patients, err
5204
+		}
5205
+	}
5206
+	if is_type == 5 {
5207
+		err = tx.Model(&models.SfPatients{}).Where("id=?", patient_id).UpdateColumn("other_count", gorm.Expr("other_count - ?", count)).Error
5208
+		if err != nil {
5209
+			tx.Rollback()
5210
+			return patients, err
5211
+		}
5212
+	}
5213
+	return patients, err
5214
+}
5215
+
5216
+func GetPatientCountList(user_org_id int64, patient_id int64, page int64, limit int64, start_time int64, end_time int64) (patient []*models.SfPatientInCount, total int64, err error) {
5119 5217
 
5120 5218
 	db := XTReadDB().Model(&patient).Where("status=1")
5121 5219
 
@@ -5129,34 +5227,382 @@ func GetPatientCountList(user_org_id int64, patient_id int64, page int64, limit
5129 5227
 		db = db.Where("user_org_id = ?", user_org_id)
5130 5228
 	}
5131 5229
 
5230
+	if start_time > 0 {
5231
+		db = db.Where("record_date >=?", start_time)
5232
+	}
5233
+	if end_time > 0 {
5234
+		db = db.Where("record_date<=?", end_time)
5235
+	}
5236
+
5132 5237
 	err = db.Count(&total).Offset(offset).Limit(limit).Order("record_date desc").Find(&patient).Error
5133 5238
 
5134 5239
 	return patient, total, err
5135 5240
 }
5136 5241
 
5137
-func CheckPatientCount(id int64) (models.SfPatientInCount, error) {
5242
+func CheckPatientCount(id int64, tx *gorm.DB) (models.SfPatientInCount, error) {
5138 5243
 
5139 5244
 	patientInCount := models.SfPatientInCount{}
5140 5245
 
5141
-	err = XTWriteDB().Model(&patientInCount).Where("id = ?", id).Updates(map[string]interface{}{"is_check": 1}).Error
5142
-
5246
+	err = tx.Model(&patientInCount).Where("id = ?", id).Updates(map[string]interface{}{"is_check": 1}).Error
5247
+	if err != nil {
5248
+		tx.Rollback()
5249
+		return patientInCount, err
5250
+	}
5143 5251
 	return patientInCount, err
5144 5252
 }
5145 5253
 
5146
-func ReturnCheckPatientCount(id int64) (models.SfPatientInCount, error) {
5254
+func ReturnCheckPatientCount(id int64, tx *gorm.DB) (models.SfPatientInCount, error) {
5147 5255
 
5148 5256
 	patientInCount := models.SfPatientInCount{}
5149 5257
 
5150
-	err = XTWriteDB().Model(&patientInCount).Where("id = ?", id).Updates(map[string]interface{}{"is_check": 2}).Error
5258
+	err = tx.Model(&patientInCount).Where("id = ?", id).Updates(map[string]interface{}{"is_check": 2}).Error
5259
+
5260
+	if err != nil {
5261
+		tx.Rollback()
5262
+		return patientInCount, err
5263
+	}
5151 5264
 
5152 5265
 	return patientInCount, err
5153 5266
 }
5154 5267
 
5155
-func GetPatientCountById(id int64) (models.SfPatientInCount, error) {
5268
+func UpdatePatientCountFlow(id int64, tx *gorm.DB) error {
5269
+
5270
+	err := tx.Model(&models.SfPatientCountFlow{}).Where("warehouse_info_id = ?", id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
5271
+
5272
+	if err != nil {
5273
+		tx.Rollback()
5274
+		return err
5275
+	}
5276
+	return err
5277
+}
5278
+
5279
+func GetPatientCountById(id int64, tx *gorm.DB) (models.SfPatientInCount, error) {
5156 5280
 
5157 5281
 	patientInCount := models.SfPatientInCount{}
5158 5282
 
5159
-	err := XTReadDB().Where("id = ?", id).Find(&patientInCount).Error
5283
+	err := tx.Where("id = ?", id).Find(&patientInCount).Error
5284
+	if err != nil {
5285
+		tx.Rollback()
5286
+		return patientInCount, err
5287
+	}
5160 5288
 
5161 5289
 	return patientInCount, err
5162 5290
 }
5291
+
5292
+func DeletePatientCount(id int64) (models.SfPatientInCount, error) {
5293
+
5294
+	patientCount := models.SfPatientInCount{}
5295
+
5296
+	err := XTWriteDB().Model(&patientCount).Where("id = ?", id).Updates(map[string]interface{}{"status": 0}).Error
5297
+
5298
+	return patientCount, err
5299
+}
5300
+
5301
+func CreateSfPatientOutCount(outCount models.SfPatientOutCount) error {
5302
+
5303
+	err := XTWriteDB().Create(&outCount).Error
5304
+
5305
+	return err
5306
+}
5307
+
5308
+func GetPatientOutCountList(patient_id int64, user_org_id int64, limit int64, page int64, start_time int64, end_time int64) (outcount []*models.SfPatientOutCount, total int64, err error) {
5309
+
5310
+	db := XTReadDB().Model(&outcount).Where("status=1")
5311
+
5312
+	offset := (page - 1) * limit
5313
+
5314
+	if patient_id > 0 {
5315
+		db = db.Where("patient_id = ?", patient_id)
5316
+	}
5317
+
5318
+	if user_org_id > 0 {
5319
+		db = db.Where("user_org_id = ?", user_org_id)
5320
+	}
5321
+
5322
+	if start_time > 0 {
5323
+		db = db.Where("start_time>=?", start_time)
5324
+	}
5325
+
5326
+	if end_time > 0 {
5327
+		db = db.Where("end_time<=?", end_time)
5328
+	}
5329
+
5330
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("record_date desc").Find(&outcount).Error
5331
+
5332
+	return outcount, total, err
5333
+
5334
+}
5335
+
5336
+func GetPatientScheduleByPatient(patient_id int64, record_date int64, user_org_id int64) (models.XtSchedule, error) {
5337
+
5338
+	schedule := models.XtSchedule{}
5339
+	err = XTReadDB().Where("patient_id = ? and schedule_date = ? and user_org_id = ? and status=1", patient_id, record_date, user_org_id).Last(&schedule).Error
5340
+
5341
+	return schedule, err
5342
+}
5343
+
5344
+func GetDialysisSolutonByScheduleModeId(mode_id int64, patient_id int64, user_org_id int64) (models.DialysisSolution, error) {
5345
+
5346
+	solution := models.DialysisSolution{}
5347
+
5348
+	err = XTReadDB().Where("mode_id = ? and patient_id = ? and user_org_id = ? and solution_status =1", mode_id, patient_id, user_org_id).Find(&solution).Error
5349
+
5350
+	return solution, err
5351
+}
5352
+
5353
+func DeletePatientOutCount(id int64) error {
5354
+
5355
+	outCount := models.SfPatientOutCount{}
5356
+
5357
+	err := XTWriteDB().Model(&outCount).Where("id = ? and status=1", id).Updates(map[string]interface{}{"status": 0}).Error
5358
+
5359
+	return err
5360
+}
5361
+
5362
+func GetPatientOutCountById(id int64, tx *gorm.DB) (models.SfPatientOutCount, error) {
5363
+
5364
+	outCount := models.SfPatientOutCount{}
5365
+	err = tx.Where("id=? and status=1", id).Find(&outCount).Error
5366
+
5367
+	if err != gorm.ErrRecordNotFound {
5368
+		if err != nil {
5369
+			tx.Rollback()
5370
+			return outCount, err
5371
+		}
5372
+	}
5373
+	return outCount, err
5374
+}
5375
+
5376
+func CreatePatientCountFlow(flow models.SfPatientCountFlow, tx *gorm.DB) error {
5377
+
5378
+	err := tx.Create(&flow).Error
5379
+
5380
+	if err != nil {
5381
+		tx.Rollback()
5382
+		return err
5383
+	}
5384
+
5385
+	return err
5386
+}
5387
+
5388
+func GetSfPatientById(tx *gorm.DB, patient_id int64) (models.SfPatients, error) {
5389
+
5390
+	patients := models.SfPatients{}
5391
+	err := tx.Where("id =? and status=1", patient_id).Find(&patients).Error
5392
+
5393
+	if err != gorm.ErrRecordNotFound {
5394
+		if err != nil {
5395
+			tx.Rollback()
5396
+			return patients, err
5397
+		}
5398
+	}
5399
+	return patients, err
5400
+}
5401
+
5402
+func GetSfPatientByIdOne(patient_id int64) (models.SfPatients, error) {
5403
+
5404
+	patients := models.SfPatients{}
5405
+	err := XTReadDB().Where("id =? and status=1", patient_id).Find(&patients).Error
5406
+
5407
+	return patients, err
5408
+}
5409
+
5410
+func CheckPatientOutCount(id int64, tx *gorm.DB) error {
5411
+
5412
+	patients := models.SfPatientOutCount{}
5413
+
5414
+	err := tx.Model(&patients).Where("id=? and status=1", id).Updates(map[string]interface{}{"is_check": 1, "mtime": time.Now().Unix()}).Error
5415
+
5416
+	return err
5417
+}
5418
+
5419
+func ReturnPatientOutCount(id int64, tx *gorm.DB) error {
5420
+
5421
+	err = tx.Model(&models.SfPatientOutCount{}).Where("id=?", id).Updates(map[string]interface{}{"is_check": 2}).Error
5422
+
5423
+	if err != nil {
5424
+		tx.Rollback()
5425
+		return err
5426
+	}
5427
+
5428
+	return err
5429
+}
5430
+
5431
+func DeletePatientCountFlow(id int64, tx *gorm.DB) error {
5432
+
5433
+	err := tx.Model(&models.SfPatientCountFlow{}).Where("warehouse_out_id = ?", id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
5434
+
5435
+	if err != nil {
5436
+		tx.Rollback()
5437
+		return err
5438
+	}
5439
+	return err
5440
+
5441
+}
5442
+
5443
+func GetPatientCountMapList(patient_id int64, limit int64, page int64, user_org_id int64) (patient []*models.SfPatients, total int64, err error) {
5444
+
5445
+	db := XTReadDB().Model(&patient).Where("status=1")
5446
+
5447
+	offset := (page - 1) * limit
5448
+
5449
+	if (patient_id) > 0 {
5450
+		db = db.Where("id = ?", patient_id)
5451
+	}
5452
+	if (user_org_id) > 0 {
5453
+		db = db.Where("user_org_id = ?", user_org_id)
5454
+	}
5455
+
5456
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("id desc").Find(&patient).Error
5457
+
5458
+	return patient, total, err
5459
+}
5460
+
5461
+func GetPatientCountFlow(patient_id int64, user_org_id int64, is_type int64, mode_id int64, start_time int64, end_time int64) (flow []*models.SfPatientCountFlow, total int64, err error) {
5462
+
5463
+	db := XTReadDB().Model(&flow).Where("status=1")
5464
+
5465
+	if patient_id > 0 {
5466
+		db = db.Where("patient_id=?", patient_id)
5467
+	}
5468
+	if user_org_id > 0 {
5469
+		db = db.Where("user_org_id = ?", user_org_id)
5470
+	}
5471
+	if is_type > 0 {
5472
+		db = db.Where("is_type = ?", is_type)
5473
+	}
5474
+	if mode_id > 0 {
5475
+		db = db.Where("mode_id = ?", mode_id)
5476
+	}
5477
+
5478
+	if start_time > 0 {
5479
+		db = db.Where("ctime>=?", start_time)
5480
+	}
5481
+	if end_time > 0 {
5482
+		db = db.Where("ctime<=?", end_time)
5483
+	}
5484
+	err = db.Find(&flow).Error
5485
+
5486
+	return flow, total, err
5487
+}
5488
+
5489
+func GetDialysisOrderSetting(user_org_id int64) (models.XtDialysisOrderSetting, error) {
5490
+
5491
+	orderSetting := models.XtDialysisOrderSetting{}
5492
+	err = XTReadDB().Model(&orderSetting).Where("user_org_id = ? and status=1", user_org_id).Find(&orderSetting).Error
5493
+
5494
+	return orderSetting, err
5495
+}
5496
+
5497
+func GetDialysisOrderSchedule(patient_id int64, schedule_date int64, user_org_id int64, tx *gorm.DB) (models.XtSchedule, error) {
5498
+
5499
+	schedule := models.XtSchedule{}
5500
+
5501
+	err = tx.Where("patient_id=? and schedule_date = ? and user_org_id=? and status=1", patient_id, schedule_date, user_org_id).Find(&schedule).Error
5502
+
5503
+	if err != nil {
5504
+		tx.Rollback()
5505
+		return schedule, err
5506
+	}
5507
+
5508
+	return schedule, err
5509
+}
5510
+
5511
+func CreateDialysisOrder(setting models.XtDialysisOrderSetting) error {
5512
+
5513
+	err := XTWriteDB().Create(&setting).Error
5514
+
5515
+	return err
5516
+}
5517
+
5518
+func GetPatientCountFlowList(patient_id int64, start_time int64, end_time int64, limit int64, page int64, orgId int64, is_type int64) (flow []*models.SfPatientCountFlow, total int64, err error) {
5519
+
5520
+	db := XTReadDB().Model(&flow).Where("status=1")
5521
+
5522
+	offset := (page - 1) * limit
5523
+
5524
+	if patient_id > 0 {
5525
+		db = db.Where("patient_id = ?", patient_id)
5526
+	}
5527
+	if start_time > 0 {
5528
+		db = db.Where("ctime>=?", start_time)
5529
+	}
5530
+
5531
+	if end_time > 0 {
5532
+		db = db.Where("ctime<=?", end_time)
5533
+	}
5534
+
5535
+	if orgId > 0 {
5536
+		db = db.Where("user_org_id = ?", orgId)
5537
+	}
5538
+
5539
+	if is_type > 0 {
5540
+		db = db.Where("is_type = ?", is_type)
5541
+	}
5542
+
5543
+	err = db.Group("patient_id,mode_id,is_type").Count(&total).Offset(offset).Limit(limit).Order("id desc").Find(&flow).Error
5544
+
5545
+	return flow, total, err
5546
+}
5547
+
5548
+func GetPatientCountListFlowOne(patient_id int64, start_time int64, end_time int64, is_type int64, orgId int64) (flow []*models.SfPatientCountFlow, err error) {
5549
+
5550
+	db := XTReadDB().Model(&flow).Where("status=1")
5551
+
5552
+	if patient_id > 0 {
5553
+		db = db.Where("patient_id = ?", patient_id)
5554
+	}
5555
+	if start_time > 0 {
5556
+		db = db.Where("ctime>=?", start_time)
5557
+	}
5558
+
5559
+	if end_time > 0 {
5560
+		db = db.Where("ctime<=?", end_time)
5561
+	}
5562
+
5563
+	if orgId > 0 {
5564
+		db = db.Where("user_org_id = ?", orgId)
5565
+	}
5566
+
5567
+	if is_type > 0 {
5568
+		db = db.Where("is_type = ?", is_type)
5569
+	}
5570
+
5571
+	err = db.Order("id desc").Find(&flow).Error
5572
+
5573
+	return flow, err
5574
+
5575
+}
5576
+
5577
+func GetPatientCountFlowByIdList(patient_id int64, orgId int64, mode_id int64, is_type int64, startTime int64, endTime int64) (flow []*models.SfPatientCountFlow, err error) {
5578
+
5579
+	db := XTReadDB().Model(&flow).Where("status=1")
5580
+
5581
+	if patient_id > 0 {
5582
+		db = db.Where("patient_id=?", patient_id)
5583
+	}
5584
+	if orgId > 0 {
5585
+		db = db.Where("user_org_id =?", orgId)
5586
+	}
5587
+
5588
+	if mode_id > 0 {
5589
+		db = db.Where("mode_id = ?", mode_id)
5590
+	}
5591
+
5592
+	if is_type > 0 {
5593
+		db = db.Where("is_type =?", is_type)
5594
+	}
5595
+
5596
+	if startTime > 0 {
5597
+		db = db.Where("ctime>=?", startTime)
5598
+	}
5599
+	if endTime > 0 {
5600
+		db = db.Where("ctime<=?", endTime)
5601
+	}
5602
+	if mode_id > 0 {
5603
+		db = db.Where("mode_id = ?", mode_id)
5604
+	}
5605
+	err = db.Find(&flow).Error
5606
+
5607
+	return flow, err
5608
+}

+ 5 - 5
service/patientmanage_service.go 查看文件

@@ -1971,22 +1971,22 @@ type InspectionCount struct {
1971 1971
 
1972 1972
 func GetNormalInspectionTotalByID(startime int64, endtime int64, orgid int64, item_name string, max_value float64, min_value float64) (total int64, err error) {
1973 1973
 	var count []*models.Inspection
1974
-	err2 := XTReadDB().Table("xt_inspection as xti ").Select("count(*) as count").Joins("join (SELECT max(inspect_date) as ind, patient_id as pid  FROM xt_inspection as x Join xt_patients pp on pp.id = x.patient_id and pp.lapseto = 1  WHERE (x.status = 1) AND (x.org_id = ?  and x.item_name = ?  and x.inspect_date >= ? and x.inspect_date <= ?) group by patient_id) as ta on ta.ind = xti.`inspect_date` and xti.patient_id = ta.pid  WHERE (xti.status = 1) AND (xti.org_id = ?  and xti.item_name = ?  and xti.inspect_date >= ? and xti.inspect_date<= ? and xti.`inspect_value` <= ? and xti.inspect_value >= ? ) Group by xti.patient_id", orgid, item_name, startime, endtime, orgid, item_name, startime, endtime, max_value, min_value).Scan(&count).Error
1974
+	err2 := XTReadDB().Table("xt_inspection as xti ").Select("count(*) as count").Joins("join (SELECT max(inspect_date) as ind, patient_id as pid  FROM xt_inspection as x Join xt_patients pp on pp.id = x.patient_id and pp.lapseto = 1 and pp.patient_type =1  WHERE (x.status = 1) AND (x.org_id = ?  and x.item_name = ?  and x.inspect_date >= ? and x.inspect_date <= ?) group by patient_id) as ta on ta.ind = xti.`inspect_date` and xti.patient_id = ta.pid  WHERE (xti.status = 1) AND (xti.org_id = ?  and xti.item_name = ?  and xti.inspect_date >= ? and xti.inspect_date<= ? and xti.`inspect_value` <= ? and xti.inspect_value >= ? ) Group by xti.patient_id", orgid, item_name, startime, endtime, orgid, item_name, startime, endtime, max_value, min_value).Scan(&count).Error
1975 1975
 
1976 1976
 	return int64(len(count)), err2
1977 1977
 }
1978 1978
 func GetUnusualInspectionTotalByID(startime int64, endtime int64, orgid int64, item_name string, max_value float64, min_value float64) (total int64, err error) {
1979 1979
 	var count []*models.Inspection
1980
-	err2 := XTReadDB().Table("xt_inspection as xti ").Select("count(*) as count").Joins("join (SELECT max(inspect_date) as ind, patient_id as pid  FROM xt_inspection as x JOIN xt_patients pp on pp.id = x.patient_id and pp.status = 1 and pp.lapseto = 1  WHERE (x.status = 1) AND (x.org_id = ? and x.item_name = ?  and x.inspect_date >= ? and x.inspect_date <= ?) group by patient_id) as ta on ta.ind = xti.`inspect_date` and xti.patient_id = ta.pid  WHERE   (xti.status = 1 AND xti.org_id = ? and xti.item_name = ?  and xti.inspect_date >= ? and xti.inspect_date <= ? and xti.inspect_value > ?) OR (xti.status = 1 AND xti.org_id = ?  and xti.item_name = ?  and xti.inspect_date >= ? and xti.inspect_date <= ? and xti.inspect_value < ?) Group by xti.patient_id", orgid, item_name, startime, endtime, orgid, item_name, startime, endtime, max_value, orgid, item_name, startime, endtime, min_value).Scan(&count).Error
1980
+	err2 := XTReadDB().Table("xt_inspection as xti ").Select("count(*) as count").Joins("join (SELECT max(inspect_date) as ind, patient_id as pid  FROM xt_inspection as x JOIN xt_patients pp on pp.id = x.patient_id and pp.status = 1 and pp.lapseto = 1 and pp.patient_type =1   WHERE (x.status = 1) AND (x.org_id = ? and x.item_name = ?  and x.inspect_date >= ? and x.inspect_date <= ?) group by patient_id) as ta on ta.ind = xti.`inspect_date` and xti.patient_id = ta.pid  WHERE   (xti.status = 1 AND xti.org_id = ? and xti.item_name = ?  and xti.inspect_date >= ? and xti.inspect_date <= ? and xti.inspect_value > ?) OR (xti.status = 1 AND xti.org_id = ?  and xti.item_name = ?  and xti.inspect_date >= ? and xti.inspect_date <= ? and xti.inspect_value < ?) Group by xti.patient_id", orgid, item_name, startime, endtime, orgid, item_name, startime, endtime, max_value, orgid, item_name, startime, endtime, min_value).Scan(&count).Error
1981 1981
 	return int64(len(count)), err2
1982 1982
 }
1983 1983
 func GetPatientNotInspectionTotal(startime int64, endtime int64, orgid int64, item_name string) (total int64, err error) {
1984
-	err = XTReadDB().Model(models.XtPatients{}).Joins("LEFT JOIN xt_inspection pd ON xt_patients.id = pd.patient_id and pd.org_id = ? and pd.item_name = ? and pd.inspect_date >= ? and pd.inspect_date<=? ", orgid, item_name, startime, endtime).Where("xt_patients.user_org_id = ? and xt_patients.status = 1 and pd.patient_id IS NULL and xt_patients.lapseto = 1", orgid).Count(&total).Error
1984
+	err = XTReadDB().Model(models.XtPatients{}).Joins("LEFT JOIN xt_inspection pd ON xt_patients.id = pd.patient_id and pd.org_id = ? and pd.item_name = ? and pd.inspect_date >= ? and pd.inspect_date<=? ", orgid, item_name, startime, endtime).Where("xt_patients.user_org_id = ? and xt_patients.status = 1 and pd.patient_id IS NULL and xt_patients.lapseto = 1 and xt_patients.patient_type = 1", orgid).Count(&total).Error
1985 1985
 	return total, err
1986 1986
 }
1987 1987
 
1988 1988
 func GetPatientInspectionByID(startime int64, endtime int64, orgid int64, patient_id int64, item_name string) (inspections []*models.Inspection, err error) {
1989
-	db := XTReadDB().Table("xt_inspection as x").Select("patient_id,inspect_date,inspect_value").Joins("join xt_patients p On p.id = x.patient_id and p.status = 1 and p.lapseto = 1").Where("x.status = 1")
1989
+	db := XTReadDB().Table("xt_inspection as x").Select("patient_id,inspect_date,inspect_value").Joins("join xt_patients p On p.id = x.patient_id and p.status = 1 and p.lapseto = 1 and p.patient_type =1").Where("x.status = 1")
1990 1990
 	if startime > 0 {
1991 1991
 		db = db.Where("x.inspect_date >= ?", startime)
1992 1992
 	}
@@ -2009,7 +2009,7 @@ func GetPatientInspectionByID(startime int64, endtime int64, orgid int64, patien
2009 2009
 }
2010 2010
 
2011 2011
 func GetPatientKTVORURRInspectionByID(startime int64, endtime int64, orgid int64, projectid int64, item_id int64, patient_id int64) (inspections []*models.Inspection, err error) {
2012
-	db := XTReadDB().Table("xt_inspection as x").Select("patient_id,inspect_date,inspect_value").Joins("join xt_patients p On p.id = x.patient_id and p.status = 1 and p.lapseto = 1").Where("x.status = 1")
2012
+	db := XTReadDB().Table("xt_inspection as x").Select("patient_id,inspect_date,inspect_value").Joins("join xt_patients p On p.id = x.patient_id and p.status = 1 and p.lapseto = 1 and p.patient_type =1").Where("x.status = 1")
2013 2013
 	if startime > 0 {
2014 2014
 		db = db.Where("x.inspect_date >= ?", startime)
2015 2015
 	}

+ 9 - 1
service/pharmacy_service.go 查看文件

@@ -2561,9 +2561,17 @@ func DispensingMedicineTwo(orgid, patient_id, advice_date, drug_id, creater int6
2561 2561
 	return
2562 2562
 }
2563 2563
 
2564
-func GetDrugTocalCountByDrugId(drug_id int64, advice_date int64, user_org_id int64) (advice []*models.HisDoctorAdviceInfo, err error) {
2564
+func GetDrugTocalCountByDrugId(drug_id int64, advice_date int64, user_org_id int64) (advice []*models.NBHisDoctorAdviceInfo, err error) {
2565 2565
 
2566 2566
 	err = XTReadDB().Where("drug_id = ? and advice_date>=? and user_org_id = ? and status=1 and drug_code!=''", drug_id, advice_date, user_org_id).Find(&advice).Error
2567 2567
 
2568 2568
 	return advice, err
2569 2569
 }
2570
+
2571
+func GetNewBaseDrugById(id int64) (models.NBXtBaseDrug, error) {
2572
+
2573
+	drug := models.NBXtBaseDrug{}
2574
+	err := XTReadDB().Where("id = ?", id).Find(&drug).Error
2575
+
2576
+	return drug, err
2577
+}

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

@@ -1271,7 +1271,7 @@ func GetInventoryModeList(orgid int64) (info []*models.PatientDrugWarehouseInfo,
1271 1271
 		if orgid > 0 {
1272 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,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
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.id").Scan(&info).Error
1275 1275
 		return info, err
1276 1276
 	} else {
1277 1277
 		db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1 and (x.warehousing_count>0)")

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

@@ -2488,7 +2488,7 @@ func BloodNewHisDrugsDelivery(orgID int64, creater int64, advice *models.HisDoct
2488 2488
 
2489 2489
 func CheckSchedule() (schedule []*models.XtSchedule, err error) {
2490 2490
 
2491
-	err = readDb3.Where("user_org_id = 10445 and schedule_date<1741536000").Find(&schedule).Error
2491
+	err = readDb3.Where("user_org_id = 9535 and schedule_date<1741536000").Find(&schedule).Error
2492 2492
 
2493 2493
 	return schedule, err
2494 2494
 }

+ 28 - 8
service/warhouse_service.go 查看文件

@@ -11049,10 +11049,15 @@ func AutoNewDrugDeliverInfoFourtyOne(orgID int64, prescribingNumber int64, wareh
11049 11049
 		if lastWarehouse.StockMinNumber >= drup.MinNumber {
11050 11050
 			var stockMax int64
11051 11051
 			var stockMin int64
11052
+
11053
+			var stockMac_One int64
11054
+
11052 11055
 			stockMax = lastWarehouse.StockMinNumber / drup.MinNumber
11053 11056
 			stockMin = lastWarehouse.StockMinNumber % drup.MinNumber
11054 11057
 
11055
-			ChangeNewMaxNumberOne(lastWarehouse.ID, stockMax, tx)
11058
+			stockMac_One = lastWarehouse.StockMaxNumber + stockMax
11059
+
11060
+			ChangeNewMaxNumberOne(lastWarehouse.ID, stockMac_One, tx)
11056 11061
 			UpdateNewMinNumber(lastWarehouse.ID, stockMin, tx)
11057 11062
 
11058 11063
 		}
@@ -11061,6 +11066,7 @@ func AutoNewDrugDeliverInfoFourtyOne(orgID int64, prescribingNumber int64, wareh
11061 11066
 	if lastWarehouse.MaxUnit == lastWarehouse.MinUnit && drup.MaxUnit != drup.MinUnit && lastWarehouse.MinUnit != "" {
11062 11067
 
11063 11068
 		lastWarehouse.StockMaxNumber = lastWarehouse.StockMaxNumber + lastWarehouse.StockMinNumber
11069
+
11064 11070
 		ChangeNewMaxNumberOne(lastWarehouse.ID, lastWarehouse.StockMaxNumber, tx)
11065 11071
 
11066 11072
 	}
@@ -11083,6 +11089,9 @@ func AutoNewDrugDeliverInfoFourtyOne(orgID int64, prescribingNumber int64, wareh
11083 11089
 		stock_number = warehouse.StockMaxNumber*drup.MinNumber + warehouse.StockMinNumber
11084 11090
 
11085 11091
 	}
11092
+
11093
+	fmt.Println("stock_number--------------", stock_number)
11094
+	fmt.Println("deliver_number", deliver_number)
11086 11095
 	if stock_number >= deliver_number {
11087 11096
 
11088 11097
 		var maxNumber int64 = 0
@@ -11091,6 +11100,10 @@ func AutoNewDrugDeliverInfoFourtyOne(orgID int64, prescribingNumber int64, wareh
11091 11100
 		maxNumber = deliver_number / drup.MinNumber
11092 11101
 		minNumber = deliver_number % drup.MinNumber
11093 11102
 
11103
+		fmt.Println("maxNumber==============", maxNumber)
11104
+
11105
+		fmt.Println("maxNumber==============", minNumber)
11106
+
11094 11107
 		if warehouse.StockMaxNumber == 0 && drup.MaxUnit == drup.MinUnit {
11095 11108
 			minNumber = maxNumber
11096 11109
 		}
@@ -11101,17 +11114,20 @@ func AutoNewDrugDeliverInfoFourtyOne(orgID int64, prescribingNumber int64, wareh
11101 11114
 			}
11102 11115
 		}
11103 11116
 
11117
+		fmt.Println("warehouse.StockMaxNumber", warehouse.StockMaxNumber)
11118
+		fmt.Println("warehouse.StockMinNumber", warehouse.StockMinNumber)
11119
+
11104 11120
 		if drup.MinUnit == warehouse.MaxUnit && drup.MaxUnit != drup.MinUnit {
11105
-			//fmt.Println("金1")
11121
+			fmt.Println("金1")
11106 11122
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber*drup.MinNumber
11107 11123
 		}
11108 11124
 
11109 11125
 		if drup.MaxUnit == warehouse.MaxUnit && drup.MaxUnit != drup.MinUnit {
11110
-			//fmt.Println("金2")
11126
+			fmt.Println("金2")
11111 11127
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
11112 11128
 		}
11113 11129
 		if drup.MaxUnit == warehouse.MaxUnit && drup.MaxUnit == drup.MinUnit {
11114
-			//fmt.Println("金3")
11130
+			fmt.Println("金3")
11115 11131
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
11116 11132
 		}
11117 11133
 
@@ -11124,8 +11140,12 @@ func AutoNewDrugDeliverInfoFourtyOne(orgID int64, prescribingNumber int64, wareh
11124 11140
 
11125 11141
 		warehouse.Mtime = time.Now().Unix()
11126 11142
 
11143
+		fmt.Println("warehouse.StockMinNumber", warehouse.StockMinNumber)
11144
+
11145
+		fmt.Println("minNumber222222222222222", minNumber)
11146
+
11127 11147
 		if warehouse.StockMinNumber < minNumber {
11128
-			//fmt.Println("金4")
11148
+			fmt.Println("金4")
11129 11149
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - 1
11130 11150
 			if warehouse.MaxUnit != warehouse.MinUnit {
11131 11151
 				warehouse.StockMinNumber = warehouse.StockMinNumber + drup.MinNumber - minNumber
@@ -11134,7 +11154,7 @@ func AutoNewDrugDeliverInfoFourtyOne(orgID int64, prescribingNumber int64, wareh
11134 11154
 				warehouse.StockMaxNumber = warehouse.StockMaxNumber - 1
11135 11155
 			}
11136 11156
 		} else {
11137
-			//fmt.Println("金5")
11157
+			fmt.Println("金5", minNumber)
11138 11158
 			if minNumber > 0 {
11139 11159
 				if (warehouse.StockMinNumber - minNumber) >= 0 {
11140 11160
 					warehouse.StockMinNumber = warehouse.StockMinNumber - minNumber
@@ -11143,7 +11163,7 @@ func AutoNewDrugDeliverInfoFourtyOne(orgID int64, prescribingNumber int64, wareh
11143 11163
 			}
11144 11164
 
11145 11165
 			if minNumber == 0 && maxNumber != 1 && warehouse.StockMaxNumber <= 0 {
11146
-				//fmt.Println("6")
11166
+				fmt.Println("6", warehouse.StockMinNumber)
11147 11167
 				if warehouse.StockMinNumber > 0 {
11148 11168
 					if warehouse.StockMinNumber-deliver_number >= 0 {
11149 11169
 						warehouse.StockMinNumber = warehouse.StockMinNumber - deliver_number
@@ -11157,7 +11177,7 @@ func AutoNewDrugDeliverInfoFourtyOne(orgID int64, prescribingNumber int64, wareh
11157 11177
 
11158 11178
 		if maxNumber == 1 && minNumber == 0 && drup.MaxUnit != drup.MinUnit && warehouse.MaxUnit != warehouse.MinUnit {
11159 11179
 			if (warehouse.StockMinNumber - deliver_number) >= 0 {
11160
-				//fmt.Println("金7")
11180
+				fmt.Println("金7")
11161 11181
 				warehouse.StockMinNumber = warehouse.StockMinNumber - deliver_number
11162 11182
 			}
11163 11183