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