浏览代码

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

csx 4 年前
父节点
当前提交
ec306b1f84
共有 2 个文件被更改,包括 18 次插入15 次删除
  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 查看文件

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

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

1366
 }
1366
 }
1367
 
1367
 
1368
 func FindDoctorAdviceByIdsTwo(orgID int64, ids []string) (advice []models.DoctorAdvice, err error) {
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
 	return
1370
 	return
1371
 }
1371
 }