|
@@ -637,7 +637,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
|
637
|
637
|
}
|
638
|
638
|
|
639
|
639
|
if isHasWay {
|
640
|
|
- out, err := service.FindDrugStockOutByIsSys(adminUserInfo.Org.Id, 1, record_time)
|
|
640
|
+ _, err := service.FindDrugStockOutByIsSys(adminUserInfo.Org.Id, 1, record_time)
|
641
|
641
|
if err == gorm.ErrRecordNotFound {
|
642
|
642
|
//没有记录,则创建出库单
|
643
|
643
|
timeStr := time.Now().Format("2006-01-02")
|
|
@@ -668,43 +668,46 @@ func (c *PatientApiController) ExecDoctorAdvice() {
|
668
|
668
|
} else {
|
669
|
669
|
for _, item := range advices {
|
670
|
670
|
if item.Way == 1 {
|
671
|
|
- if item.PrescribingNumber > 0 {
|
672
|
|
- warehouseOutInfo := &models.DrugWarehouseOutInfo{
|
673
|
|
- WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
|
674
|
|
- WarehouseOutId: warehouseOut.ID,
|
675
|
|
- Status: 1,
|
676
|
|
- Ctime: time.Now().Unix(),
|
677
|
|
- Remark: "",
|
678
|
|
- OrgId: adminUserInfo.Org.Id,
|
679
|
|
- Type: 1,
|
680
|
|
- Manufacturer: 0,
|
681
|
|
- Dealer: 0,
|
682
|
|
- IsSys: 1,
|
683
|
|
- SysRecordTime: record_time,
|
684
|
|
- DrugId: item.DrugId,
|
685
|
|
- }
|
686
|
|
- prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
687
|
|
- count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
688
|
|
- warehouseOutInfo.Count = count
|
689
|
|
- stockInInfo, _ := service.FindLastDrugStockInInfoRecord(item.DrugId, adminUserInfo.Org.Id)
|
690
|
|
- warehouseOutInfo.Price = stockInInfo.Price
|
691
|
|
- err := service.AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
|
692
|
|
- if err == nil {
|
693
|
|
- details := &models.DrugAutomaticReduceDetail{
|
694
|
|
- WarehouseOutId: warehouseOutInfo.ID,
|
695
|
|
- WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
|
696
|
|
- PatientId: item.PatientId,
|
697
|
|
- Ctime: time.Now().Unix(),
|
698
|
|
- Mtime: time.Now().Unix(),
|
699
|
|
- Status: 1,
|
700
|
|
- RecordTime: record_time,
|
701
|
|
- OrgId: adminUserInfo.Org.Id,
|
702
|
|
- DrugId: item.DrugId,
|
703
|
|
- Count: count,
|
704
|
|
- }
|
705
|
|
- service.AddSigleDrugAutoReduceRecordInfo(details)
|
706
|
|
- }
|
707
|
|
- }
|
|
671
|
+
|
|
672
|
+ service.DrugsDelivery(item.UserOrgId, &item)
|
|
673
|
+
|
|
674
|
+ //if item.PrescribingNumber > 0 {
|
|
675
|
+ // warehouseOutInfo := &models.DrugWarehouseOutInfo{
|
|
676
|
+ // WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
|
|
677
|
+ // WarehouseOutId: warehouseOut.ID,
|
|
678
|
+ // Status: 1,
|
|
679
|
+ // Ctime: time.Now().Unix(),
|
|
680
|
+ // Remark: "",
|
|
681
|
+ // OrgId: adminUserInfo.Org.Id,
|
|
682
|
+ // Type: 1,
|
|
683
|
+ // Manufacturer: 0,
|
|
684
|
+ // Dealer: 0,
|
|
685
|
+ // IsSys: 1,
|
|
686
|
+ // SysRecordTime: record_time,
|
|
687
|
+ // DrugId: item.DrugId,
|
|
688
|
+ // }
|
|
689
|
+ // prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
|
690
|
+ // count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
|
691
|
+ // warehouseOutInfo.Count = count
|
|
692
|
+ // stockInInfo, _ := service.FindLastDrugStockInInfoRecord(item.DrugId, adminUserInfo.Org.Id)
|
|
693
|
+ // warehouseOutInfo.Price = stockInInfo.Price
|
|
694
|
+ // err := service.AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
|
|
695
|
+ // if err == nil {
|
|
696
|
+ // details := &models.DrugAutomaticReduceDetail{
|
|
697
|
+ // WarehouseOutId: warehouseOutInfo.ID,
|
|
698
|
+ // WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
|
|
699
|
+ // PatientId: item.PatientId,
|
|
700
|
+ // Ctime: time.Now().Unix(),
|
|
701
|
+ // Mtime: time.Now().Unix(),
|
|
702
|
+ // Status: 1,
|
|
703
|
+ // RecordTime: record_time,
|
|
704
|
+ // OrgId: adminUserInfo.Org.Id,
|
|
705
|
+ // DrugId: item.DrugId,
|
|
706
|
+ // Count: count,
|
|
707
|
+ // }
|
|
708
|
+ // service.AddSigleDrugAutoReduceRecordInfo(details)
|
|
709
|
+ // }
|
|
710
|
+ //}
|
708
|
711
|
}
|
709
|
712
|
|
710
|
713
|
}
|
|
@@ -713,71 +716,72 @@ func (c *PatientApiController) ExecDoctorAdvice() {
|
713
|
716
|
} else if err == nil {
|
714
|
717
|
for _, item := range advices {
|
715
|
718
|
if item.Way == 1 {
|
716
|
|
- outInfo, err := service.FindDrugStockOutInfoByTypeId(adminUserInfo.Org.Id, item.DrugId, out.ID, out.WarehouseOutOrderNumber)
|
717
|
|
- if err == gorm.ErrRecordNotFound {
|
718
|
|
- warehouseOutInfo := &models.DrugWarehouseOutInfo{
|
719
|
|
- WarehouseOutOrderNumber: out.WarehouseOutOrderNumber,
|
720
|
|
- WarehouseOutId: out.ID,
|
721
|
|
- Status: 1,
|
722
|
|
- Ctime: time.Now().Unix(),
|
723
|
|
- Remark: "",
|
724
|
|
- OrgId: adminUserInfo.Org.Id,
|
725
|
|
- Type: 1,
|
726
|
|
- Manufacturer: 0,
|
727
|
|
- Dealer: 0,
|
728
|
|
- IsSys: 1,
|
729
|
|
- SysRecordTime: record_time,
|
730
|
|
- }
|
731
|
|
-
|
732
|
|
- stockInInfo, _ := service.FindLastDrugStockInInfoRecord(item.DrugId, adminUserInfo.Org.Id)
|
733
|
|
- warehouseOutInfo.Price = stockInInfo.Price
|
734
|
|
- warehouseOutInfo.DrugId = item.DrugId
|
735
|
|
- prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
736
|
|
- count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
737
|
|
- warehouseOutInfo.Count = count
|
738
|
|
- err := service.AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
|
739
|
|
- if err == nil {
|
740
|
|
- details := &models.DrugAutomaticReduceDetail{
|
741
|
|
- WarehouseOutId: warehouseOutInfo.ID,
|
742
|
|
- WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
|
743
|
|
- PatientId: item.PatientId,
|
744
|
|
- Ctime: time.Now().Unix(),
|
745
|
|
- Mtime: time.Now().Unix(),
|
746
|
|
- Status: 1,
|
747
|
|
- RecordTime: record_time,
|
748
|
|
- OrgId: adminUserInfo.Org.Id,
|
749
|
|
- DrugId: item.DrugId,
|
750
|
|
- Count: count,
|
751
|
|
- }
|
752
|
|
- service.AddSigleDrugAutoReduceRecordInfo(details)
|
753
|
|
- }
|
754
|
|
-
|
755
|
|
- } else if err == nil { //记录存在,则将增加数量
|
756
|
|
- if outInfo.ID > 0 {
|
757
|
|
- prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
758
|
|
- count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
759
|
|
- service.UpdateDrugStockOutInfoCount2(adminUserInfo.Org.Id, outInfo.ID, count)
|
760
|
|
- }
|
761
|
|
-
|
762
|
|
- //count, _ := service.FindPatientDrugAutomaticReduceRecord(adminUserInfo.Org.Id, record_time, item.DrugId, item.PatientId)
|
763
|
|
- //if count == 0 {
|
764
|
|
- prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
765
|
|
- count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
766
|
|
- details := &models.DrugAutomaticReduceDetail{
|
767
|
|
- WarehouseOutId: outInfo.ID,
|
768
|
|
- WarehouseOutOrderNumber: outInfo.WarehouseOutOrderNumber,
|
769
|
|
- PatientId: item.PatientId,
|
770
|
|
- Ctime: time.Now().Unix(),
|
771
|
|
- Mtime: time.Now().Unix(),
|
772
|
|
- Status: 1,
|
773
|
|
- RecordTime: record_time,
|
774
|
|
- OrgId: adminUserInfo.Org.Id,
|
775
|
|
- DrugId: item.DrugId,
|
776
|
|
- Count: count,
|
777
|
|
- }
|
778
|
|
- service.AddSigleDrugAutoReduceRecordInfo(details)
|
779
|
|
-
|
780
|
|
- }
|
|
719
|
+ service.DrugsDelivery(item.UserOrgId, &item)
|
|
720
|
+ //outInfo, err := service.FindDrugStockOutInfoByTypeId(adminUserInfo.Org.Id, item.DrugId, out.ID, out.WarehouseOutOrderNumber)
|
|
721
|
+ //if err == gorm.ErrRecordNotFound {
|
|
722
|
+ // warehouseOutInfo := &models.DrugWarehouseOutInfo{
|
|
723
|
+ // WarehouseOutOrderNumber: out.WarehouseOutOrderNumber,
|
|
724
|
+ // WarehouseOutId: out.ID,
|
|
725
|
+ // Status: 1,
|
|
726
|
+ // Ctime: time.Now().Unix(),
|
|
727
|
+ // Remark: "",
|
|
728
|
+ // OrgId: adminUserInfo.Org.Id,
|
|
729
|
+ // Type: 1,
|
|
730
|
+ // Manufacturer: 0,
|
|
731
|
+ // Dealer: 0,
|
|
732
|
+ // IsSys: 1,
|
|
733
|
+ // SysRecordTime: record_time,
|
|
734
|
+ // }
|
|
735
|
+ //
|
|
736
|
+ // stockInInfo, _ := service.FindLastDrugStockInInfoRecord(item.DrugId, adminUserInfo.Org.Id)
|
|
737
|
+ // warehouseOutInfo.Price = stockInInfo.Price
|
|
738
|
+ // warehouseOutInfo.DrugId = item.DrugId
|
|
739
|
+ // prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
|
740
|
+ // count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
|
741
|
+ // warehouseOutInfo.Count = count
|
|
742
|
+ // err := service.AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
|
|
743
|
+ // if err == nil {
|
|
744
|
+ // details := &models.DrugAutomaticReduceDetail{
|
|
745
|
+ // WarehouseOutId: warehouseOutInfo.ID,
|
|
746
|
+ // WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
|
|
747
|
+ // PatientId: item.PatientId,
|
|
748
|
+ // Ctime: time.Now().Unix(),
|
|
749
|
+ // Mtime: time.Now().Unix(),
|
|
750
|
+ // Status: 1,
|
|
751
|
+ // RecordTime: record_time,
|
|
752
|
+ // OrgId: adminUserInfo.Org.Id,
|
|
753
|
+ // DrugId: item.DrugId,
|
|
754
|
+ // Count: count,
|
|
755
|
+ // }
|
|
756
|
+ // service.AddSigleDrugAutoReduceRecordInfo(details)
|
|
757
|
+ // }
|
|
758
|
+ //
|
|
759
|
+ //} else if err == nil { //记录存在,则将增加数量
|
|
760
|
+ // if outInfo.ID > 0 {
|
|
761
|
+ // prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
|
762
|
+ // count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
|
763
|
+ // service.UpdateDrugStockOutInfoCount2(adminUserInfo.Org.Id, outInfo.ID, count)
|
|
764
|
+ // }
|
|
765
|
+ //
|
|
766
|
+ // //count, _ := service.FindPatientDrugAutomaticReduceRecord(adminUserInfo.Org.Id, record_time, item.DrugId, item.PatientId)
|
|
767
|
+ // //if count == 0 {
|
|
768
|
+ // prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
|
769
|
+ // count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
|
770
|
+ // details := &models.DrugAutomaticReduceDetail{
|
|
771
|
+ // WarehouseOutId: outInfo.ID,
|
|
772
|
+ // WarehouseOutOrderNumber: outInfo.WarehouseOutOrderNumber,
|
|
773
|
+ // PatientId: item.PatientId,
|
|
774
|
+ // Ctime: time.Now().Unix(),
|
|
775
|
+ // Mtime: time.Now().Unix(),
|
|
776
|
+ // Status: 1,
|
|
777
|
+ // RecordTime: record_time,
|
|
778
|
+ // OrgId: adminUserInfo.Org.Id,
|
|
779
|
+ // DrugId: item.DrugId,
|
|
780
|
+ // Count: count,
|
|
781
|
+ // }
|
|
782
|
+ // service.AddSigleDrugAutoReduceRecordInfo(details)
|
|
783
|
+ //
|
|
784
|
+ //}
|
781
|
785
|
}
|
782
|
786
|
}
|
783
|
787
|
|
|
@@ -796,7 +800,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
|
796
|
800
|
}
|
797
|
801
|
|
798
|
802
|
if isHasWay {
|
799
|
|
- out, err := service.FindDrugStockOutByIsSys(adminUserInfo.Org.Id, 1, record_time)
|
|
803
|
+ _, err := service.FindDrugStockOutByIsSys(adminUserInfo.Org.Id, 1, record_time)
|
800
|
804
|
if err == gorm.ErrRecordNotFound {
|
801
|
805
|
//没有记录,则创建出库单
|
802
|
806
|
timeStr := time.Now().Format("2006-01-02")
|
|
@@ -827,43 +831,44 @@ func (c *PatientApiController) ExecDoctorAdvice() {
|
827
|
831
|
} else {
|
828
|
832
|
for _, item := range advices {
|
829
|
833
|
if item.Way == 1 {
|
830
|
|
- if item.PrescribingNumber > 0 {
|
831
|
|
- warehouseOutInfo := &models.DrugWarehouseOutInfo{
|
832
|
|
- WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
|
833
|
|
- WarehouseOutId: warehouseOut.ID,
|
834
|
|
- Status: 1,
|
835
|
|
- Ctime: time.Now().Unix(),
|
836
|
|
- Remark: "",
|
837
|
|
- OrgId: adminUserInfo.Org.Id,
|
838
|
|
- Type: 1,
|
839
|
|
- Manufacturer: 0,
|
840
|
|
- Dealer: 0,
|
841
|
|
- IsSys: 1,
|
842
|
|
- SysRecordTime: record_time,
|
843
|
|
- DrugId: item.DrugId,
|
844
|
|
- }
|
845
|
|
- prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
846
|
|
- count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
847
|
|
- warehouseOutInfo.Count = count
|
848
|
|
- stockInInfo, _ := service.FindLastDrugStockInInfoRecord(item.DrugId, adminUserInfo.Org.Id)
|
849
|
|
- warehouseOutInfo.Price = stockInInfo.Price
|
850
|
|
- err := service.AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
|
851
|
|
- if err == nil {
|
852
|
|
- details := &models.DrugAutomaticReduceDetail{
|
853
|
|
- WarehouseOutId: warehouseOutInfo.ID,
|
854
|
|
- WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
|
855
|
|
- PatientId: item.PatientId,
|
856
|
|
- Ctime: time.Now().Unix(),
|
857
|
|
- Mtime: time.Now().Unix(),
|
858
|
|
- Status: 1,
|
859
|
|
- RecordTime: record_time,
|
860
|
|
- OrgId: adminUserInfo.Org.Id,
|
861
|
|
- DrugId: item.DrugId,
|
862
|
|
- Count: count,
|
863
|
|
- }
|
864
|
|
- service.AddSigleDrugAutoReduceRecordInfo(details)
|
865
|
|
- }
|
866
|
|
- }
|
|
834
|
+ service.DrugsDelivery(item.UserOrgId, &item)
|
|
835
|
+ //if item.PrescribingNumber > 0 {
|
|
836
|
+ // warehouseOutInfo := &models.DrugWarehouseOutInfo{
|
|
837
|
+ // WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
|
|
838
|
+ // WarehouseOutId: warehouseOut.ID,
|
|
839
|
+ // Status: 1,
|
|
840
|
+ // Ctime: time.Now().Unix(),
|
|
841
|
+ // Remark: "",
|
|
842
|
+ // OrgId: adminUserInfo.Org.Id,
|
|
843
|
+ // Type: 1,
|
|
844
|
+ // Manufacturer: 0,
|
|
845
|
+ // Dealer: 0,
|
|
846
|
+ // IsSys: 1,
|
|
847
|
+ // SysRecordTime: record_time,
|
|
848
|
+ // DrugId: item.DrugId,
|
|
849
|
+ // }
|
|
850
|
+ // prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
|
851
|
+ // count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
|
852
|
+ // warehouseOutInfo.Count = count
|
|
853
|
+ // stockInInfo, _ := service.FindLastDrugStockInInfoRecord(item.DrugId, adminUserInfo.Org.Id)
|
|
854
|
+ // warehouseOutInfo.Price = stockInInfo.Price
|
|
855
|
+ // err := service.AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
|
|
856
|
+ // if err == nil {
|
|
857
|
+ // details := &models.DrugAutomaticReduceDetail{
|
|
858
|
+ // WarehouseOutId: warehouseOutInfo.ID,
|
|
859
|
+ // WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
|
|
860
|
+ // PatientId: item.PatientId,
|
|
861
|
+ // Ctime: time.Now().Unix(),
|
|
862
|
+ // Mtime: time.Now().Unix(),
|
|
863
|
+ // Status: 1,
|
|
864
|
+ // RecordTime: record_time,
|
|
865
|
+ // OrgId: adminUserInfo.Org.Id,
|
|
866
|
+ // DrugId: item.DrugId,
|
|
867
|
+ // Count: count,
|
|
868
|
+ // }
|
|
869
|
+ // service.AddSigleDrugAutoReduceRecordInfo(details)
|
|
870
|
+ // }
|
|
871
|
+ //}
|
867
|
872
|
}
|
868
|
873
|
|
869
|
874
|
}
|
|
@@ -872,77 +877,73 @@ func (c *PatientApiController) ExecDoctorAdvice() {
|
872
|
877
|
} else if err == nil {
|
873
|
878
|
for _, item := range advices {
|
874
|
879
|
if item.Way == 1 {
|
875
|
|
- outInfo, err := service.FindDrugStockOutInfoByTypeId(adminUserInfo.Org.Id, item.DrugId, out.ID, out.WarehouseOutOrderNumber)
|
876
|
|
- if err == gorm.ErrRecordNotFound {
|
877
|
|
- warehouseOutInfo := &models.DrugWarehouseOutInfo{
|
878
|
|
- WarehouseOutOrderNumber: out.WarehouseOutOrderNumber,
|
879
|
|
- WarehouseOutId: out.ID,
|
880
|
|
- Status: 1,
|
881
|
|
- Ctime: time.Now().Unix(),
|
882
|
|
- Remark: "",
|
883
|
|
- OrgId: adminUserInfo.Org.Id,
|
884
|
|
- Type: 1,
|
885
|
|
- Manufacturer: 0,
|
886
|
|
- Dealer: 0,
|
887
|
|
- IsSys: 1,
|
888
|
|
- SysRecordTime: record_time,
|
889
|
|
- }
|
890
|
|
-
|
891
|
|
- stockInInfo, _ := service.FindLastDrugStockInInfoRecord(item.DrugId, adminUserInfo.Org.Id)
|
892
|
|
- warehouseOutInfo.Price = stockInInfo.Price
|
893
|
|
- warehouseOutInfo.DrugId = item.DrugId
|
894
|
|
- //warehouseOutInfo.Count = item.
|
895
|
|
- prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
896
|
|
- count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
897
|
|
- err := service.AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
|
898
|
|
- if err == nil {
|
899
|
|
- details := &models.DrugAutomaticReduceDetail{
|
900
|
|
- WarehouseOutId: warehouseOutInfo.ID,
|
901
|
|
- WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
|
902
|
|
- PatientId: item.PatientId,
|
903
|
|
- Ctime: time.Now().Unix(),
|
904
|
|
- Mtime: time.Now().Unix(),
|
905
|
|
- Status: 1,
|
906
|
|
- RecordTime: record_time,
|
907
|
|
- OrgId: adminUserInfo.Org.Id,
|
908
|
|
- DrugId: item.DrugId,
|
909
|
|
- Count: count,
|
910
|
|
- }
|
911
|
|
- service.AddSigleDrugAutoReduceRecordInfo(details)
|
912
|
|
- }
|
913
|
|
-
|
914
|
|
- } else if err == nil { //记录存在,则将增加数量
|
915
|
|
- if outInfo.ID > 0 {
|
916
|
|
- prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
917
|
|
- count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
918
|
|
- service.UpdateDrugStockOutInfoCount2(adminUserInfo.Org.Id, outInfo.ID, count)
|
919
|
|
- }
|
920
|
|
-
|
921
|
|
- //count, _ := service.FindPatientDrugAutomaticReduceRecord(adminUserInfo.Org.Id, record_time, item.DrugId, item.PatientId)
|
922
|
|
- //if count == 0 {
|
923
|
|
- prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
924
|
|
- count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
925
|
|
- details := &models.DrugAutomaticReduceDetail{
|
926
|
|
- WarehouseOutId: outInfo.ID,
|
927
|
|
- WarehouseOutOrderNumber: outInfo.WarehouseOutOrderNumber,
|
928
|
|
- PatientId: item.PatientId,
|
929
|
|
- Ctime: time.Now().Unix(),
|
930
|
|
- Mtime: time.Now().Unix(),
|
931
|
|
- Status: 1,
|
932
|
|
- RecordTime: record_time,
|
933
|
|
- OrgId: adminUserInfo.Org.Id,
|
934
|
|
- DrugId: item.DrugId,
|
935
|
|
- Count: count,
|
936
|
|
- }
|
937
|
|
- service.AddSigleDrugAutoReduceRecordInfo(details)
|
938
|
|
- //}
|
939
|
|
- //else if count == 1 {
|
940
|
|
- // prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
941
|
|
- // count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
942
|
|
- // service.UpdateDrugUserInfoDetails(item.DrugId, record_time, adminUserInfo.Org.Id, item.PatientId, count, &outInfo)
|
943
|
|
- //}
|
944
|
|
-
|
945
|
|
- }
|
|
880
|
+ service.DrugsDelivery(item.UserOrgId, &item)
|
|
881
|
+ //outInfo, err := service.FindDrugStockOutInfoByTypeId(adminUserInfo.Org.Id, item.DrugId, out.ID, out.WarehouseOutOrderNumber)
|
|
882
|
+ //if err == gorm.ErrRecordNotFound {
|
|
883
|
+ // warehouseOutInfo := &models.DrugWarehouseOutInfo{
|
|
884
|
+ // WarehouseOutOrderNumber: out.WarehouseOutOrderNumber,
|
|
885
|
+ // WarehouseOutId: out.ID,
|
|
886
|
+ // Status: 1,
|
|
887
|
+ // Ctime: time.Now().Unix(),
|
|
888
|
+ // Remark: "",
|
|
889
|
+ // OrgId: adminUserInfo.Org.Id,
|
|
890
|
+ // Type: 1,
|
|
891
|
+ // Manufacturer: 0,
|
|
892
|
+ // Dealer: 0,
|
|
893
|
+ // IsSys: 1,
|
|
894
|
+ // SysRecordTime: record_time,
|
|
895
|
+ // }
|
|
896
|
+ //
|
|
897
|
+ // stockInInfo, _ := service.FindLastDrugStockInInfoRecord(item.DrugId, adminUserInfo.Org.Id)
|
|
898
|
+ // warehouseOutInfo.Price = stockInInfo.Price
|
|
899
|
+ // warehouseOutInfo.DrugId = item.DrugId
|
|
900
|
+ // //warehouseOutInfo.Count = item.
|
|
901
|
+ // prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
|
902
|
+ // count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
|
903
|
+ // err := service.AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
|
|
904
|
+ // if err == nil {
|
|
905
|
+ // details := &models.DrugAutomaticReduceDetail{
|
|
906
|
+ // WarehouseOutId: warehouseOutInfo.ID,
|
|
907
|
+ // WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
|
|
908
|
+ // PatientId: item.PatientId,
|
|
909
|
+ // Ctime: time.Now().Unix(),
|
|
910
|
+ // Mtime: time.Now().Unix(),
|
|
911
|
+ // Status: 1,
|
|
912
|
+ // RecordTime: record_time,
|
|
913
|
+ // OrgId: adminUserInfo.Org.Id,
|
|
914
|
+ // DrugId: item.DrugId,
|
|
915
|
+ // Count: count,
|
|
916
|
+ // }
|
|
917
|
+ // service.AddSigleDrugAutoReduceRecordInfo(details)
|
|
918
|
+ // }
|
|
919
|
+ //
|
|
920
|
+ //} else if err == nil { //记录存在,则将增加数量
|
|
921
|
+ // if outInfo.ID > 0 {
|
|
922
|
+ // prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
|
923
|
+ // count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
|
924
|
+ // service.UpdateDrugStockOutInfoCount2(adminUserInfo.Org.Id, outInfo.ID, count)
|
|
925
|
+ // }
|
|
926
|
+ //
|
|
927
|
+ // //count, _ := service.FindPatientDrugAutomaticReduceRecord(adminUserInfo.Org.Id, record_time, item.DrugId, item.PatientId)
|
|
928
|
+ // //if count == 0 {
|
|
929
|
+ // prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
|
930
|
+ // count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
|
931
|
+ // details := &models.DrugAutomaticReduceDetail{
|
|
932
|
+ // WarehouseOutId: outInfo.ID,
|
|
933
|
+ // WarehouseOutOrderNumber: outInfo.WarehouseOutOrderNumber,
|
|
934
|
+ // PatientId: item.PatientId,
|
|
935
|
+ // Ctime: time.Now().Unix(),
|
|
936
|
+ // Mtime: time.Now().Unix(),
|
|
937
|
+ // Status: 1,
|
|
938
|
+ // RecordTime: record_time,
|
|
939
|
+ // OrgId: adminUserInfo.Org.Id,
|
|
940
|
+ // DrugId: item.DrugId,
|
|
941
|
+ // Count: count,
|
|
942
|
+ // }
|
|
943
|
+ // service.AddSigleDrugAutoReduceRecordInfo(details)
|
|
944
|
+ //
|
|
945
|
+ //
|
|
946
|
+ //}
|
946
|
947
|
}
|
947
|
948
|
}
|
948
|
949
|
|
|
@@ -1001,7 +1002,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
|
1001
|
1002
|
|
1002
|
1003
|
advices, _ := service.FindDoctorAdviceByIds(adminUserInfo.Org.Id, ids)
|
1003
|
1004
|
for _, item := range advices {
|
1004
|
|
- fmt.Println("item222222222222", item.ExecutionState)
|
|
1005
|
+
|
1005
|
1006
|
if item.ExecutionState == 1 && item.Way == 2 {
|
1006
|
1007
|
|
1007
|
1008
|
prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
|
@@ -1036,7 +1037,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
|
1036
|
1037
|
|
1037
|
1038
|
//查询 该患者是否已出库
|
1038
|
1039
|
out, errcode := service.GetSelfOutStock(adminUserInfo.Org.Id, item.AdviceDate, item.PatientId, item.AdviceName, item.AdviceDesc)
|
1039
|
|
- fmt.Println("errcode ------------------", errcode)
|
|
1040
|
+
|
1040
|
1041
|
if errcode == gorm.ErrRecordNotFound {
|
1041
|
1042
|
service.CreateOutStock(&outStock)
|
1042
|
1043
|
} else if errcode == nil {
|
|
@@ -1146,26 +1147,28 @@ func (c *PatientApiController) ExecDoctorAdvice() {
|
1146
|
1147
|
stockInInfo, _ := service.FindLastDrugStockInInfoRecord(advice.DrugId, adminInfo.Org.Id)
|
1147
|
1148
|
warehouseOutInfo.Price = stockInInfo.Price
|
1148
|
1149
|
err := service.AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
|
|
1150
|
+
|
1149
|
1151
|
if err == nil {
|
1150
|
|
- details := &models.DrugAutomaticReduceDetail{
|
1151
|
|
- WarehouseOutId: warehouseOutInfo.ID,
|
1152
|
|
- WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
|
1153
|
|
- PatientId: advice.PatientId,
|
1154
|
|
- Ctime: time.Now().Unix(),
|
1155
|
|
- Mtime: time.Now().Unix(),
|
1156
|
|
- Status: 1,
|
1157
|
|
- RecordTime: record_time,
|
1158
|
|
- OrgId: adminInfo.Org.Id,
|
1159
|
|
- DrugId: advice.DrugId,
|
1160
|
|
- Count: count,
|
1161
|
|
- }
|
1162
|
|
- service.AddSigleDrugAutoReduceRecordInfo(details)
|
|
1152
|
+ service.HisDrugsDelivery(adminInfo.Org.Id, &advice)
|
|
1153
|
+ //details := &models.DrugAutomaticReduceDetail{
|
|
1154
|
+ // WarehouseOutId: warehouseOutInfo.ID,
|
|
1155
|
+ // WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
|
|
1156
|
+ // PatientId: advice.PatientId,
|
|
1157
|
+ // Ctime: time.Now().Unix(),
|
|
1158
|
+ // Mtime: time.Now().Unix(),
|
|
1159
|
+ // Status: 1,
|
|
1160
|
+ // RecordTime: record_time,
|
|
1161
|
+ // OrgId: adminInfo.Org.Id,
|
|
1162
|
+ // DrugId: advice.DrugId,
|
|
1163
|
+ // Count: count,
|
|
1164
|
+ //}
|
|
1165
|
+ //service.AddSigleDrugAutoReduceRecordInfo(details)
|
1163
|
1166
|
}
|
1164
|
1167
|
}
|
1165
|
1168
|
}
|
1166
|
1169
|
|
1167
|
1170
|
} else if err == nil {
|
1168
|
|
- outInfo, err := service.FindDrugStockOutInfoByTypeId(adminInfo.Org.Id, advice.DrugId, out.ID, out.WarehouseOutOrderNumber)
|
|
1171
|
+ _, err := service.FindDrugStockOutInfoByTypeId(adminInfo.Org.Id, advice.DrugId, out.ID, out.WarehouseOutOrderNumber)
|
1169
|
1172
|
if err == gorm.ErrRecordNotFound {
|
1170
|
1173
|
warehouseOutInfo := &models.DrugWarehouseOutInfo{
|
1171
|
1174
|
WarehouseOutOrderNumber: out.WarehouseOutOrderNumber,
|
|
@@ -1189,42 +1192,44 @@ func (c *PatientApiController) ExecDoctorAdvice() {
|
1189
|
1192
|
warehouseOutInfo.Count = count
|
1190
|
1193
|
err := service.AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
|
1191
|
1194
|
if err == nil {
|
1192
|
|
- details := &models.DrugAutomaticReduceDetail{
|
1193
|
|
- WarehouseOutId: warehouseOutInfo.ID,
|
1194
|
|
- WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
|
1195
|
|
- PatientId: advice.PatientId,
|
1196
|
|
- Ctime: time.Now().Unix(),
|
1197
|
|
- Mtime: time.Now().Unix(),
|
1198
|
|
- Status: 1,
|
1199
|
|
- RecordTime: record_time,
|
1200
|
|
- OrgId: adminInfo.Org.Id,
|
1201
|
|
- DrugId: advice.DrugId,
|
1202
|
|
- Count: count,
|
1203
|
|
- }
|
1204
|
|
- service.AddSigleDrugAutoReduceRecordInfo(details)
|
|
1195
|
+ service.HisDrugsDelivery(adminInfo.Org.Id, &advice)
|
|
1196
|
+ //details := &models.DrugAutomaticReduceDetail{
|
|
1197
|
+ // WarehouseOutId: warehouseOutInfo.ID,
|
|
1198
|
+ // WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
|
|
1199
|
+ // PatientId: advice.PatientId,
|
|
1200
|
+ // Ctime: time.Now().Unix(),
|
|
1201
|
+ // Mtime: time.Now().Unix(),
|
|
1202
|
+ // Status: 1,
|
|
1203
|
+ // RecordTime: record_time,
|
|
1204
|
+ // OrgId: adminInfo.Org.Id,
|
|
1205
|
+ // DrugId: advice.DrugId,
|
|
1206
|
+ // Count: count,
|
|
1207
|
+ //}
|
|
1208
|
+ //service.AddSigleDrugAutoReduceRecordInfo(details)
|
1205
|
1209
|
}
|
1206
|
1210
|
|
1207
|
1211
|
} else if err == nil { //记录存在,则将增加数量
|
1208
|
|
- if outInfo.ID > 0 {
|
1209
|
|
- prescribingNumber := strconv.FormatFloat(math.Abs(advice.PrescribingNumber), 'f', 0, 64)
|
1210
|
|
- count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
1211
|
|
- service.UpdateDrugStockOutInfoCount2(adminInfo.Org.Id, outInfo.ID, count)
|
1212
|
|
- }
|
1213
|
|
- prescribingNumber := strconv.FormatFloat(math.Abs(advice.PrescribingNumber), 'f', 0, 64)
|
1214
|
|
- count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
1215
|
|
- details := &models.DrugAutomaticReduceDetail{
|
1216
|
|
- WarehouseOutId: outInfo.ID,
|
1217
|
|
- WarehouseOutOrderNumber: outInfo.WarehouseOutOrderNumber,
|
1218
|
|
- PatientId: advice.PatientId,
|
1219
|
|
- Ctime: time.Now().Unix(),
|
1220
|
|
- Mtime: time.Now().Unix(),
|
1221
|
|
- Status: 1,
|
1222
|
|
- RecordTime: record_time,
|
1223
|
|
- OrgId: adminInfo.Org.Id,
|
1224
|
|
- DrugId: advice.DrugId,
|
1225
|
|
- Count: count,
|
1226
|
|
- }
|
1227
|
|
- service.AddSigleDrugAutoReduceRecordInfo(details)
|
|
1212
|
+ service.HisDrugsDelivery(adminInfo.Org.Id, &advice)
|
|
1213
|
+ //if outInfo.ID > 0 {
|
|
1214
|
+ // prescribingNumber := strconv.FormatFloat(math.Abs(advice.PrescribingNumber), 'f', 0, 64)
|
|
1215
|
+ // count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
|
1216
|
+ // service.UpdateDrugStockOutInfoCount2(adminInfo.Org.Id, outInfo.ID, count)
|
|
1217
|
+ //}
|
|
1218
|
+ //prescribingNumber := strconv.FormatFloat(math.Abs(advice.PrescribingNumber), 'f', 0, 64)
|
|
1219
|
+ //count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
|
1220
|
+ //details := &models.DrugAutomaticReduceDetail{
|
|
1221
|
+ // WarehouseOutId: outInfo.ID,
|
|
1222
|
+ // WarehouseOutOrderNumber: outInfo.WarehouseOutOrderNumber,
|
|
1223
|
+ // PatientId: advice.PatientId,
|
|
1224
|
+ // Ctime: time.Now().Unix(),
|
|
1225
|
+ // Mtime: time.Now().Unix(),
|
|
1226
|
+ // Status: 1,
|
|
1227
|
+ // RecordTime: record_time,
|
|
1228
|
+ // OrgId: adminInfo.Org.Id,
|
|
1229
|
+ // DrugId: advice.DrugId,
|
|
1230
|
+ // Count: count,
|
|
1231
|
+ //}
|
|
1232
|
+ //service.AddSigleDrugAutoReduceRecordInfo(details)
|
1228
|
1233
|
}
|
1229
|
1234
|
}
|
1230
|
1235
|
}
|