|
@@ -688,20 +688,13 @@ func (c *PatientApiController) ExecDoctorAdvice() {
|
688
|
688
|
|
689
|
689
|
if drugStockConfig.IsOpen == 1 {
|
690
|
690
|
if groupno > 0 {
|
691
|
|
- advices, _ := service.FindAllDoctorAdviceByGoroupNo(adminUserInfo.Org.Id, groupno)
|
692
|
|
-
|
693
|
|
- isHasWay := false //用来判断是否包含来自药品库的医嘱
|
694
|
|
- for _, item := range advices {
|
695
|
|
- if item.Way == 1 {
|
696
|
|
- isHasWay = true
|
697
|
|
- }
|
|
691
|
+ advices, _ := service.FindAllDoctorAdviceByGoroupNoTwety(adminUserInfo.Org.Id, groupno)
|
698
|
692
|
|
699
|
|
- }
|
700
|
|
-
|
701
|
|
- if isHasWay {
|
|
693
|
+ if len(advices) > 0 {
|
702
|
694
|
var total int64
|
703
|
695
|
var prescribing_number_total int64
|
704
|
696
|
|
|
697
|
+ //判断库存
|
705
|
698
|
for _, item := range advices {
|
706
|
699
|
if item.Way == 1 {
|
707
|
700
|
houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
|
|
@@ -753,39 +746,22 @@ func (c *PatientApiController) ExecDoctorAdvice() {
|
753
|
746
|
}
|
754
|
747
|
}
|
755
|
748
|
|
756
|
|
- if prescribing_number_total <= total {
|
|
749
|
+ }
|
|
750
|
+ }
|
757
|
751
|
|
758
|
|
- //查询是否出库按钮开启
|
759
|
|
- adviceSetting, _ := service.FindAdviceSettingById(item.UserOrgId)
|
760
|
|
- if adviceSetting.IsAdviceOpen == 1 {
|
761
|
|
- //查询是否出库按钮开启
|
762
|
|
- prescriptionConfig, _ := service.FindPrescriptionConfigById(item.UserOrgId)
|
763
|
|
- pharmacyConfig, _ := service.FindPharmacyConfig(item.UserOrgId)
|
764
|
|
- if prescriptionConfig.IsOpen == 1 {
|
765
|
|
- if medical.IsUse == 2 {
|
766
|
|
- if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
|
767
|
|
- service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
|
768
|
|
- }
|
769
|
|
- if pharmacyConfig.IsOpen != 1 {
|
770
|
|
- service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
|
771
|
|
- }
|
|
752
|
+ //出库
|
|
753
|
+ for _, item := range advices {
|
|
754
|
+ if item.Way == 1 {
|
772
|
755
|
|
773
|
|
- //更新字典里面的库存
|
774
|
|
- stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
|
775
|
|
- var sum_count int64
|
776
|
|
- for _, its := range stockInfo {
|
777
|
|
- if its.MaxUnit == medical.MaxUnit {
|
778
|
|
- its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
|
779
|
|
- }
|
780
|
|
- sum_count += its.StockMaxNumber + its.StockMinNumber
|
781
|
|
- }
|
782
|
|
- service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
|
783
|
|
- //剩余库存
|
784
|
|
- service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
|
785
|
|
- }
|
786
|
|
- }
|
787
|
|
- } else {
|
788
|
|
- pharmacyConfig, _ := service.FindPharmacyConfig(item.UserOrgId)
|
|
756
|
+ //查询是否出库按钮开启
|
|
757
|
+ adviceSetting, _ := service.FindAdviceSettingById(item.UserOrgId)
|
|
758
|
+ //查询改药品信息
|
|
759
|
+ medical, _ := service.GetBaseDrugMedical(item.DrugId)
|
|
760
|
+ if adviceSetting.IsAdviceOpen == 1 {
|
|
761
|
+ //查询是否出库按钮开启
|
|
762
|
+ prescriptionConfig, _ := service.FindPrescriptionConfigById(item.UserOrgId)
|
|
763
|
+ pharmacyConfig, _ := service.FindPharmacyConfig(item.UserOrgId)
|
|
764
|
+ if prescriptionConfig.IsOpen == 1 {
|
789
|
765
|
if medical.IsUse == 2 {
|
790
|
766
|
if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
|
791
|
767
|
service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
|
|
@@ -794,6 +770,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
|
794
|
770
|
service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
|
795
|
771
|
}
|
796
|
772
|
|
|
773
|
+ //更新字典里面的库存
|
797
|
774
|
stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
|
798
|
775
|
var sum_count int64
|
799
|
776
|
for _, its := range stockInfo {
|
|
@@ -807,23 +784,47 @@ func (c *PatientApiController) ExecDoctorAdvice() {
|
807
|
784
|
service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
|
808
|
785
|
}
|
809
|
786
|
}
|
|
787
|
+ } else {
|
|
788
|
+ pharmacyConfig, _ := service.FindPharmacyConfig(item.UserOrgId)
|
|
789
|
+ if medical.IsUse == 2 {
|
|
790
|
+ if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
|
|
791
|
+ service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
|
|
792
|
+ }
|
|
793
|
+ if pharmacyConfig.IsOpen != 1 {
|
|
794
|
+ service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
|
|
795
|
+ }
|
|
796
|
+
|
|
797
|
+ stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
|
|
798
|
+ var sum_count int64
|
|
799
|
+ for _, its := range stockInfo {
|
|
800
|
+ if its.MaxUnit == medical.MaxUnit {
|
|
801
|
+ its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
|
|
802
|
+ }
|
|
803
|
+ sum_count += its.StockMaxNumber + its.StockMinNumber
|
|
804
|
+ }
|
|
805
|
+ service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
|
|
806
|
+ //剩余库存
|
|
807
|
+ service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
|
|
808
|
+ }
|
810
|
809
|
}
|
811
|
810
|
}
|
|
811
|
+
|
812
|
812
|
}
|
813
|
813
|
|
814
|
814
|
}
|
815
|
|
- } else {
|
816
|
815
|
|
817
|
|
- advices, _ := service.FindDoctorAdviceByIds(adminUserInfo.Org.Id, ids)
|
818
|
|
- isHasWay := false //用来判断是否包含来自药品库的医嘱
|
|
816
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
817
|
+ "msg": "1",
|
|
818
|
+ "advice": advice,
|
|
819
|
+ "ids": ids,
|
|
820
|
+ })
|
|
821
|
+ return
|
819
|
822
|
|
820
|
|
- for _, item := range advices {
|
821
|
|
- if item.Way == 1 {
|
822
|
|
- isHasWay = true
|
823
|
|
- }
|
824
|
|
- }
|
|
823
|
+ } else {
|
|
824
|
+
|
|
825
|
+ advices, _ := service.FindDoctorAdviceByIdsTwety(adminUserInfo.Org.Id, ids)
|
825
|
826
|
|
826
|
|
- if isHasWay {
|
|
827
|
+ if len(advices) > 0 {
|
827
|
828
|
var total int64
|
828
|
829
|
var prescribing_number_total int64
|
829
|
830
|
for _, item := range advices {
|
|
@@ -880,51 +881,56 @@ func (c *PatientApiController) ExecDoctorAdvice() {
|
880
|
881
|
}
|
881
|
882
|
}
|
882
|
883
|
|
883
|
|
- if prescribing_number_total <= total {
|
884
|
|
- pharmacyConfig, _ := service.FindPharmacyConfig(item.UserOrgId)
|
885
|
|
- if medical.IsUse == 2 {
|
886
|
|
- if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
|
887
|
|
- service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
|
888
|
|
- }
|
889
|
|
- if pharmacyConfig.IsOpen != 1 {
|
890
|
|
- service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
|
891
|
|
- }
|
|
884
|
+ }
|
|
885
|
+ }
|
892
|
886
|
|
893
|
|
- //更新字典里面的库存
|
894
|
|
- stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
|
895
|
|
- var sum_count int64
|
896
|
|
- for _, its := range stockInfo {
|
897
|
|
- baseDrug, _ := service.GetBaseDrugMedical(its.DrugId)
|
898
|
|
- if its.MaxUnit == baseDrug.MaxUnit {
|
899
|
|
- its.StockMaxNumber = its.StockMaxNumber * baseDrug.MinNumber
|
900
|
|
- }
|
901
|
|
- sum_count += its.StockMaxNumber + its.StockMinNumber
|
902
|
|
- }
|
903
|
|
- service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
|
904
|
|
- //剩余库存
|
905
|
|
- service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
|
|
887
|
+ for _, item := range advices {
|
|
888
|
+ if item.Way == 1 {
|
|
889
|
+ //查询改药品信息
|
|
890
|
+ medical, _ := service.GetBaseDrugMedical(item.DrugId)
|
|
891
|
+ pharmacyConfig, _ := service.FindPharmacyConfig(item.UserOrgId)
|
|
892
|
+ if medical.IsUse == 2 {
|
|
893
|
+ if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
|
|
894
|
+ service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
|
906
|
895
|
}
|
907
|
|
- if medical.IsUse == 1 {
|
908
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
909
|
|
- "msg": "1",
|
910
|
|
- "advice": advice,
|
911
|
|
- "ids": ids,
|
912
|
|
- })
|
913
|
|
- return
|
|
896
|
+ if pharmacyConfig.IsOpen != 1 {
|
|
897
|
+ service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
|
914
|
898
|
}
|
915
|
899
|
|
|
900
|
+ //更新字典里面的库存
|
|
901
|
+ stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
|
|
902
|
+ var sum_count int64
|
|
903
|
+ for _, its := range stockInfo {
|
|
904
|
+ baseDrug, _ := service.GetBaseDrugMedical(its.DrugId)
|
|
905
|
+ if its.MaxUnit == baseDrug.MaxUnit {
|
|
906
|
+ its.StockMaxNumber = its.StockMaxNumber * baseDrug.MinNumber
|
|
907
|
+ }
|
|
908
|
+ sum_count += its.StockMaxNumber + its.StockMinNumber
|
|
909
|
+ }
|
|
910
|
+ service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
|
|
911
|
+ //剩余库存
|
|
912
|
+ service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
|
916
|
913
|
}
|
|
914
|
+ if medical.IsUse == 1 {
|
|
915
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
916
|
+ "msg": "1",
|
|
917
|
+ "advice": advice,
|
|
918
|
+ "ids": ids,
|
|
919
|
+ })
|
|
920
|
+ return
|
|
921
|
+ }
|
|
922
|
+
|
917
|
923
|
}
|
|
924
|
+
|
918
|
925
|
}
|
919
|
926
|
}
|
|
927
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
928
|
+ "msg": "1",
|
|
929
|
+ "advice": advice,
|
|
930
|
+ "ids": ids,
|
|
931
|
+ })
|
|
932
|
+ return
|
920
|
933
|
}
|
921
|
|
-
|
922
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
923
|
|
- "msg": "1",
|
924
|
|
- "advice": advice,
|
925
|
|
- "ids": ids,
|
926
|
|
- })
|
927
|
|
- return
|
928
|
934
|
}
|
929
|
935
|
|
930
|
936
|
if privateDrugConfig != nil && privateDrugConfig.DrugStart == 1 {
|