Bladeren bron

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

csx 4 jaren geleden
bovenliggende
commit
ec306b1f84
2 gewijzigde bestanden met toevoegingen van 18 en 15 verwijderingen
  1. 17 14
      controllers/mobile_api_controllers/patient_api_controller.go
  2. 1 1
      service/patient_service.go

+ 17 - 14
controllers/mobile_api_controllers/patient_api_controller.go Bestand weergeven

@@ -552,9 +552,11 @@ func (c *PatientApiController) ExecDoctorAdvice() {
552 552
 	//}
553 553
 
554 554
 	var advice models.DoctorAdvice
555
+	var tempAdvices []models.DoctorAdvice
555 556
 
556 557
 	if groupno > 0 {
557
-		advices, _ := service.FindAllDoctorAdviceByGoroupNo(adminUserInfo.Org.Id, groupno)
558
+		advices, _ := service.FindAllDoctorAdviceByGoroupNoTwo(adminUserInfo.Org.Id, groupno)
559
+		tempAdvices = advices
558 560
 		for _, item := range advices {
559 561
 			if item.ExecutionState == 2 {
560 562
 				advice = item
@@ -562,7 +564,9 @@ func (c *PatientApiController) ExecDoctorAdvice() {
562 564
 			}
563 565
 		}
564 566
 	} else {
565
-		advices, _ := service.FindDoctorAdviceByIds(adminUserInfo.Org.Id, ids)
567
+		advices, _ := service.FindDoctorAdviceByIdsTwo(adminUserInfo.Org.Id, ids)
568
+		tempAdvices = advices
569
+
566 570
 		for _, item := range advices {
567 571
 			if item.ExecutionState == 2 {
568 572
 				advice = item
@@ -622,10 +626,10 @@ func (c *PatientApiController) ExecDoctorAdvice() {
622 626
 
623 627
 	if drugStockConfig.IsOpen == 1 {
624 628
 		if groupno > 0 {
625
-			advices, _ := service.FindAllDoctorAdviceByGoroupNo(adminUserInfo.Org.Id, groupno)
629
+			//advices, _ := service.FindAllDoctorAdviceByGoroupNo(adminUserInfo.Org.Id, groupno)
626 630
 			isHasWay := false //用来判断是否包含来自药品库的医嘱
627 631
 			record_time := int64(0)
628
-			for _, item := range advices {
632
+			for _, item := range tempAdvices {
629 633
 				if item.Way == 1 {
630 634
 					isHasWay = true
631 635
 					record_time = item.RecordDate
@@ -662,7 +666,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
662 666
 					if err != nil {
663 667
 						utils.TraceLog("创建出库单失败 err = %v", err)
664 668
 					} else {
665
-						for _, item := range advices {
669
+						for _, item := range tempAdvices {
666 670
 							if item.Way == 1 {
667 671
 								if item.PrescribingNumber > 0 {
668 672
 									warehouseOutInfo := &models.DrugWarehouseOutInfo{
@@ -707,7 +711,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
707 711
 					}
708 712
 
709 713
 				} else if err == nil {
710
-					for _, item := range advices {
714
+					for _, item := range tempAdvices {
711 715
 						if item.Way == 1 {
712 716
 							outInfo, err := service.FindDrugStockOutInfoByTypeId(adminUserInfo.Org.Id, item.DrugId, out.ID, out.WarehouseOutOrderNumber)
713 717
 							if err == gorm.ErrRecordNotFound {
@@ -781,10 +785,10 @@ func (c *PatientApiController) ExecDoctorAdvice() {
781 785
 
782 786
 			}
783 787
 		} else {
784
-			advices, _ := service.FindDoctorAdviceByIds(adminUserInfo.Org.Id, ids)
788
+			//advices, _ := service.FindDoctorAdviceByIds(adminUserInfo.Org.Id, ids)
785 789
 			isHasWay := false //用来判断是否包含来自药品库的医嘱
786 790
 			record_time := int64(0)
787
-			for _, item := range advices {
791
+			for _, item := range tempAdvices {
788 792
 				if item.Way == 1 {
789 793
 					isHasWay = true
790 794
 					record_time = item.RecordDate
@@ -821,7 +825,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
821 825
 					if err != nil {
822 826
 						utils.TraceLog("创建出库单失败 err = %v", err)
823 827
 					} else {
824
-						for _, item := range advices {
828
+						for _, item := range tempAdvices {
825 829
 							if item.Way == 1 {
826 830
 								if item.PrescribingNumber > 0 {
827 831
 									warehouseOutInfo := &models.DrugWarehouseOutInfo{
@@ -866,7 +870,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
866 870
 					}
867 871
 
868 872
 				} else if err == nil {
869
-					for _, item := range advices {
873
+					for _, item := range tempAdvices {
870 874
 						if item.Way == 1 {
871 875
 							outInfo, err := service.FindDrugStockOutInfoByTypeId(adminUserInfo.Org.Id, item.DrugId, out.ID, out.WarehouseOutOrderNumber)
872 876
 							if err == gorm.ErrRecordNotFound {
@@ -950,8 +954,8 @@ func (c *PatientApiController) ExecDoctorAdvice() {
950 954
 
951 955
 	if privateDrugConfig != nil && privateDrugConfig.DrugStart == 1 {
952 956
 		if groupno > 0 {
953
-			advices, _ := service.FindAllDoctorAdviceByGoroupNo(adminUserInfo.Org.Id, groupno)
954
-			for _, item := range advices {
957
+			//advices, _ := service.FindAllDoctorAdviceByGoroupNo(adminUserInfo.Org.Id, groupno)
958
+			for _, item := range tempAdvices {
955 959
 
956 960
 				if item.ExecutionState == 1 && item.Way == 2 {
957 961
 					prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
@@ -987,8 +991,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
987 991
 			}
988 992
 		} else {
989 993
 
990
-			advices, _ := service.FindDoctorAdviceByIds(adminUserInfo.Org.Id, ids)
991
-			for _, item := range advices {
994
+			for _, item := range tempAdvices {
992 995
 				if item.ExecutionState == 1 && item.Way == 2 {
993 996
 
994 997
 					prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)

+ 1 - 1
service/patient_service.go Bestand weergeven

@@ -1366,6 +1366,6 @@ func FindAllDoctorAdviceByGoroupNoTwo(orgID int64, groupno int64) (advice []mode
1366 1366
 }
1367 1367
 
1368 1368
 func FindDoctorAdviceByIdsTwo(orgID int64, ids []string) (advice []models.DoctorAdvice, err error) {
1369
-	err = readDb.Model(&models.DoctorAdvice{}).Where("user_org_id = ? AND status = 1 AND execution_state = 2 OR (id IN (?) AND patient_id IN (?))", orgID, ids, ids).Find(&advice).Error
1369
+	err = readDb.Model(&models.DoctorAdvice{}).Where("user_org_id = ? AND status = 1 AND execution_state = 2 AND (id IN (?) OR parent_id IN (?))", orgID, ids, ids).Find(&advice).Error
1370 1370
 	return
1371 1371
 }