|
@@ -1654,400 +1654,32 @@ func (c *PatientApiController) ExecDoctorAdvice() {
|
1654
|
1654
|
privateDrugConfig, _ := service.GetDrugSetByUserOrgId(adminUserInfo.CurrentOrgId)
|
1655
|
1655
|
|
1656
|
1656
|
if drugStockConfig.IsOpen == 1 {
|
1657
|
|
- //查询已经执行的医嘱
|
1658
|
|
- //advices, _ := service.GetExecutionDoctors(adminUserInfo.CurrentOrgId, patient, id)
|
1659
|
|
- //for _, item := range advices {
|
1660
|
|
- //
|
1661
|
|
- // //调用药品出库接口
|
1662
|
|
- // //service.DrugsDelivery(item.UserOrgId, item)
|
1663
|
|
- //
|
1664
|
|
- // //if item.Way == 1 {
|
1665
|
|
- // // out, err := service.FindDrugStockOutByIsSys(adminUserInfo.CurrentOrgId, 1, item.RecordDate)
|
1666
|
|
- // // if err == gorm.ErrRecordNotFound {
|
1667
|
|
- // // //没有记录,则创建出库单
|
1668
|
|
- // // timeStr := time.Now().Format("2006-01-02")
|
1669
|
|
- // // timeArr := strings.Split(timeStr, "-")
|
1670
|
|
- // // total, _ := service.FindAllDrugWarehouseOut(adminUserInfo.CurrentOrgId)
|
1671
|
|
- // // total = total + 1
|
1672
|
|
- // // warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
|
1673
|
|
- // // number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
|
1674
|
|
- // // number = number + total
|
1675
|
|
- // // warehousing_out_order = "YPCKD" + strconv.FormatInt(number, 10)
|
1676
|
|
- // // creater := adminUserInfo.AdminUser.Id
|
1677
|
|
- // // warehouseOut := models.DrugWarehouseOut{
|
1678
|
|
- // // WarehouseOutOrderNumber: warehousing_out_order,
|
1679
|
|
- // // OperationTime: time.Now().Unix(),
|
1680
|
|
- // // OrgId: adminUserInfo.CurrentOrgId,
|
1681
|
|
- // // Creater: creater,
|
1682
|
|
- // // Ctime: time.Now().Unix(),
|
1683
|
|
- // // Status: 1,
|
1684
|
|
- // // WarehouseOutTime: item.RecordDate,
|
1685
|
|
- // // Dealer: 0,
|
1686
|
|
- // // Manufacturer: 0,
|
1687
|
|
- // // Type: 1,
|
1688
|
|
- // // IsSys: 1,
|
1689
|
|
- // // }
|
1690
|
|
- // //
|
1691
|
|
- // // err := service.AddSigleDrugWarehouseOut(&warehouseOut)
|
1692
|
|
- // // if err != nil {
|
1693
|
|
- // // utils.TraceLog("创建出库单失败 err = %v", err)
|
1694
|
|
- // // } else {
|
1695
|
|
- // // if item.Way == 1 {
|
1696
|
|
- // // if item.PrescribingNumber > 0 {
|
1697
|
|
- // // warehouseOutInfo := &models.DrugWarehouseOutInfo{
|
1698
|
|
- // // WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
|
1699
|
|
- // // WarehouseOutId: warehouseOut.ID,
|
1700
|
|
- // // Status: 1,
|
1701
|
|
- // // Ctime: time.Now().Unix(),
|
1702
|
|
- // // Remark: "",
|
1703
|
|
- // // OrgId: adminUserInfo.CurrentOrgId,
|
1704
|
|
- // // Type: 1,
|
1705
|
|
- // // Manufacturer: 0,
|
1706
|
|
- // // Dealer: 0,
|
1707
|
|
- // // IsSys: 1,
|
1708
|
|
- // // SysRecordTime: item.RecordDate,
|
1709
|
|
- // // DrugId: item.DrugId,
|
1710
|
|
- // // }
|
1711
|
|
- // // prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
1712
|
|
- // // count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
1713
|
|
- // // warehouseOutInfo.Count = count
|
1714
|
|
- // // stockInInfo, _ := service.FindLastDrugStockInInfoRecord(item.DrugId, adminUserInfo.CurrentOrgId)
|
1715
|
|
- // // warehouseOutInfo.Price = stockInInfo.Price
|
1716
|
|
- // // err := service.AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
|
1717
|
|
- // // if err == nil {
|
1718
|
|
- // // details := &models.DrugAutomaticReduceDetail{
|
1719
|
|
- // // WarehouseOutId: warehouseOutInfo.ID,
|
1720
|
|
- // // WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
|
1721
|
|
- // // PatientId: item.PatientId,
|
1722
|
|
- // // Ctime: time.Now().Unix(),
|
1723
|
|
- // // Mtime: time.Now().Unix(),
|
1724
|
|
- // // Status: 1,
|
1725
|
|
- // // RecordTime: item.RecordDate,
|
1726
|
|
- // // OrgId: adminUserInfo.CurrentOrgId,
|
1727
|
|
- // // DrugId: item.DrugId,
|
1728
|
|
- // // Count: count,
|
1729
|
|
- // // }
|
1730
|
|
- // // service.AddSigleDrugAutoReduceRecordInfo(details)
|
1731
|
|
- // // if err != nil {
|
1732
|
|
- // // utils.TraceLog("创建出库单失败 err = %v", err)
|
1733
|
|
- // // } else {
|
1734
|
|
- // // if item.Way == 1 {
|
1735
|
|
- // // if item.PrescribingNumber > 0 {
|
1736
|
|
- // // warehouseOutInfo := &models.DrugWarehouseOutInfo{
|
1737
|
|
- // // WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
|
1738
|
|
- // // WarehouseOutId: warehouseOut.ID,
|
1739
|
|
- // // Status: 1,
|
1740
|
|
- // // Ctime: time.Now().Unix(),
|
1741
|
|
- // // Remark: "",
|
1742
|
|
- // // OrgId: adminUserInfo.CurrentOrgId,
|
1743
|
|
- // // Type: 1,
|
1744
|
|
- // // Manufacturer: 0,
|
1745
|
|
- // // Dealer: 0,
|
1746
|
|
- // // IsSys: 1,
|
1747
|
|
- // // SysRecordTime: item.RecordDate,
|
1748
|
|
- // // DrugId: item.DrugId,
|
1749
|
|
- // // }
|
1750
|
|
- // // prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
1751
|
|
- // // count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
1752
|
|
- // // warehouseOutInfo.Count = count
|
1753
|
|
- // // stockInInfo, _ := service.FindLastDrugStockInInfoRecord(item.DrugId, adminUserInfo.CurrentOrgId)
|
1754
|
|
- // // warehouseOutInfo.Price = stockInInfo.Price
|
1755
|
|
- // // err := service.AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
|
1756
|
|
- // // if err == nil {
|
1757
|
|
- // // details := &models.DrugAutomaticReduceDetail{
|
1758
|
|
- // // WarehouseOutId: warehouseOutInfo.ID,
|
1759
|
|
- // // WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
|
1760
|
|
- // // PatientId: item.PatientId,
|
1761
|
|
- // // Ctime: time.Now().Unix(),
|
1762
|
|
- // // Mtime: time.Now().Unix(),
|
1763
|
|
- // // Status: 1,
|
1764
|
|
- // // RecordTime: item.RecordDate,
|
1765
|
|
- // // OrgId: adminUserInfo.CurrentOrgId,
|
1766
|
|
- // // DrugId: item.DrugId,
|
1767
|
|
- // // Count: count,
|
1768
|
|
- // // }
|
1769
|
|
- // // service.AddSigleDrugAutoReduceRecordInfo(details)
|
1770
|
|
- // // }
|
1771
|
|
- // // }
|
1772
|
|
- // // }
|
1773
|
|
- // // }
|
1774
|
|
- // //
|
1775
|
|
- // // }
|
1776
|
|
- // // }
|
1777
|
|
- // // }
|
1778
|
|
- // // }
|
1779
|
|
- // // } else if err == nil {
|
1780
|
|
- // // if item.Way == 1 {
|
1781
|
|
- // // outInfo, err := service.FindDrugStockOutInfoByTypeId(adminUserInfo.CurrentOrgId, item.DrugId, out.ID, out.WarehouseOutOrderNumber)
|
1782
|
|
- // // if err == gorm.ErrRecordNotFound {
|
1783
|
|
- // // warehouseOutInfo := &models.DrugWarehouseOutInfo{
|
1784
|
|
- // // WarehouseOutOrderNumber: out.WarehouseOutOrderNumber,
|
1785
|
|
- // // WarehouseOutId: out.ID,
|
1786
|
|
- // // Status: 1,
|
1787
|
|
- // // Ctime: time.Now().Unix(),
|
1788
|
|
- // // Remark: "",
|
1789
|
|
- // // OrgId: adminUserInfo.CurrentOrgId,
|
1790
|
|
- // // Type: 1,
|
1791
|
|
- // // Manufacturer: 0,
|
1792
|
|
- // // Dealer: 0,
|
1793
|
|
- // // IsSys: 1,
|
1794
|
|
- // // SysRecordTime: item.RecordDate,
|
1795
|
|
- // // }
|
1796
|
|
- // //
|
1797
|
|
- // // stockInInfo, _ := service.FindLastDrugStockInInfoRecord(item.DrugId, adminUserInfo.CurrentOrgId)
|
1798
|
|
- // // warehouseOutInfo.Price = stockInInfo.Price
|
1799
|
|
- // // warehouseOutInfo.DrugId = item.DrugId
|
1800
|
|
- // // prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
1801
|
|
- // // count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
1802
|
|
- // // warehouseOutInfo.Count = count
|
1803
|
|
- // // err := service.AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
|
1804
|
|
- // // if err == nil {
|
1805
|
|
- // // details := &models.DrugAutomaticReduceDetail{
|
1806
|
|
- // // WarehouseOutId: warehouseOutInfo.ID,
|
1807
|
|
- // // WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
|
1808
|
|
- // // PatientId: item.PatientId,
|
1809
|
|
- // // Ctime: time.Now().Unix(),
|
1810
|
|
- // // Mtime: time.Now().Unix(),
|
1811
|
|
- // // Status: 1,
|
1812
|
|
- // // RecordTime: item.RecordDate,
|
1813
|
|
- // // OrgId: adminUserInfo.CurrentOrgId,
|
1814
|
|
- // // DrugId: item.DrugId,
|
1815
|
|
- // // Count: count,
|
1816
|
|
- // // }
|
1817
|
|
- // // service.AddSigleDrugAutoReduceRecordInfo(details)
|
1818
|
|
- // // }
|
1819
|
|
- // //
|
1820
|
|
- // // } else if err == nil { //记录存在,则将增加数量
|
1821
|
|
- // // if outInfo.ID > 0 {
|
1822
|
|
- // // prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
1823
|
|
- // // count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
1824
|
|
- // // service.UpdateDrugStockOutInfoCount2(adminUserInfo.CurrentOrgId, outInfo.ID, count)
|
1825
|
|
- // // }
|
1826
|
|
- // //
|
1827
|
|
- // // count, _ := service.FindPatientDrugAutomaticReduceRecord(adminUserInfo.CurrentOrgId, item.RecordDate, item.DrugId, item.PatientId)
|
1828
|
|
- // // if count == 0 {
|
1829
|
|
- // // prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
1830
|
|
- // // count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
1831
|
|
- // // details := &models.DrugAutomaticReduceDetail{
|
1832
|
|
- // // WarehouseOutId: outInfo.ID,
|
1833
|
|
- // // WarehouseOutOrderNumber: outInfo.WarehouseOutOrderNumber,
|
1834
|
|
- // // PatientId: item.PatientId,
|
1835
|
|
- // // Ctime: time.Now().Unix(),
|
1836
|
|
- // // Mtime: time.Now().Unix(),
|
1837
|
|
- // // Status: 1,
|
1838
|
|
- // // RecordTime: item.RecordDate,
|
1839
|
|
- // // OrgId: adminUserInfo.CurrentOrgId,
|
1840
|
|
- // // DrugId: item.DrugId,
|
1841
|
|
- // // Count: count,
|
1842
|
|
- // // }
|
1843
|
|
- // // service.AddSigleDrugAutoReduceRecordInfo(details)
|
1844
|
|
- // // } else if count == 1 {
|
1845
|
|
- // // prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
1846
|
|
- // // count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
1847
|
|
- // // service.UpdateDrugUserInfoDetails(item.DrugId, item.RecordDate, adminUserInfo.CurrentOrgId, item.PatientId, count, &outInfo)
|
1848
|
|
- // // }
|
1849
|
|
- // //
|
1850
|
|
- // // }
|
1851
|
|
- // // }
|
1852
|
|
- // // }
|
1853
|
|
- // //}
|
1854
|
|
- //}
|
|
1657
|
+
|
1855
|
1658
|
advices, _ := service.GetExecutionDoctors(adminUserInfo.CurrentOrgId, patient, id)
|
1856
|
1659
|
for _, item := range advices {
|
1857
|
1660
|
fmt.Println("imte00000000000000", item.PrescribingNumber)
|
|
1661
|
+
|
|
1662
|
+ //查询该药品是否有库存
|
|
1663
|
+ list, _ := service.GetDrugTotalCount(item.DrugId, item.UserOrgId)
|
|
1664
|
+ prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
|
1665
|
+ count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
|
|
1666
|
+ if list.Count == 0 {
|
|
1667
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1668
|
+ "msg": "1",
|
|
1669
|
+ "advice": advice,
|
|
1670
|
+ })
|
|
1671
|
+ return
|
|
1672
|
+ }
|
|
1673
|
+ if count > list.Count {
|
|
1674
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1675
|
+ "msg": "2",
|
|
1676
|
+ "advice": advice,
|
|
1677
|
+ })
|
|
1678
|
+ return
|
|
1679
|
+ }
|
1858
|
1680
|
//调用药品出库接口
|
1859
|
1681
|
service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
|
1860
|
1682
|
|
1861
|
|
- //if item.Way == 1 {
|
1862
|
|
- // out, err := service.FindDrugStockOutByIsSys(adminUserInfo.CurrentOrgId, 1, item.RecordDate)
|
1863
|
|
- // if err == gorm.ErrRecordNotFound {
|
1864
|
|
- // //没有记录,则创建出库单
|
1865
|
|
- // timeStr := time.Now().Format("2006-01-02")
|
1866
|
|
- // timeArr := strings.Split(timeStr, "-")
|
1867
|
|
- // total, _ := service.FindAllDrugWarehouseOut(adminUserInfo.CurrentOrgId)
|
1868
|
|
- // total = total + 1
|
1869
|
|
- // warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
|
1870
|
|
- // number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
|
1871
|
|
- // number = number + total
|
1872
|
|
- // warehousing_out_order = "YPCKD" + strconv.FormatInt(number, 10)
|
1873
|
|
- // creater := adminUserInfo.AdminUser.Id
|
1874
|
|
- // warehouseOut := models.DrugWarehouseOut{
|
1875
|
|
- // WarehouseOutOrderNumber: warehousing_out_order,
|
1876
|
|
- // OperationTime: time.Now().Unix(),
|
1877
|
|
- // OrgId: adminUserInfo.CurrentOrgId,
|
1878
|
|
- // Creater: creater,
|
1879
|
|
- // Ctime: time.Now().Unix(),
|
1880
|
|
- // Status: 1,
|
1881
|
|
- // WarehouseOutTime: item.RecordDate,
|
1882
|
|
- // Dealer: 0,
|
1883
|
|
- // Manufacturer: 0,
|
1884
|
|
- // Type: 1,
|
1885
|
|
- // IsSys: 1,
|
1886
|
|
- // }
|
1887
|
|
- //
|
1888
|
|
- // err := service.AddSigleDrugWarehouseOut(&warehouseOut)
|
1889
|
|
- // if err != nil {
|
1890
|
|
- // utils.TraceLog("创建出库单失败 err = %v", err)
|
1891
|
|
- // } else {
|
1892
|
|
- // if item.Way == 1 {
|
1893
|
|
- // if item.PrescribingNumber > 0 {
|
1894
|
|
- // warehouseOutInfo := &models.DrugWarehouseOutInfo{
|
1895
|
|
- // WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
|
1896
|
|
- // WarehouseOutId: warehouseOut.ID,
|
1897
|
|
- // Status: 1,
|
1898
|
|
- // Ctime: time.Now().Unix(),
|
1899
|
|
- // Remark: "",
|
1900
|
|
- // OrgId: adminUserInfo.CurrentOrgId,
|
1901
|
|
- // Type: 1,
|
1902
|
|
- // Manufacturer: 0,
|
1903
|
|
- // Dealer: 0,
|
1904
|
|
- // IsSys: 1,
|
1905
|
|
- // SysRecordTime: item.RecordDate,
|
1906
|
|
- // DrugId: item.DrugId,
|
1907
|
|
- // }
|
1908
|
|
- // prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
1909
|
|
- // count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
1910
|
|
- // warehouseOutInfo.Count = count
|
1911
|
|
- // stockInInfo, _ := service.FindLastDrugStockInInfoRecord(item.DrugId, adminUserInfo.CurrentOrgId)
|
1912
|
|
- // warehouseOutInfo.Price = stockInInfo.Price
|
1913
|
|
- // err := service.AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
|
1914
|
|
- // if err == nil {
|
1915
|
|
- // details := &models.DrugAutomaticReduceDetail{
|
1916
|
|
- // WarehouseOutId: warehouseOutInfo.ID,
|
1917
|
|
- // WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
|
1918
|
|
- // PatientId: item.PatientId,
|
1919
|
|
- // Ctime: time.Now().Unix(),
|
1920
|
|
- // Mtime: time.Now().Unix(),
|
1921
|
|
- // Status: 1,
|
1922
|
|
- // RecordTime: item.RecordDate,
|
1923
|
|
- // OrgId: adminUserInfo.CurrentOrgId,
|
1924
|
|
- // DrugId: item.DrugId,
|
1925
|
|
- // Count: count,
|
1926
|
|
- // }
|
1927
|
|
- // service.AddSigleDrugAutoReduceRecordInfo(details)
|
1928
|
|
- // if err != nil {
|
1929
|
|
- // utils.TraceLog("创建出库单失败 err = %v", err)
|
1930
|
|
- // } else {
|
1931
|
|
- // if item.Way == 1 {
|
1932
|
|
- // if item.PrescribingNumber > 0 {
|
1933
|
|
- // warehouseOutInfo := &models.DrugWarehouseOutInfo{
|
1934
|
|
- // WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
|
1935
|
|
- // WarehouseOutId: warehouseOut.ID,
|
1936
|
|
- // Status: 1,
|
1937
|
|
- // Ctime: time.Now().Unix(),
|
1938
|
|
- // Remark: "",
|
1939
|
|
- // OrgId: adminUserInfo.CurrentOrgId,
|
1940
|
|
- // Type: 1,
|
1941
|
|
- // Manufacturer: 0,
|
1942
|
|
- // Dealer: 0,
|
1943
|
|
- // IsSys: 1,
|
1944
|
|
- // SysRecordTime: item.RecordDate,
|
1945
|
|
- // DrugId: item.DrugId,
|
1946
|
|
- // }
|
1947
|
|
- // prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
1948
|
|
- // count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
1949
|
|
- // warehouseOutInfo.Count = count
|
1950
|
|
- // stockInInfo, _ := service.FindLastDrugStockInInfoRecord(item.DrugId, adminUserInfo.CurrentOrgId)
|
1951
|
|
- // warehouseOutInfo.Price = stockInInfo.Price
|
1952
|
|
- // err := service.AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
|
1953
|
|
- // if err == nil {
|
1954
|
|
- // details := &models.DrugAutomaticReduceDetail{
|
1955
|
|
- // WarehouseOutId: warehouseOutInfo.ID,
|
1956
|
|
- // WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
|
1957
|
|
- // PatientId: item.PatientId,
|
1958
|
|
- // Ctime: time.Now().Unix(),
|
1959
|
|
- // Mtime: time.Now().Unix(),
|
1960
|
|
- // Status: 1,
|
1961
|
|
- // RecordTime: item.RecordDate,
|
1962
|
|
- // OrgId: adminUserInfo.CurrentOrgId,
|
1963
|
|
- // DrugId: item.DrugId,
|
1964
|
|
- // Count: count,
|
1965
|
|
- // }
|
1966
|
|
- // service.AddSigleDrugAutoReduceRecordInfo(details)
|
1967
|
|
- // }
|
1968
|
|
- // }
|
1969
|
|
- // }
|
1970
|
|
- // }
|
1971
|
|
- //
|
1972
|
|
- // }
|
1973
|
|
- // }
|
1974
|
|
- // }
|
1975
|
|
- // }
|
1976
|
|
- // } else if err == nil {
|
1977
|
|
- // if item.Way == 1 {
|
1978
|
|
- // outInfo, err := service.FindDrugStockOutInfoByTypeId(adminUserInfo.CurrentOrgId, item.DrugId, out.ID, out.WarehouseOutOrderNumber)
|
1979
|
|
- // if err == gorm.ErrRecordNotFound {
|
1980
|
|
- // warehouseOutInfo := &models.DrugWarehouseOutInfo{
|
1981
|
|
- // WarehouseOutOrderNumber: out.WarehouseOutOrderNumber,
|
1982
|
|
- // WarehouseOutId: out.ID,
|
1983
|
|
- // Status: 1,
|
1984
|
|
- // Ctime: time.Now().Unix(),
|
1985
|
|
- // Remark: "",
|
1986
|
|
- // OrgId: adminUserInfo.CurrentOrgId,
|
1987
|
|
- // Type: 1,
|
1988
|
|
- // Manufacturer: 0,
|
1989
|
|
- // Dealer: 0,
|
1990
|
|
- // IsSys: 1,
|
1991
|
|
- // SysRecordTime: item.RecordDate,
|
1992
|
|
- // }
|
1993
|
|
- //
|
1994
|
|
- // stockInInfo, _ := service.FindLastDrugStockInInfoRecord(item.DrugId, adminUserInfo.CurrentOrgId)
|
1995
|
|
- // warehouseOutInfo.Price = stockInInfo.Price
|
1996
|
|
- // warehouseOutInfo.DrugId = item.DrugId
|
1997
|
|
- // prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
1998
|
|
- // count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
1999
|
|
- // warehouseOutInfo.Count = count
|
2000
|
|
- // err := service.AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
|
2001
|
|
- // if err == nil {
|
2002
|
|
- // details := &models.DrugAutomaticReduceDetail{
|
2003
|
|
- // WarehouseOutId: warehouseOutInfo.ID,
|
2004
|
|
- // WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
|
2005
|
|
- // PatientId: item.PatientId,
|
2006
|
|
- // Ctime: time.Now().Unix(),
|
2007
|
|
- // Mtime: time.Now().Unix(),
|
2008
|
|
- // Status: 1,
|
2009
|
|
- // RecordTime: item.RecordDate,
|
2010
|
|
- // OrgId: adminUserInfo.CurrentOrgId,
|
2011
|
|
- // DrugId: item.DrugId,
|
2012
|
|
- // Count: count,
|
2013
|
|
- // }
|
2014
|
|
- // service.AddSigleDrugAutoReduceRecordInfo(details)
|
2015
|
|
- // }
|
2016
|
|
- //
|
2017
|
|
- // } else if err == nil { //记录存在,则将增加数量
|
2018
|
|
- // if outInfo.ID > 0 {
|
2019
|
|
- // prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
2020
|
|
- // count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
2021
|
|
- // service.UpdateDrugStockOutInfoCount2(adminUserInfo.CurrentOrgId, outInfo.ID, count)
|
2022
|
|
- // }
|
2023
|
|
- //
|
2024
|
|
- // count, _ := service.FindPatientDrugAutomaticReduceRecord(adminUserInfo.CurrentOrgId, item.RecordDate, item.DrugId, item.PatientId)
|
2025
|
|
- // if count == 0 {
|
2026
|
|
- // prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
2027
|
|
- // count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
2028
|
|
- // details := &models.DrugAutomaticReduceDetail{
|
2029
|
|
- // WarehouseOutId: outInfo.ID,
|
2030
|
|
- // WarehouseOutOrderNumber: outInfo.WarehouseOutOrderNumber,
|
2031
|
|
- // PatientId: item.PatientId,
|
2032
|
|
- // Ctime: time.Now().Unix(),
|
2033
|
|
- // Mtime: time.Now().Unix(),
|
2034
|
|
- // Status: 1,
|
2035
|
|
- // RecordTime: item.RecordDate,
|
2036
|
|
- // OrgId: adminUserInfo.CurrentOrgId,
|
2037
|
|
- // DrugId: item.DrugId,
|
2038
|
|
- // Count: count,
|
2039
|
|
- // }
|
2040
|
|
- // service.AddSigleDrugAutoReduceRecordInfo(details)
|
2041
|
|
- // } else if count == 1 {
|
2042
|
|
- // prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
2043
|
|
- // count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
2044
|
|
- // service.UpdateDrugUserInfoDetails(item.DrugId, item.RecordDate, adminUserInfo.CurrentOrgId, item.PatientId, count, &outInfo)
|
2045
|
|
- // }
|
2046
|
|
- //
|
2047
|
|
- // }
|
2048
|
|
- // }
|
2049
|
|
- // }
|
2050
|
|
- //}
|
2051
|
1683
|
}
|
2052
|
1684
|
}
|
2053
|
1685
|
|
|
@@ -2179,191 +1811,25 @@ func (c *PatientApiController) ExecDoctorAdvice() {
|
2179
|
1811
|
//查询已经执行的医嘱
|
2180
|
1812
|
advices, _ := service.GetHisExecutionDoctors(adminUserInfo.CurrentOrgId, patient, id)
|
2181
|
1813
|
for _, item := range advices {
|
2182
|
|
-
|
|
1814
|
+ //查询该药品是否有库存
|
|
1815
|
+ list, _ := service.GetDrugTotalCount(item.DrugId, item.UserOrgId)
|
|
1816
|
+ prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
|
1817
|
+ count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
|
|
1818
|
+ if list.Count == 0 {
|
|
1819
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1820
|
+ "msg": "1",
|
|
1821
|
+ "advice": advice,
|
|
1822
|
+ })
|
|
1823
|
+ return
|
|
1824
|
+ }
|
|
1825
|
+ if count > list.Count {
|
|
1826
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1827
|
+ "msg": "2",
|
|
1828
|
+ "advice": advice,
|
|
1829
|
+ })
|
|
1830
|
+ return
|
|
1831
|
+ }
|
2183
|
1832
|
service.HisDrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
|
2184
|
|
-
|
2185
|
|
- //out, err := service.FindDrugStockOutByIsSys(adminUserInfo.CurrentOrgId, 1, item.RecordDate)
|
2186
|
|
- //if err == gorm.ErrRecordNotFound {
|
2187
|
|
- // //没有记录,则创建出库单
|
2188
|
|
- // timeStr := time.Now().Format("2006-01-02")
|
2189
|
|
- // timeArr := strings.Split(timeStr, "-")
|
2190
|
|
- // total, _ := service.FindAllDrugWarehouseOut(adminUserInfo.CurrentOrgId)
|
2191
|
|
- // total = total + 1
|
2192
|
|
- // warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
|
2193
|
|
- // number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
|
2194
|
|
- // number = number + total
|
2195
|
|
- // warehousing_out_order = "YPCKD" + strconv.FormatInt(number, 10)
|
2196
|
|
- // creater := adminUserInfo.AdminUser.Id
|
2197
|
|
- // warehouseOut := models.DrugWarehouseOut{
|
2198
|
|
- // WarehouseOutOrderNumber: warehousing_out_order,
|
2199
|
|
- // OperationTime: time.Now().Unix(),
|
2200
|
|
- // OrgId: adminUserInfo.CurrentOrgId,
|
2201
|
|
- // Creater: creater,
|
2202
|
|
- // Ctime: time.Now().Unix(),
|
2203
|
|
- // Status: 1,
|
2204
|
|
- // WarehouseOutTime: item.RecordDate,
|
2205
|
|
- // Dealer: 0,
|
2206
|
|
- // Manufacturer: 0,
|
2207
|
|
- // Type: 1,
|
2208
|
|
- // IsSys: 1,
|
2209
|
|
- // }
|
2210
|
|
- //
|
2211
|
|
- // err := service.AddSigleDrugWarehouseOut(&warehouseOut)
|
2212
|
|
- // if err != nil {
|
2213
|
|
- // utils.TraceLog("创建出库单失败 err = %v", err)
|
2214
|
|
- // } else {
|
2215
|
|
- // if item.PrescribingNumber > 0 {
|
2216
|
|
- // warehouseOutInfo := &models.DrugWarehouseOutInfo{
|
2217
|
|
- // WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
|
2218
|
|
- // WarehouseOutId: warehouseOut.ID,
|
2219
|
|
- // Status: 1,
|
2220
|
|
- // Ctime: time.Now().Unix(),
|
2221
|
|
- // Remark: "",
|
2222
|
|
- // OrgId: adminUserInfo.CurrentOrgId,
|
2223
|
|
- // Type: 1,
|
2224
|
|
- // Manufacturer: 0,
|
2225
|
|
- // Dealer: 0,
|
2226
|
|
- // IsSys: 1,
|
2227
|
|
- // SysRecordTime: item.RecordDate,
|
2228
|
|
- // DrugId: item.DrugId,
|
2229
|
|
- // }
|
2230
|
|
- // prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
2231
|
|
- // count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
2232
|
|
- // warehouseOutInfo.Count = count
|
2233
|
|
- // stockInInfo, _ := service.FindLastDrugStockInInfoRecord(item.DrugId, adminUserInfo.CurrentOrgId)
|
2234
|
|
- // warehouseOutInfo.Price = stockInInfo.Price
|
2235
|
|
- // err := service.AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
|
2236
|
|
- // if err == nil {
|
2237
|
|
- // details := &models.DrugAutomaticReduceDetail{
|
2238
|
|
- // WarehouseOutId: warehouseOutInfo.ID,
|
2239
|
|
- // WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
|
2240
|
|
- // PatientId: item.PatientId,
|
2241
|
|
- // Ctime: time.Now().Unix(),
|
2242
|
|
- // Mtime: time.Now().Unix(),
|
2243
|
|
- // Status: 1,
|
2244
|
|
- // RecordTime: item.RecordDate,
|
2245
|
|
- // OrgId: adminUserInfo.CurrentOrgId,
|
2246
|
|
- // DrugId: item.DrugId,
|
2247
|
|
- // Count: count,
|
2248
|
|
- // }
|
2249
|
|
- // service.AddSigleDrugAutoReduceRecordInfo(details)
|
2250
|
|
- // if err != nil {
|
2251
|
|
- // utils.TraceLog("创建出库单失败 err = %v", err)
|
2252
|
|
- // } else {
|
2253
|
|
- // if item.PrescribingNumber > 0 {
|
2254
|
|
- // warehouseOutInfo := &models.DrugWarehouseOutInfo{
|
2255
|
|
- // WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
|
2256
|
|
- // WarehouseOutId: warehouseOut.ID,
|
2257
|
|
- // Status: 1,
|
2258
|
|
- // Ctime: time.Now().Unix(),
|
2259
|
|
- // Remark: "",
|
2260
|
|
- // OrgId: adminUserInfo.CurrentOrgId,
|
2261
|
|
- // Type: 1,
|
2262
|
|
- // Manufacturer: 0,
|
2263
|
|
- // Dealer: 0,
|
2264
|
|
- // IsSys: 1,
|
2265
|
|
- // SysRecordTime: item.RecordDate,
|
2266
|
|
- // DrugId: item.DrugId,
|
2267
|
|
- // }
|
2268
|
|
- // prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
2269
|
|
- // count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
2270
|
|
- // warehouseOutInfo.Count = count
|
2271
|
|
- // stockInInfo, _ := service.FindLastDrugStockInInfoRecord(item.DrugId, adminUserInfo.CurrentOrgId)
|
2272
|
|
- // warehouseOutInfo.Price = stockInInfo.Price
|
2273
|
|
- // err := service.AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
|
2274
|
|
- // if err == nil {
|
2275
|
|
- // details := &models.DrugAutomaticReduceDetail{
|
2276
|
|
- // WarehouseOutId: warehouseOutInfo.ID,
|
2277
|
|
- // WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
|
2278
|
|
- // PatientId: item.PatientId,
|
2279
|
|
- // Ctime: time.Now().Unix(),
|
2280
|
|
- // Mtime: time.Now().Unix(),
|
2281
|
|
- // Status: 1,
|
2282
|
|
- // RecordTime: item.RecordDate,
|
2283
|
|
- // OrgId: adminUserInfo.CurrentOrgId,
|
2284
|
|
- // DrugId: item.DrugId,
|
2285
|
|
- // Count: count,
|
2286
|
|
- // }
|
2287
|
|
- // service.AddSigleDrugAutoReduceRecordInfo(details)
|
2288
|
|
- // }
|
2289
|
|
- // }
|
2290
|
|
- // }
|
2291
|
|
- //
|
2292
|
|
- // }
|
2293
|
|
- // }
|
2294
|
|
- // }
|
2295
|
|
- //} else if err == nil {
|
2296
|
|
- // outInfo, err := service.FindDrugStockOutInfoByTypeId(adminUserInfo.CurrentOrgId, item.DrugId, out.ID, out.WarehouseOutOrderNumber)
|
2297
|
|
- // if err == gorm.ErrRecordNotFound {
|
2298
|
|
- // warehouseOutInfo := &models.DrugWarehouseOutInfo{
|
2299
|
|
- // WarehouseOutOrderNumber: out.WarehouseOutOrderNumber,
|
2300
|
|
- // WarehouseOutId: out.ID,
|
2301
|
|
- // Status: 1,
|
2302
|
|
- // Ctime: time.Now().Unix(),
|
2303
|
|
- // Remark: "",
|
2304
|
|
- // OrgId: adminUserInfo.CurrentOrgId,
|
2305
|
|
- // Type: 1,
|
2306
|
|
- // Manufacturer: 0,
|
2307
|
|
- // Dealer: 0,
|
2308
|
|
- // IsSys: 1,
|
2309
|
|
- // SysRecordTime: item.RecordDate,
|
2310
|
|
- // }
|
2311
|
|
- //
|
2312
|
|
- // stockInInfo, _ := service.FindLastDrugStockInInfoRecord(item.DrugId, adminUserInfo.CurrentOrgId)
|
2313
|
|
- // warehouseOutInfo.Price = stockInInfo.Price
|
2314
|
|
- // warehouseOutInfo.DrugId = item.DrugId
|
2315
|
|
- // prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
2316
|
|
- // count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
2317
|
|
- // warehouseOutInfo.Count = count
|
2318
|
|
- // err := service.AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
|
2319
|
|
- // if err == nil {
|
2320
|
|
- // details := &models.DrugAutomaticReduceDetail{
|
2321
|
|
- // WarehouseOutId: warehouseOutInfo.ID,
|
2322
|
|
- // WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
|
2323
|
|
- // PatientId: item.PatientId,
|
2324
|
|
- // Ctime: time.Now().Unix(),
|
2325
|
|
- // Mtime: time.Now().Unix(),
|
2326
|
|
- // Status: 1,
|
2327
|
|
- // RecordTime: item.RecordDate,
|
2328
|
|
- // OrgId: adminUserInfo.CurrentOrgId,
|
2329
|
|
- // DrugId: item.DrugId,
|
2330
|
|
- // Count: count,
|
2331
|
|
- // }
|
2332
|
|
- // service.AddSigleDrugAutoReduceRecordInfo(details)
|
2333
|
|
- // }
|
2334
|
|
- //
|
2335
|
|
- // } else if err == nil { //记录存在,则将增加数量
|
2336
|
|
- // if outInfo.ID > 0 {
|
2337
|
|
- // prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
2338
|
|
- // count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
2339
|
|
- // service.UpdateDrugStockOutInfoCount2(adminUserInfo.CurrentOrgId, outInfo.ID, count)
|
2340
|
|
- // }
|
2341
|
|
- //
|
2342
|
|
- // count, _ := service.FindPatientDrugAutomaticReduceRecord(adminUserInfo.CurrentOrgId, item.RecordDate, item.DrugId, item.PatientId)
|
2343
|
|
- // if count == 0 {
|
2344
|
|
- // prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
2345
|
|
- // count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
2346
|
|
- // details := &models.DrugAutomaticReduceDetail{
|
2347
|
|
- // WarehouseOutId: outInfo.ID,
|
2348
|
|
- // WarehouseOutOrderNumber: outInfo.WarehouseOutOrderNumber,
|
2349
|
|
- // PatientId: item.PatientId,
|
2350
|
|
- // Ctime: time.Now().Unix(),
|
2351
|
|
- // Mtime: time.Now().Unix(),
|
2352
|
|
- // Status: 1,
|
2353
|
|
- // RecordTime: item.RecordDate,
|
2354
|
|
- // OrgId: adminUserInfo.CurrentOrgId,
|
2355
|
|
- // DrugId: item.DrugId,
|
2356
|
|
- // Count: count,
|
2357
|
|
- // }
|
2358
|
|
- // service.AddSigleDrugAutoReduceRecordInfo(details)
|
2359
|
|
- // } else if count == 1 {
|
2360
|
|
- // prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
2361
|
|
- // count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
2362
|
|
- // service.UpdateDrugUserInfoDetails(item.DrugId, item.RecordDate, adminUserInfo.CurrentOrgId, item.PatientId, count, &outInfo)
|
2363
|
|
- // }
|
2364
|
|
- //
|
2365
|
|
- // }
|
2366
|
|
- //}
|
2367
|
1833
|
}
|
2368
|
1834
|
}
|
2369
|
1835
|
c.ServeSuccessJSON(map[string]interface{}{
|