|
@@ -719,6 +719,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
|
719
|
719
|
}
|
720
|
720
|
|
721
|
721
|
if medical.IsUse == 1 {
|
|
722
|
+ service.UpdateDoctorAdviceByExcecute(advice.ID, advice.UserOrgId)
|
722
|
723
|
c.ServeSuccessJSON(map[string]interface{}{
|
723
|
724
|
"msg": "1",
|
724
|
725
|
"advice": advice,
|
|
@@ -729,14 +730,17 @@ func (c *PatientApiController) ExecDoctorAdvice() {
|
729
|
730
|
|
730
|
731
|
if medical.IsUse != 1 {
|
731
|
732
|
if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
|
|
733
|
+ service.UpdateDoctorAdviceByExcecute(advice.ID, advice.UserOrgId)
|
732
|
734
|
c.ServeSuccessJSON(map[string]interface{}{
|
733
|
735
|
"msg": "3",
|
734
|
736
|
"advice": advice,
|
735
|
737
|
"ids": ids,
|
736
|
738
|
})
|
737
|
739
|
return
|
|
740
|
+
|
738
|
741
|
}
|
739
|
742
|
if prescribing_number_total > total {
|
|
743
|
+ service.UpdateDoctorAdviceByExcecute(advice.ID, advice.UserOrgId)
|
740
|
744
|
c.ServeSuccessJSON(map[string]interface{}{
|
741
|
745
|
"msg": "2",
|
742
|
746
|
"advice": advice,
|
|
@@ -752,7 +756,6 @@ func (c *PatientApiController) ExecDoctorAdvice() {
|
752
|
756
|
//出库
|
753
|
757
|
for _, item := range advices {
|
754
|
758
|
if item.Way == 1 {
|
755
|
|
-
|
756
|
759
|
//查询是否出库按钮开启
|
757
|
760
|
adviceSetting, _ := service.FindAdviceSettingById(item.UserOrgId)
|
758
|
761
|
//查询改药品信息
|
|
@@ -760,14 +763,23 @@ func (c *PatientApiController) ExecDoctorAdvice() {
|
760
|
763
|
if adviceSetting.IsAdviceOpen == 1 {
|
761
|
764
|
//查询是否出库按钮开启
|
762
|
765
|
prescriptionConfig, _ := service.FindPrescriptionConfigById(item.UserOrgId)
|
|
766
|
+ //患者发药
|
763
|
767
|
pharmacyConfig, _ := service.FindPharmacyConfig(item.UserOrgId)
|
764
|
768
|
if prescriptionConfig.IsOpen == 1 {
|
765
|
769
|
if medical.IsUse == 2 {
|
766
|
770
|
if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
|
767
|
|
- service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
|
|
771
|
+ //查询今日是否出库
|
|
772
|
+ drugOutInfo, _ := service.GetAdviceIsOut(item.ID, item.UserOrgId, item.PatientId, item.AdviceDate, item.DrugId)
|
|
773
|
+ if drugOutInfo.ID == 0 {
|
|
774
|
+ service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
|
|
775
|
+ }
|
|
776
|
+
|
768
|
777
|
}
|
769
|
778
|
if pharmacyConfig.IsOpen != 1 {
|
770
|
|
- service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
|
|
779
|
+ drugOutInfo, _ := service.GetAdviceIsOut(item.ID, item.UserOrgId, item.PatientId, item.AdviceDate, item.DrugId)
|
|
780
|
+ if drugOutInfo.ID == 0 {
|
|
781
|
+ service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
|
|
782
|
+ }
|
771
|
783
|
}
|
772
|
784
|
|
773
|
785
|
//更新字典里面的库存
|
|
@@ -788,10 +800,32 @@ func (c *PatientApiController) ExecDoctorAdvice() {
|
788
|
800
|
pharmacyConfig, _ := service.FindPharmacyConfig(item.UserOrgId)
|
789
|
801
|
if medical.IsUse == 2 {
|
790
|
802
|
if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
|
791
|
|
- service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
|
|
803
|
+ drugOutInfo, _ := service.GetAdviceIsOut(item.ID, item.UserOrgId, item.PatientId, item.AdviceDate, item.DrugId)
|
|
804
|
+ if drugOutInfo.ID == 0 {
|
|
805
|
+ service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
|
|
806
|
+ }
|
792
|
807
|
}
|
793
|
808
|
if pharmacyConfig.IsOpen != 1 {
|
794
|
|
- service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
|
|
809
|
+ drugError := models.XtDrugError{
|
|
810
|
+ ID: 0,
|
|
811
|
+ UserOrgId: item.UserOrgId,
|
|
812
|
+ DrugId: item.DrugId,
|
|
813
|
+ RecordDate: item.AdviceDate,
|
|
814
|
+ PatientId: item.PatientId,
|
|
815
|
+ Remark: "恒泰中医院出库开始",
|
|
816
|
+ Status: 1,
|
|
817
|
+ Ctime: time.Now().Unix(),
|
|
818
|
+ Mtime: 0,
|
|
819
|
+ Prescribingnumber: item.PrescribingNumber,
|
|
820
|
+ PrescribingNumberUnit: item.PrescribingNumberUnit,
|
|
821
|
+ SumCount: 0,
|
|
822
|
+ }
|
|
823
|
+ service.CreateDrugError(drugError)
|
|
824
|
+ drugOutInfo, _ := service.GetAdviceIsOut(item.ID, item.UserOrgId, item.PatientId, item.AdviceDate, item.DrugId)
|
|
825
|
+ if drugOutInfo.ID == 0 {
|
|
826
|
+
|
|
827
|
+ service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
|
|
828
|
+ }
|
795
|
829
|
}
|
796
|
830
|
|
797
|
831
|
stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
|
|
@@ -855,6 +889,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
|
855
|
889
|
}
|
856
|
890
|
|
857
|
891
|
if medical.IsUse == 1 {
|
|
892
|
+ service.UpdateDoctorAdviceByExcecute(advice.ID, advice.UserOrgId)
|
858
|
893
|
c.ServeSuccessJSON(map[string]interface{}{
|
859
|
894
|
"msg": "1",
|
860
|
895
|
"advice": advice,
|
|
@@ -864,6 +899,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
|
864
|
899
|
}
|
865
|
900
|
if medical.IsUse != 1 {
|
866
|
901
|
if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
|
|
902
|
+ service.UpdateDoctorAdviceByExcecute(advice.ID, advice.UserOrgId)
|
867
|
903
|
c.ServeSuccessJSON(map[string]interface{}{
|
868
|
904
|
"msg": "3",
|
869
|
905
|
"advice": advice,
|
|
@@ -872,6 +908,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
|
872
|
908
|
return
|
873
|
909
|
}
|
874
|
910
|
if prescribing_number_total > total {
|
|
911
|
+ service.UpdateDoctorAdviceByExcecute(advice.ID, advice.UserOrgId)
|
875
|
912
|
c.ServeSuccessJSON(map[string]interface{}{
|
876
|
913
|
"msg": "2",
|
877
|
914
|
"advice": advice,
|
|
@@ -891,10 +928,18 @@ func (c *PatientApiController) ExecDoctorAdvice() {
|
891
|
928
|
pharmacyConfig, _ := service.FindPharmacyConfig(item.UserOrgId)
|
892
|
929
|
if medical.IsUse == 2 {
|
893
|
930
|
if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
|
894
|
|
- service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
|
|
931
|
+ //查询今日是否出库
|
|
932
|
+ drugOutInfo, _ := service.GetAdviceIsOut(item.ID, item.UserOrgId, item.PatientId, item.AdviceDate, item.DrugId)
|
|
933
|
+ if drugOutInfo.ID == 0 {
|
|
934
|
+ service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
|
|
935
|
+ }
|
895
|
936
|
}
|
896
|
937
|
if pharmacyConfig.IsOpen != 1 {
|
897
|
|
- service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
|
|
938
|
+ //查询今日是否出库
|
|
939
|
+ drugOutInfo, _ := service.GetAdviceIsOut(item.ID, item.UserOrgId, item.PatientId, item.AdviceDate, item.DrugId)
|
|
940
|
+ if drugOutInfo.ID == 0 {
|
|
941
|
+ service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
|
|
942
|
+ }
|
898
|
943
|
}
|
899
|
944
|
|
900
|
945
|
//更新字典里面的库存
|