|
@@ -813,6 +813,7 @@ func BloodDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *
|
813
|
813
|
}
|
814
|
814
|
|
815
|
815
|
//如果本次出库数据大于历史出库数据 新增1条流水
|
|
816
|
+
|
816
|
817
|
if deliver_number > (out_count - cancel_count) {
|
817
|
818
|
drugflow := models.DrugFlow{
|
818
|
819
|
WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
|
|
@@ -1262,7 +1263,7 @@ func BloodDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *
|
1262
|
1263
|
}
|
1263
|
1264
|
|
1264
|
1265
|
// 药品自动出库 递归方式
|
1265
|
|
-func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *models.DrugWarehouseOut, drup *models.BaseDrugLib, advice *models.HisDoctorAdviceInfo) (err error) {
|
|
1266
|
+func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *models.DrugWarehouseOut, drup *models.BaseDrugLib, advice *models.HisDoctorAdviceInfo, hisprescribingNumber float64) (err error) {
|
1266
|
1267
|
|
1267
|
1268
|
drugError := models.XtDrugError{
|
1268
|
1269
|
UserOrgId: orgID,
|
|
@@ -1280,11 +1281,15 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
|
1280
|
1281
|
CreateDrugError(drugError)
|
1281
|
1282
|
// 判断处方里药品单位是拆零单位还是包装单位, 如果是包装单位,则根据规格,将包装数量转为拆零数量
|
1282
|
1283
|
var deliver_number int64 = 0
|
|
1284
|
+ var deliver_number_one int64 = 0
|
1283
|
1285
|
var stock_number int64 = 0
|
1284
|
1286
|
|
1285
|
1287
|
prescribingNumber_temp := strconv.FormatFloat(math.Abs(prescribingNumber), 'f', 0, 64)
|
1286
|
1288
|
count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
|
1287
|
1289
|
|
|
1290
|
+ prescribingNumber_temp_one := strconv.FormatFloat(math.Abs(hisprescribingNumber), 'f', 0, 64)
|
|
1291
|
+ countone, _ := strconv.ParseInt(prescribingNumber_temp_one, 10, 64)
|
|
1292
|
+
|
1288
|
1293
|
var drug_price float64
|
1289
|
1294
|
if advice.PrescribingNumberUnit == drup.MaxUnit {
|
1290
|
1295
|
deliver_number = count * drup.MinNumber
|
|
@@ -1294,6 +1299,16 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
|
1294
|
1299
|
|
1295
|
1300
|
}
|
1296
|
1301
|
|
|
1302
|
+ if advice.PrescribingNumberUnit == drup.MaxUnit {
|
|
1303
|
+ deliver_number_one = countone * drup.MinNumber
|
|
1304
|
+
|
|
1305
|
+ } else {
|
|
1306
|
+ deliver_number_one = countone
|
|
1307
|
+
|
|
1308
|
+ }
|
|
1309
|
+
|
|
1310
|
+ fmt.Println(deliver_number_one)
|
|
1311
|
+
|
1297
|
1312
|
if advice.PrescribingNumberUnit == drup.MaxUnit {
|
1298
|
1313
|
drug_price = drup.RetailPrice
|
1299
|
1314
|
}
|
|
@@ -1320,6 +1335,7 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
|
1320
|
1335
|
|
1321
|
1336
|
ChangeMaxNumber(lastWarehouse.ID, stockMax)
|
1322
|
1337
|
UpdateMinNumber(lastWarehouse.ID, stockMin)
|
|
1338
|
+
|
1323
|
1339
|
}
|
1324
|
1340
|
}
|
1325
|
1341
|
|
|
@@ -1543,33 +1559,41 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
|
1543
|
1559
|
}
|
1544
|
1560
|
}
|
1545
|
1561
|
if lastDrugOutInfo.ID > 0 {
|
1546
|
|
- var his_count int64
|
1547
|
|
- if lastDrugOutInfo.CountUnit == drup.MaxUnit {
|
1548
|
|
- his_count = lastDrugOutInfo.Count * drup.MinNumber
|
1549
|
|
- }
|
1550
|
|
- if lastDrugOutInfo.CountUnit == drup.MinUnit {
|
1551
|
|
- his_count = lastDrugOutInfo.Count
|
1552
|
|
- }
|
1553
|
|
- if deliver_number != his_count {
|
1554
|
|
- errThree := UpdateSigleDrugWarehouseOutInfo(lastDrugOutInfo.ID, warehouseOutInfo)
|
1555
|
|
- if errThree != nil {
|
1556
|
|
- drugError := models.XtDrugError{
|
1557
|
|
- UserOrgId: orgID,
|
1558
|
|
- DrugId: advice.DrugId,
|
1559
|
|
- RecordDate: advice.AdviceDate,
|
1560
|
|
- PatientId: advice.PatientId,
|
1561
|
|
- Remark: "更新出库单失败",
|
1562
|
|
- Status: 1,
|
1563
|
|
- Ctime: time.Now().Unix(),
|
1564
|
|
- Mtime: 0,
|
1565
|
|
- SumCount: 0,
|
1566
|
|
- Prescribingnumber: advice.PrescribingNumber,
|
1567
|
|
- PrescribingNumberUnit: advice.PrescribingNumberUnit,
|
1568
|
|
- }
|
1569
|
|
- CreateDrugError(drugError)
|
1570
|
|
- return errThree
|
1571
|
|
- }
|
1572
|
|
- }
|
|
1562
|
+
|
|
1563
|
+ //删除在新增
|
|
1564
|
+ UpdateDrugWarehouseOutInfoTen(lastDrugOutInfo.PatientId, lastDrugOutInfo.SysRecordTime, advice.ID)
|
|
1565
|
+
|
|
1566
|
+ AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
|
|
1567
|
+
|
|
1568
|
+ //var his_count int64
|
|
1569
|
+ //if lastDrugOutInfo.CountUnit == drup.MaxUnit {
|
|
1570
|
+ // his_count = lastDrugOutInfo.Count * drup.MinNumber
|
|
1571
|
+ //}
|
|
1572
|
+ //if lastDrugOutInfo.CountUnit == drup.MinUnit {
|
|
1573
|
+ // his_count = lastDrugOutInfo.Count
|
|
1574
|
+ //}
|
|
1575
|
+ //fmt.Println("deliver_number", deliver_number)
|
|
1576
|
+ //fmt.Println("his_countwowowoowow", his_count)
|
|
1577
|
+ //if deliver_number != his_count {
|
|
1578
|
+ // errThree := UpdateSigleDrugWarehouseOutInfo(lastDrugOutInfo.ID, warehouseOutInfo)
|
|
1579
|
+ // if errThree != nil {
|
|
1580
|
+ // drugError := models.XtDrugError{
|
|
1581
|
+ // UserOrgId: orgID,
|
|
1582
|
+ // DrugId: advice.DrugId,
|
|
1583
|
+ // RecordDate: advice.AdviceDate,
|
|
1584
|
+ // PatientId: advice.PatientId,
|
|
1585
|
+ // Remark: "更新出库单失败",
|
|
1586
|
+ // Status: 1,
|
|
1587
|
+ // Ctime: time.Now().Unix(),
|
|
1588
|
+ // Mtime: 0,
|
|
1589
|
+ // SumCount: 0,
|
|
1590
|
+ // Prescribingnumber: advice.PrescribingNumber,
|
|
1591
|
+ // PrescribingNumberUnit: advice.PrescribingNumberUnit,
|
|
1592
|
+ // }
|
|
1593
|
+ // CreateDrugError(drugError)
|
|
1594
|
+ // return errThree
|
|
1595
|
+ // }
|
|
1596
|
+ //}
|
1573
|
1597
|
}
|
1574
|
1598
|
|
1575
|
1599
|
var out_count int64
|
|
@@ -1586,11 +1610,7 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
|
1586
|
1610
|
cancel_count += item.Count
|
1587
|
1611
|
}
|
1588
|
1612
|
|
1589
|
|
- //如果本次出库数据大于历史出库数据 新增1条流水
|
1590
|
|
- //fmt.Println("deliver_number233233223232wi", deliver_number)
|
1591
|
|
- //fmt.Println("out_coutn23333333333333333", out_count)
|
1592
|
|
- //fmt.Println("cancel_coutn099992ow", cancel_count)
|
1593
|
|
- if deliver_number >= (out_count - cancel_count) {
|
|
1613
|
+ if deliver_number_one-(out_count-cancel_count) >= 0 {
|
1594
|
1614
|
if (deliver_number - out_count - cancel_count) != 0 {
|
1595
|
1615
|
drugflow := models.DrugFlow{
|
1596
|
1616
|
WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
|
|
@@ -1599,7 +1619,7 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
|
1599
|
1619
|
Number: warehouse.Number,
|
1600
|
1620
|
ProductDate: warehouse.ProductDate,
|
1601
|
1621
|
ExpireDate: warehouse.ExpiryDate,
|
1602
|
|
- Count: deliver_number - (out_count - cancel_count), //按最小单位计算,
|
|
1622
|
+ Count: deliver_number_one - (out_count - cancel_count), //按最小单位计算,
|
1603
|
1623
|
Price: warehouse.RetailPrice,
|
1604
|
1624
|
Status: 1,
|
1605
|
1625
|
Ctime: advice.AdviceDate,
|
|
@@ -1667,7 +1687,7 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
|
1667
|
1687
|
}
|
1668
|
1688
|
|
1669
|
1689
|
//如果本次出库数据小于历史出库数据 新增1条退库流水
|
1670
|
|
- if deliver_number < (out_count - cancel_count) {
|
|
1690
|
+ if deliver_number_one-(out_count-cancel_count) < 0 {
|
1671
|
1691
|
|
1672
|
1692
|
operation_time := time.Now().Unix()
|
1673
|
1693
|
|
|
@@ -2340,7 +2360,7 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
|
2340
|
2360
|
advice.PrescribingNumber = float64(prescribingNumber_two_temp)
|
2341
|
2361
|
advice.PrescribingNumberUnit = drup.MinUnit
|
2342
|
2362
|
|
2343
|
|
- BloodHisDrugDeliverInfo(orgID, overPlusNumber, warehouseout, drup, advice)
|
|
2363
|
+ BloodHisDrugDeliverInfo(orgID, overPlusNumber, warehouseout, drup, advice, hisprescribingNumber)
|
2344
|
2364
|
}
|
2345
|
2365
|
|
2346
|
2366
|
return
|
|
@@ -3935,7 +3955,6 @@ func ConsumablesGoodDeliveryNew(orgID int64, patient_id int64, record_time int64
|
3935
|
3955
|
utils.ErrorLog("事务失败,原因为: %v", err)
|
3936
|
3956
|
tx.Rollback()
|
3937
|
3957
|
} else {
|
3938
|
|
- fmt.Println("err-----------------------", err)
|
3939
|
3958
|
tx.Commit()
|
3940
|
3959
|
}
|
3941
|
3960
|
var deliver_number int64 = 0
|
|
@@ -4513,3 +4532,9 @@ func ConsumablesGoodDeliveryNew(orgID int64, patient_id int64, record_time int64
|
4513
|
4532
|
|
4514
|
4533
|
return nil
|
4515
|
4534
|
}
|
|
4535
|
+
|
|
4536
|
+func UpdateDrugWarehouseOutInfoTen(patient_id int64, sys_record_time int64, advice_id int64) error {
|
|
4537
|
+
|
|
4538
|
+ err := XTWriteDB().Model(&models.DrugWarehouseOutInfo{}).Where("patient_id = ? and sys_record_time = ? and status=1 and advice_id = ?", patient_id, sys_record_time, advice_id).Updates(map[string]interface{}{"status": 0}).Error
|
|
4539
|
+ return err
|
|
4540
|
+}
|