|
@@ -1573,171 +1573,382 @@ func (c *PatientApiController) ExecDoctorAdvice() {
|
1573
|
1573
|
advice.ExecutionTime = theTime.Unix()
|
1574
|
1574
|
// advice.Checker = checker
|
1575
|
1575
|
|
1576
|
|
- adviceName, _ := service.FindDoctorAdvice(adminUserInfo.CurrentOrgId, id)
|
1577
|
|
- fmt.Println("adviceName", adviceName.Way)
|
1578
|
|
- timeStr := time.Now().Format("2006-01-02")
|
1579
|
|
- fmt.Println("timestr", timeStr)
|
1580
|
|
-
|
1581
|
|
- //如果医嘱已执行,生成自备药出库单
|
1582
|
|
- //来自药品库
|
1583
|
|
- if adviceName.ExecutionState == 1 && adviceName.Way == 1 {
|
1584
|
|
-
|
1585
|
|
- //查询是否开启药品库
|
1586
|
|
- stockConfig, _ := service.GetDrugStockConfig(adminUserInfo.CurrentOrgId)
|
1587
|
|
- //开启药品库
|
1588
|
|
- if stockConfig.IsOpen == 1 {
|
1589
|
|
- timeLayout := "2006-01-02"
|
1590
|
|
- loc, _ := time.LoadLocation("Local")
|
1591
|
|
- //产询今日是否存在出库单
|
1592
|
|
- timeStr := time.Now().Format("2006-01-02")
|
1593
|
|
- theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", timeStr+" 00:00:00", loc)
|
1594
|
|
- _, errcode := service.GetDrugWareseOut(theTime.Unix(), adminUserInfo.CurrentOrgId)
|
1595
|
|
- if errcode == gorm.ErrRecordNotFound {
|
|
1576
|
+ //adviceName, _ := service.FindDoctorAdvice(adminUserInfo.CurrentOrgId, id)
|
|
1577
|
+ //fmt.Println("adviceName", adviceName.Way)
|
|
1578
|
+
|
|
1579
|
+ //处理出库相关逻辑
|
|
1580
|
+
|
|
1581
|
+ //1.判断是否启用药品管理和自备药出库功能
|
|
1582
|
+
|
|
1583
|
+ //药品管理信息
|
|
1584
|
+ _, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(adminUserInfo.CurrentOrgId)
|
|
1585
|
+
|
|
1586
|
+ //自备药信息
|
|
1587
|
+ privateDrugConfig, _ := service.GetDrugSetByUserOrgId(adminUserInfo.CurrentOrgId)
|
|
1588
|
+ fmt.Println("drugStockConfig9999999999999", drugStockConfig.IsOpen)
|
|
1589
|
+ if drugStockConfig.IsOpen == 1 {
|
|
1590
|
+ adviceName, _ := service.FindDoctorAdvice(adminUserInfo.CurrentOrgId, id)
|
|
1591
|
+ //isHasWay := false //用来判断是否包含来自药品库的医嘱
|
|
1592
|
+
|
|
1593
|
+ if adviceName.Way == 1 {
|
|
1594
|
+ fmt.Println("药品库进来没有--------------------")
|
|
1595
|
+ out, err := service.FindDrugStockOutByIsSys(adminUserInfo.CurrentOrgId, 1, adviceName.RecordDate)
|
|
1596
|
+ fmt.Println("err================", err)
|
|
1597
|
+ if err == gorm.ErrRecordNotFound {
|
|
1598
|
+ //没有记录,则创建出库单
|
|
1599
|
+ timeStr := time.Now().Format("2006-01-02")
|
1596
|
1600
|
timeArr := strings.Split(timeStr, "-")
|
1597
|
1601
|
total, _ := service.FindAllDrugWarehouseOut(adminUserInfo.CurrentOrgId)
|
1598
|
|
-
|
1599
|
1602
|
total = total + 1
|
1600
|
1603
|
warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
|
1601
|
1604
|
number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
|
1602
|
1605
|
number = number + total
|
1603
|
|
- warehousing_out_order = "YPRKD" + strconv.FormatInt(number, 10)
|
1604
|
|
- //查询厂家
|
1605
|
|
- drug, _ := service.GetManufacturer(adviceName.DrugId)
|
1606
|
|
- //创建
|
1607
|
|
- warehouse := models.XtDrugWarehouse{
|
1608
|
|
- WarehousingOrder: warehousing_out_order,
|
1609
|
|
- OperationTime: theTime.Unix(),
|
1610
|
|
- Creater: adminUserInfo.AdminUser.Id,
|
1611
|
|
- OrgId: adminUserInfo.CurrentOrgId,
|
1612
|
|
- Status: 1,
|
1613
|
|
- WarehousingTime: theTime.Unix(),
|
1614
|
|
- Manufacturer: drug.Manufacturer,
|
1615
|
|
- Type: 1,
|
|
1606
|
+ warehousing_out_order = "YPCKD" + strconv.FormatInt(number, 10)
|
|
1607
|
+ creater := adminUserInfo.AdminUser.Id
|
|
1608
|
+ warehouseOut := models.DrugWarehouseOut{
|
|
1609
|
+ WarehouseOutOrderNumber: warehousing_out_order,
|
|
1610
|
+ OperationTime: time.Now().Unix(),
|
|
1611
|
+ OrgId: adminUserInfo.CurrentOrgId,
|
|
1612
|
+ Creater: creater,
|
|
1613
|
+ Ctime: time.Now().Unix(),
|
|
1614
|
+ Status: 1,
|
|
1615
|
+ WarehouseOutTime: adviceName.RecordDate,
|
|
1616
|
+ Dealer: 0,
|
|
1617
|
+ Manufacturer: 0,
|
|
1618
|
+ Type: 1,
|
|
1619
|
+ IsSys: 1,
|
|
1620
|
+ }
|
|
1621
|
+ fmt.Println("触发了梅花园")
|
|
1622
|
+ err := service.AddSigleDrugWarehouseOut(&warehouseOut)
|
|
1623
|
+ if err != nil {
|
|
1624
|
+ utils.TraceLog("创建出库单失败 err = %v", err)
|
|
1625
|
+ } else {
|
|
1626
|
+ if adviceName.Way == 1 {
|
|
1627
|
+ if adviceName.PrescribingNumber > 0 {
|
|
1628
|
+ warehouseOutInfo := &models.DrugWarehouseOutInfo{
|
|
1629
|
+ WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
|
|
1630
|
+ WarehouseOutId: warehouseOut.ID,
|
|
1631
|
+ Status: 1,
|
|
1632
|
+ Ctime: time.Now().Unix(),
|
|
1633
|
+ Remark: "",
|
|
1634
|
+ OrgId: adminUserInfo.CurrentOrgId,
|
|
1635
|
+ Type: 1,
|
|
1636
|
+ Manufacturer: 0,
|
|
1637
|
+ Dealer: 0,
|
|
1638
|
+ IsSys: 1,
|
|
1639
|
+ SysRecordTime: adviceName.RecordDate,
|
|
1640
|
+ DrugId: adviceName.DrugId,
|
|
1641
|
+ }
|
|
1642
|
+ prescribingNumber := strconv.FormatFloat(math.Abs(adviceName.PrescribingNumber), 'f', 0, 64)
|
|
1643
|
+ count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
|
1644
|
+ warehouseOutInfo.Count = count
|
|
1645
|
+ stockInInfo, _ := service.FindLastDrugStockInInfoRecord(adviceName.DrugId, adminUserInfo.CurrentOrgId)
|
|
1646
|
+ warehouseOutInfo.Price = stockInInfo.Price
|
|
1647
|
+ err := service.AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
|
|
1648
|
+ if err == nil {
|
|
1649
|
+ details := &models.DrugAutomaticReduceDetail{
|
|
1650
|
+ WarehouseOutId: warehouseOutInfo.ID,
|
|
1651
|
+ WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
|
|
1652
|
+ PatientId: adviceName.PatientId,
|
|
1653
|
+ Ctime: time.Now().Unix(),
|
|
1654
|
+ Mtime: time.Now().Unix(),
|
|
1655
|
+ Status: 1,
|
|
1656
|
+ RecordTime: adviceName.RecordDate,
|
|
1657
|
+ OrgId: adminUserInfo.CurrentOrgId,
|
|
1658
|
+ DrugId: adviceName.DrugId,
|
|
1659
|
+ Count: count,
|
|
1660
|
+ }
|
|
1661
|
+ service.AddSigleDrugAutoReduceRecordInfo(details)
|
|
1662
|
+ }
|
|
1663
|
+ }
|
|
1664
|
+ }
|
|
1665
|
+ }
|
|
1666
|
+ } else if err == nil {
|
|
1667
|
+
|
|
1668
|
+ if adviceName.Way == 1 {
|
|
1669
|
+ outInfo, err := service.FindDrugStockOutInfoByTypeId(adminUserInfo.CurrentOrgId, adviceName.DrugId, out.ID, out.WarehouseOutOrderNumber)
|
|
1670
|
+ if err == gorm.ErrRecordNotFound {
|
|
1671
|
+ warehouseOutInfo := &models.DrugWarehouseOutInfo{
|
|
1672
|
+ WarehouseOutOrderNumber: out.WarehouseOutOrderNumber,
|
|
1673
|
+ WarehouseOutId: out.ID,
|
|
1674
|
+ Status: 1,
|
|
1675
|
+ Ctime: time.Now().Unix(),
|
|
1676
|
+ Remark: "",
|
|
1677
|
+ OrgId: adminUserInfo.CurrentOrgId,
|
|
1678
|
+ Type: 1,
|
|
1679
|
+ Manufacturer: 0,
|
|
1680
|
+ Dealer: 0,
|
|
1681
|
+ IsSys: 1,
|
|
1682
|
+ SysRecordTime: adviceName.RecordDate,
|
|
1683
|
+ }
|
|
1684
|
+
|
|
1685
|
+ stockInInfo, _ := service.FindLastDrugStockInInfoRecord(adviceName.DrugId, adminUserInfo.CurrentOrgId)
|
|
1686
|
+ warehouseOutInfo.Price = stockInInfo.Price
|
|
1687
|
+ warehouseOutInfo.DrugId = adviceName.DrugId
|
|
1688
|
+ prescribingNumber := strconv.FormatFloat(math.Abs(adviceName.PrescribingNumber), 'f', 0, 64)
|
|
1689
|
+ count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
|
1690
|
+ warehouseOutInfo.Count = count
|
|
1691
|
+ err := service.AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
|
|
1692
|
+ if err == nil {
|
|
1693
|
+ details := &models.DrugAutomaticReduceDetail{
|
|
1694
|
+ WarehouseOutId: warehouseOutInfo.ID,
|
|
1695
|
+ WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
|
|
1696
|
+ PatientId: adviceName.PatientId,
|
|
1697
|
+ Ctime: time.Now().Unix(),
|
|
1698
|
+ Mtime: time.Now().Unix(),
|
|
1699
|
+ Status: 1,
|
|
1700
|
+ RecordTime: adviceName.RecordDate,
|
|
1701
|
+ OrgId: adminUserInfo.CurrentOrgId,
|
|
1702
|
+ DrugId: adviceName.DrugId,
|
|
1703
|
+ Count: count,
|
|
1704
|
+ }
|
|
1705
|
+ service.AddSigleDrugAutoReduceRecordInfo(details)
|
|
1706
|
+ }
|
|
1707
|
+
|
|
1708
|
+ } else if err == nil { //记录存在,则将增加数量
|
|
1709
|
+ if outInfo.ID > 0 {
|
|
1710
|
+ prescribingNumber := strconv.FormatFloat(math.Abs(adviceName.PrescribingNumber), 'f', 0, 64)
|
|
1711
|
+ count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
|
1712
|
+ service.UpdateDrugStockOutInfoCount2(adminUserInfo.CurrentOrgId, outInfo.ID, count)
|
|
1713
|
+ }
|
|
1714
|
+
|
|
1715
|
+ count, _ := service.FindPatientDrugAutomaticReduceRecord(adminUserInfo.CurrentOrgId, adviceName.RecordDate, adviceName.DrugId, adviceName.PatientId)
|
|
1716
|
+ if count == 0 {
|
|
1717
|
+ prescribingNumber := strconv.FormatFloat(math.Abs(adviceName.PrescribingNumber), 'f', 0, 64)
|
|
1718
|
+ count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
|
1719
|
+ details := &models.DrugAutomaticReduceDetail{
|
|
1720
|
+ WarehouseOutId: outInfo.ID,
|
|
1721
|
+ WarehouseOutOrderNumber: outInfo.WarehouseOutOrderNumber,
|
|
1722
|
+ PatientId: adviceName.PatientId,
|
|
1723
|
+ Ctime: time.Now().Unix(),
|
|
1724
|
+ Mtime: time.Now().Unix(),
|
|
1725
|
+ Status: 1,
|
|
1726
|
+ RecordTime: adviceName.RecordDate,
|
|
1727
|
+ OrgId: adminUserInfo.CurrentOrgId,
|
|
1728
|
+ DrugId: adviceName.DrugId,
|
|
1729
|
+ Count: count,
|
|
1730
|
+ }
|
|
1731
|
+ service.AddSigleDrugAutoReduceRecordInfo(details)
|
|
1732
|
+ } else if count == 1 {
|
|
1733
|
+ prescribingNumber := strconv.FormatFloat(math.Abs(adviceName.PrescribingNumber), 'f', 0, 64)
|
|
1734
|
+ count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
|
1735
|
+ service.UpdateDrugUserInfoDetails(adviceName.DrugId, adviceName.RecordDate, adminUserInfo.CurrentOrgId, adviceName.PatientId, count, &outInfo)
|
|
1736
|
+ }
|
|
1737
|
+
|
|
1738
|
+ }
|
1616
|
1739
|
}
|
1617
|
|
- service.CreateDrugWarehoue(&warehouse)
|
1618
|
|
- }
|
1619
|
1740
|
|
1620
|
|
- timeArr := strings.Split(timeStr, "-")
|
1621
|
|
- total, _ := service.FindAllDrugWarehouseOut(adminUserInfo.CurrentOrgId)
|
1622
|
|
-
|
1623
|
|
- total = total + 1
|
1624
|
|
- warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
|
1625
|
|
- number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
|
1626
|
|
- number = number + total
|
1627
|
|
- warehousing_out_order = "YPRKD" + strconv.FormatInt(number, 10)
|
1628
|
|
- drug, _ := service.GetManufacturer(adviceName.DrugId)
|
1629
|
|
- out := models.XtDrugWarehouseOut{
|
1630
|
|
- WarehouseOutOrderNumber: warehousing_out_order,
|
1631
|
|
- OperationTime: theTime.Unix(),
|
1632
|
|
- Creater: adminUserInfo.AdminUser.Id,
|
1633
|
|
- OrgId: adminUserInfo.CurrentOrgId,
|
1634
|
|
- Ctime: time.Now().Unix(),
|
1635
|
|
- Status: 1,
|
1636
|
|
- WarehouseOutTime: theTime.Unix(),
|
1637
|
|
- Manufacturer: drug.Manufacturer,
|
1638
|
|
- Type: 1,
|
1639
|
|
- IsSys: 1,
|
1640
|
|
- }
|
1641
|
|
- service.CreateDrugWareHouseOut(&out)
|
1642
|
|
-
|
1643
|
|
- //查询今日的出库单号
|
1644
|
|
- orderOut, _ := service.GetTodayWareHousringOrder(theTime.Unix(), adminUserInfo.CurrentOrgId)
|
1645
|
|
- prescribingNumber := strconv.FormatFloat(math.Abs(adviceName.PrescribingNumber), 'f', 0, 64)
|
1646
|
|
- outStoreNumber, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
1647
|
|
- timeArrs := strings.Split(timeStr, "-")
|
1648
|
|
- totals, _ := service.FindAllDrugWarehouseOut(adminUserInfo.CurrentOrgId)
|
1649
|
|
-
|
1650
|
|
- totals = totals + 1
|
1651
|
|
- warehousing_out_orders := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArrs[0] + timeArrs[1] + timeArrs[2] + "000"
|
1652
|
|
- numbers, _ := strconv.ParseInt(warehousing_out_orders, 10, 64)
|
1653
|
|
- number = numbers + totals
|
1654
|
|
- warehousing_out_order = "YPCKD" + strconv.FormatInt(numbers, 10)
|
1655
|
|
- info := models.XtDrugWarehouseOutInfo{
|
1656
|
|
- WarehouseOutId: orderOut.ID,
|
1657
|
|
- DrugId: adviceName.DrugId,
|
1658
|
|
- Count: outStoreNumber,
|
1659
|
|
- Price: drug.RetailPrice,
|
1660
|
|
- TotalPrice: drug.RetailPrice,
|
1661
|
|
- ProductDate: theTime.Unix(),
|
1662
|
|
- Ctime: time.Now().Unix(),
|
1663
|
|
- Status: 1,
|
1664
|
|
- OrgId: adminUserInfo.CurrentOrgId,
|
1665
|
|
- IsCancel: 2,
|
1666
|
|
- WarehouseOutOrderNumber: warehousing_out_order,
|
1667
|
|
- Type: 1,
|
1668
|
|
- Manufacturer: orderOut.Manufacturer,
|
1669
|
|
- IsSys: 1,
|
1670
|
|
- SysRecordTime: theTime.Unix(),
|
1671
|
|
- }
|
1672
|
|
- service.CreateWareHouseOutInfo(&info)
|
1673
|
|
-
|
1674
|
|
- timeArrss := strings.Split(timeStr, "-")
|
1675
|
|
- totalss, _ := service.FindAllDrugWarehouseOut(adminUserInfo.CurrentOrgId)
|
1676
|
|
-
|
1677
|
|
- totalss = totalss + 1
|
1678
|
|
- warehousing_out_orderss := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArrss[0] + timeArrss[1] + timeArrss[2] + "000"
|
1679
|
|
- numberss, _ := strconv.ParseInt(warehousing_out_orderss, 10, 64)
|
1680
|
|
- number = numberss + totalss
|
1681
|
|
- warehousing_out_order = "YPCKD" + strconv.FormatInt(numberss, 10)
|
1682
|
|
- detail := models.XtDrugAutomaticReduceDetail{
|
1683
|
|
- WarehouseOutOrderNumber: warehousing_out_order,
|
1684
|
|
- WarehouseOutId: orderOut.ID,
|
1685
|
|
- PatientId: adviceName.PatientId,
|
1686
|
|
- Ctime: time.Now().Unix(),
|
1687
|
|
- RecordTime: theTime.Unix(),
|
1688
|
|
- OrgId: adminUserInfo.CurrentOrgId,
|
1689
|
|
- GoodId: adviceName.DrugId,
|
1690
|
|
- Count: outStoreNumber,
|
1691
|
|
- Status: 1,
|
1692
|
1741
|
}
|
1693
|
|
- service.CreateAotoMaticReduceDetail(&detail)
|
1694
|
1742
|
}
|
1695
|
1743
|
}
|
1696
|
1744
|
|
1697
|
|
- if adviceName.ExecutionState == 1 && adviceName.Way == 2 {
|
1698
|
|
-
|
1699
|
|
- //是否开启自备药
|
1700
|
|
- medicalSet, _ := service.GetSetSelfMedical(adminUserInfo.CurrentOrgId)
|
1701
|
|
- //开启自备药,生成出库单
|
1702
|
|
- if medicalSet.DrugStart == 1 {
|
1703
|
|
- prescribingNumber := strconv.FormatFloat(math.Abs(adviceName.PrescribingNumber), 'f', 0, 64)
|
1704
|
|
- outStoreNumber, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
1705
|
|
-
|
1706
|
|
- timeStr := time.Now().Format("2006-01-02")
|
1707
|
|
- timeArr := strings.Split(timeStr, "-")
|
1708
|
|
- total, _ := service.FindAllDrugWarehouseOut(adminUserInfo.CurrentOrgId)
|
1709
|
|
-
|
1710
|
|
- total = total + 1
|
1711
|
|
- warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
|
1712
|
|
- number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
|
1713
|
|
- number = number + total
|
1714
|
|
- warehousing_out_order = "CKD" + strconv.FormatInt(number, 10)
|
1715
|
|
-
|
1716
|
|
- outStock := models.XtSelfOutStock{
|
1717
|
|
- DrugName: adviceName.AdviceName,
|
1718
|
|
- DrugSpec: adviceName.AdviceDesc,
|
1719
|
|
- OutstoreNumber: outStoreNumber,
|
1720
|
|
- AdminUserId: adminUserInfo.AdminUser.Id,
|
1721
|
|
- CreatedTime: time.Now().Unix(),
|
1722
|
|
- Status: 1,
|
1723
|
|
- PatientId: adviceName.PatientId,
|
1724
|
|
- StockOutNumber: warehousing_out_order,
|
1725
|
|
- ExitMode: 2,
|
1726
|
|
- StorckTime: adviceName.AdviceDate,
|
1727
|
|
- MedicId: adviceName.DrugId,
|
1728
|
|
- UserOrgId: adminUserInfo.CurrentOrgId,
|
|
1745
|
+ fmt.Println("222222222222", privateDrugConfig.DrugStart)
|
|
1746
|
+ adviceName, _ := service.FindDoctorAdvice(adminUserInfo.CurrentOrgId, id)
|
|
1747
|
+ if adviceName.Way == 2 {
|
|
1748
|
+ if privateDrugConfig != nil && privateDrugConfig.DrugStart == 1 {
|
|
1749
|
+ fmt.Println("进来了没有-------------------------------")
|
|
1750
|
+ adviceName, _ := service.FindDoctorAdvice(adminUserInfo.CurrentOrgId, id)
|
|
1751
|
+ fmt.Println("3333333333", adviceName.ExecutionState)
|
|
1752
|
+ if adviceName.ExecutionState == 1 {
|
|
1753
|
+ prescribingNumber := strconv.FormatFloat(math.Abs(adviceName.PrescribingNumber), 'f', 0, 64)
|
|
1754
|
+ count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
|
1755
|
+
|
|
1756
|
+ timeStr := time.Now().Format("2006-01-02")
|
|
1757
|
+ timeArr := strings.Split(timeStr, "-")
|
|
1758
|
+ total, _ := service.FindAllDrugWarehouseOut(adminUserInfo.CurrentOrgId)
|
|
1759
|
+
|
|
1760
|
+ total = total + 1
|
|
1761
|
+ warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
|
|
1762
|
+ number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
|
|
1763
|
+ number = number + total
|
|
1764
|
+ warehousing_out_order = "CKD" + strconv.FormatInt(number, 10)
|
|
1765
|
+ //插入自备药出库单
|
|
1766
|
+ outStock := models.XtSelfOutStock{
|
|
1767
|
+ DrugName: adviceName.AdviceName,
|
|
1768
|
+ DrugNameId: adviceName.DrugId,
|
|
1769
|
+ DrugSpec: adviceName.AdviceDesc,
|
|
1770
|
+ OutstoreNumber: count,
|
|
1771
|
+ AdminUserId: adminUserInfo.AdminUser.Id,
|
|
1772
|
+ StorckTime: adviceName.RecordDate,
|
|
1773
|
+ UserOrgId: adminUserInfo.CurrentOrgId,
|
|
1774
|
+ CreatedTime: time.Now().Unix(),
|
|
1775
|
+ Status: 1,
|
|
1776
|
+ PatientId: adviceName.PatientId,
|
|
1777
|
+ ExitMode: 2,
|
|
1778
|
+ MedicId: adviceName.DrugId,
|
|
1779
|
+ StockOutNumber: warehousing_out_order,
|
|
1780
|
+ }
|
|
1781
|
+ service.CreateOutStock(&outStock)
|
1729
|
1782
|
}
|
1730
|
|
- //创建出库单,自动出库
|
1731
|
|
- service.CreateOutStock(&outStock)
|
1732
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
1733
|
|
- "msg": "ok",
|
1734
|
|
- "advice": advice,
|
1735
|
|
- })
|
1736
|
|
- return
|
1737
|
1783
|
}
|
1738
|
|
-
|
1739
|
1784
|
}
|
1740
|
1785
|
|
|
1786
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1787
|
+ "msg": "ok",
|
|
1788
|
+ "advice": advice,
|
|
1789
|
+ })
|
|
1790
|
+ return
|
|
1791
|
+
|
|
1792
|
+ ////如果医嘱已执行,生成自备药出库单
|
|
1793
|
+ // //来自药品库
|
|
1794
|
+ // if adviceName.ExecutionState == 1 && adviceName.Way == 1 {
|
|
1795
|
+ //
|
|
1796
|
+ // //查询是否开启药品库
|
|
1797
|
+ // stockConfig, _ := service.GetDrugStockConfig(adminUserInfo.CurrentOrgId)
|
|
1798
|
+ // //开启药品库
|
|
1799
|
+ // if stockConfig.IsOpen == 1 {
|
|
1800
|
+ // timeLayout := "2006-01-02"
|
|
1801
|
+ // loc, _ := time.LoadLocation("Local")
|
|
1802
|
+ // //产询今日是否存在出库单
|
|
1803
|
+ // timeStr := time.Now().Format("2006-01-02")
|
|
1804
|
+ // theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", timeStr+" 00:00:00", loc)
|
|
1805
|
+ // _, errcode := service.GetDrugWareseOut(theTime.Unix(), adminUserInfo.CurrentOrgId)
|
|
1806
|
+ // if errcode == gorm.ErrRecordNotFound {
|
|
1807
|
+ // timeArr := strings.Split(timeStr, "-")
|
|
1808
|
+ // total, _ := service.FindAllDrugWarehouseOut(adminUserInfo.CurrentOrgId)
|
|
1809
|
+ //
|
|
1810
|
+ // total = total + 1
|
|
1811
|
+ // warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
|
|
1812
|
+ // number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
|
|
1813
|
+ // number = number + total
|
|
1814
|
+ // warehousing_out_order = "YPRKD" + strconv.FormatInt(number, 10)
|
|
1815
|
+ // //查询厂家
|
|
1816
|
+ // drug, _ := service.GetManufacturer(adviceName.DrugId)
|
|
1817
|
+ // //创建
|
|
1818
|
+ // warehouse := models.XtDrugWarehouse{
|
|
1819
|
+ // WarehousingOrder: warehousing_out_order,
|
|
1820
|
+ // OperationTime: theTime.Unix(),
|
|
1821
|
+ // Creater: adminUserInfo.AdminUser.Id,
|
|
1822
|
+ // OrgId: adminUserInfo.CurrentOrgId,
|
|
1823
|
+ // Status: 1,
|
|
1824
|
+ // WarehousingTime: theTime.Unix(),
|
|
1825
|
+ // Manufacturer: drug.Manufacturer,
|
|
1826
|
+ // Type: 1,
|
|
1827
|
+ // }
|
|
1828
|
+ // service.CreateDrugWarehoue(&warehouse)
|
|
1829
|
+ // }
|
|
1830
|
+ //
|
|
1831
|
+ // timeArr := strings.Split(timeStr, "-")
|
|
1832
|
+ // total, _ := service.FindAllDrugWarehouseOut(adminUserInfo.CurrentOrgId)
|
|
1833
|
+ //
|
|
1834
|
+ // total = total + 1
|
|
1835
|
+ // warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
|
|
1836
|
+ // number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
|
|
1837
|
+ // number = number + total
|
|
1838
|
+ // warehousing_out_order = "YPRKD" + strconv.FormatInt(number, 10)
|
|
1839
|
+ // drug, _ := service.GetManufacturer(adviceName.DrugId)
|
|
1840
|
+ // out := models.XtDrugWarehouseOut{
|
|
1841
|
+ // WarehouseOutOrderNumber: warehousing_out_order,
|
|
1842
|
+ // OperationTime: theTime.Unix(),
|
|
1843
|
+ // Creater: adminUserInfo.AdminUser.Id,
|
|
1844
|
+ // OrgId: adminUserInfo.CurrentOrgId,
|
|
1845
|
+ // Ctime: time.Now().Unix(),
|
|
1846
|
+ // Status: 1,
|
|
1847
|
+ // WarehouseOutTime: theTime.Unix(),
|
|
1848
|
+ // Manufacturer: drug.Manufacturer,
|
|
1849
|
+ // Type: 1,
|
|
1850
|
+ // IsSys: 1,
|
|
1851
|
+ // }
|
|
1852
|
+ // service.CreateDrugWareHouseOut(&out)
|
|
1853
|
+ //
|
|
1854
|
+ // //查询今日的出库单号
|
|
1855
|
+ // orderOut, _ := service.GetTodayWareHousringOrder(theTime.Unix(), adminUserInfo.CurrentOrgId)
|
|
1856
|
+ // prescribingNumber := strconv.FormatFloat(math.Abs(adviceName.PrescribingNumber), 'f', 0, 64)
|
|
1857
|
+ // outStoreNumber, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
|
1858
|
+ // timeArrs := strings.Split(timeStr, "-")
|
|
1859
|
+ // totals, _ := service.FindAllDrugWarehouseOut(adminUserInfo.CurrentOrgId)
|
|
1860
|
+ //
|
|
1861
|
+ // totals = totals + 1
|
|
1862
|
+ // warehousing_out_orders := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArrs[0] + timeArrs[1] + timeArrs[2] + "000"
|
|
1863
|
+ // numbers, _ := strconv.ParseInt(warehousing_out_orders, 10, 64)
|
|
1864
|
+ // number = numbers + totals
|
|
1865
|
+ // warehousing_out_order = "YPCKD" + strconv.FormatInt(numbers, 10)
|
|
1866
|
+ // info := models.XtDrugWarehouseOutInfo{
|
|
1867
|
+ // WarehouseOutId: orderOut.ID,
|
|
1868
|
+ // DrugId: adviceName.DrugId,
|
|
1869
|
+ // Count: outStoreNumber,
|
|
1870
|
+ // Price: drug.RetailPrice,
|
|
1871
|
+ // TotalPrice: drug.RetailPrice,
|
|
1872
|
+ // ProductDate: theTime.Unix(),
|
|
1873
|
+ // Ctime: time.Now().Unix(),
|
|
1874
|
+ // Status: 1,
|
|
1875
|
+ // OrgId: adminUserInfo.CurrentOrgId,
|
|
1876
|
+ // IsCancel: 2,
|
|
1877
|
+ // WarehouseOutOrderNumber: warehousing_out_order,
|
|
1878
|
+ // Type: 1,
|
|
1879
|
+ // Manufacturer: orderOut.Manufacturer,
|
|
1880
|
+ // IsSys: 1,
|
|
1881
|
+ // SysRecordTime: theTime.Unix(),
|
|
1882
|
+ // }
|
|
1883
|
+ // service.CreateWareHouseOutInfo(&info)
|
|
1884
|
+ //
|
|
1885
|
+ // timeArrss := strings.Split(timeStr, "-")
|
|
1886
|
+ // totalss, _ := service.FindAllDrugWarehouseOut(adminUserInfo.CurrentOrgId)
|
|
1887
|
+ //
|
|
1888
|
+ // totalss = totalss + 1
|
|
1889
|
+ // warehousing_out_orderss := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArrss[0] + timeArrss[1] + timeArrss[2] + "000"
|
|
1890
|
+ // numberss, _ := strconv.ParseInt(warehousing_out_orderss, 10, 64)
|
|
1891
|
+ // number = numberss + totalss
|
|
1892
|
+ // warehousing_out_order = "YPCKD" + strconv.FormatInt(numberss, 10)
|
|
1893
|
+ // detail := models.XtDrugAutomaticReduceDetail{
|
|
1894
|
+ // WarehouseOutOrderNumber: warehousing_out_order,
|
|
1895
|
+ // WarehouseOutId: orderOut.ID,
|
|
1896
|
+ // PatientId: adviceName.PatientId,
|
|
1897
|
+ // Ctime: time.Now().Unix(),
|
|
1898
|
+ // RecordTime: theTime.Unix(),
|
|
1899
|
+ // OrgId: adminUserInfo.CurrentOrgId,
|
|
1900
|
+ // GoodId: adviceName.DrugId,
|
|
1901
|
+ // Count: outStoreNumber,
|
|
1902
|
+ // Status: 1,
|
|
1903
|
+ // }
|
|
1904
|
+ // service.CreateAotoMaticReduceDetail(&detail)
|
|
1905
|
+ // }
|
|
1906
|
+ //}
|
|
1907
|
+
|
|
1908
|
+ //if adviceName.ExecutionState == 1 && adviceName.Way == 2 {
|
|
1909
|
+ //
|
|
1910
|
+ // //是否开启自备药
|
|
1911
|
+ // medicalSet, _ := service.GetSetSelfMedical(adminUserInfo.CurrentOrgId)
|
|
1912
|
+ // //开启自备药,生成出库单
|
|
1913
|
+ // if medicalSet.DrugStart == 1 {
|
|
1914
|
+ // prescribingNumber := strconv.FormatFloat(math.Abs(adviceName.PrescribingNumber), 'f', 0, 64)
|
|
1915
|
+ // outStoreNumber, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
|
1916
|
+ //
|
|
1917
|
+ // timeStr := time.Now().Format("2006-01-02")
|
|
1918
|
+ // timeArr := strings.Split(timeStr, "-")
|
|
1919
|
+ // total, _ := service.FindAllDrugWarehouseOut(adminUserInfo.CurrentOrgId)
|
|
1920
|
+ //
|
|
1921
|
+ // total = total + 1
|
|
1922
|
+ // warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
|
|
1923
|
+ // number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
|
|
1924
|
+ // number = number + total
|
|
1925
|
+ // warehousing_out_order = "CKD" + strconv.FormatInt(number, 10)
|
|
1926
|
+ //
|
|
1927
|
+ // outStock := models.XtSelfOutStock{
|
|
1928
|
+ // DrugName: adviceName.AdviceName,
|
|
1929
|
+ // DrugSpec: adviceName.AdviceDesc,
|
|
1930
|
+ // OutstoreNumber: outStoreNumber,
|
|
1931
|
+ // AdminUserId: adminUserInfo.AdminUser.Id,
|
|
1932
|
+ // CreatedTime: time.Now().Unix(),
|
|
1933
|
+ // Status: 1,
|
|
1934
|
+ // PatientId: adviceName.PatientId,
|
|
1935
|
+ // StockOutNumber: warehousing_out_order,
|
|
1936
|
+ // ExitMode: 2,
|
|
1937
|
+ // StorckTime: adviceName.AdviceDate,
|
|
1938
|
+ // MedicId: adviceName.DrugId,
|
|
1939
|
+ // UserOrgId: adminUserInfo.CurrentOrgId,
|
|
1940
|
+ // }
|
|
1941
|
+ // //创建出库单,自动出库
|
|
1942
|
+ // service.CreateOutStock(&outStock)
|
|
1943
|
+ // c.ServeSuccessJSON(map[string]interface{}{
|
|
1944
|
+ // "msg": "ok",
|
|
1945
|
+ // "advice": advice,
|
|
1946
|
+ // })
|
|
1947
|
+ // return
|
|
1948
|
+ // }
|
|
1949
|
+ //
|
|
1950
|
+ //}
|
|
1951
|
+
|
1741
|
1952
|
}
|
1742
|
1953
|
|
1743
|
1954
|
func (c *PatientApiController) CheckGroupAdvice() {
|