|
@@ -1384,313 +1384,307 @@ func (c *PatientApiController) ExecDoctorAdvice() {
|
1384
|
1384
|
defer redis.Close()
|
1385
|
1385
|
}
|
1386
|
1386
|
|
1387
|
|
- if err == nil {
|
1388
|
|
-
|
1389
|
|
- //药品管理信息
|
1390
|
|
- _, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(adminInfo.Org.Id)
|
|
1387
|
+ //药品管理信息
|
|
1388
|
+ _, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(adminInfo.Org.Id)
|
1391
|
1389
|
|
1392
|
|
- storeHouseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
|
1393
|
|
- if drugStockConfig.IsOpen == 1 {
|
1394
|
|
- for _, item := range advices {
|
1395
|
|
- //查询改药品信息
|
1396
|
|
- medical, _ := service.GetBaseDrugMedical(item.DrugId)
|
1397
|
|
-
|
1398
|
|
- //判断单位是否合格
|
1399
|
|
- if item.PrescribingNumberUnit != medical.MaxUnit && item.PrescribingNumberUnit != medical.MinUnit {
|
1400
|
|
- //查询该药品是否有出库记录
|
1401
|
|
- flowMap, _ := service.GetDrugFLowByAdviceById(item.DrugId, item.PatientId, item.UserOrgId, item.AdviceDate)
|
1402
|
|
- if len(flowMap) == 0 {
|
1403
|
|
- errs := service.UpdateHisAdviceById(item.ID)
|
1404
|
|
- if errs != nil {
|
1405
|
|
- drugError := models.XtDrugError{
|
1406
|
|
- UserOrgId: adminInfo.Org.Id,
|
1407
|
|
- DrugId: item.DrugId,
|
1408
|
|
- RecordDate: item.AdviceDate,
|
1409
|
|
- PatientId: item.PatientId,
|
1410
|
|
- Remark: "单位不统一,执行失败",
|
1411
|
|
- Status: 1,
|
1412
|
|
- Ctime: time.Now().Unix(),
|
1413
|
|
- Mtime: 0,
|
1414
|
|
- SumCount: 0,
|
1415
|
|
- Prescribingnumber: item.PrescribingNumber,
|
1416
|
|
- PrescribingNumberUnit: item.PrescribingNumberUnit,
|
1417
|
|
- }
|
1418
|
|
- service.CreateDrugError(drugError)
|
|
1390
|
+ storeHouseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
|
|
1391
|
+ if drugStockConfig.IsOpen == 1 {
|
|
1392
|
+ for _, item := range advices {
|
|
1393
|
+ //查询改药品信息
|
|
1394
|
+ medical, _ := service.GetBaseDrugMedical(item.DrugId)
|
|
1395
|
+
|
|
1396
|
+ //判断单位是否合格
|
|
1397
|
+ if item.PrescribingNumberUnit != medical.MaxUnit && item.PrescribingNumberUnit != medical.MinUnit {
|
|
1398
|
+ //查询该药品是否有出库记录
|
|
1399
|
+ flowMap, _ := service.GetDrugFLowByAdviceById(item.DrugId, item.PatientId, item.UserOrgId, item.AdviceDate)
|
|
1400
|
+ if len(flowMap) == 0 {
|
|
1401
|
+ errs := service.UpdateHisAdviceById(item.ID)
|
|
1402
|
+ if errs != nil {
|
|
1403
|
+ drugError := models.XtDrugError{
|
|
1404
|
+ UserOrgId: adminInfo.Org.Id,
|
|
1405
|
+ DrugId: item.DrugId,
|
|
1406
|
+ RecordDate: item.AdviceDate,
|
|
1407
|
+ PatientId: item.PatientId,
|
|
1408
|
+ Remark: "单位不统一,执行失败",
|
|
1409
|
+ Status: 1,
|
|
1410
|
+ Ctime: time.Now().Unix(),
|
|
1411
|
+ Mtime: 0,
|
|
1412
|
+ SumCount: 0,
|
|
1413
|
+ Prescribingnumber: item.PrescribingNumber,
|
|
1414
|
+ PrescribingNumberUnit: item.PrescribingNumberUnit,
|
1419
|
1415
|
}
|
|
1416
|
+ service.CreateDrugError(drugError)
|
1420
|
1417
|
}
|
1421
|
|
- advice, _ := service.FindHisDoctorAdviceById(adminInfo.Org.Id, item.ID)
|
1422
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
1423
|
|
- "msg": "7",
|
1424
|
|
- "advice": advice,
|
1425
|
|
- "ids": ids,
|
1426
|
|
- })
|
1427
|
|
- return
|
1428
|
1418
|
}
|
|
1419
|
+ advice, _ := service.FindHisDoctorAdviceById(adminInfo.Org.Id, item.ID)
|
|
1420
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1421
|
+ "msg": "7",
|
|
1422
|
+ "advice": advice,
|
|
1423
|
+ "ids": ids,
|
|
1424
|
+ })
|
|
1425
|
+ return
|
|
1426
|
+ }
|
1429
|
1427
|
|
1430
|
|
- //查询这个患者这个患者这个药已经出库的所有数量
|
1431
|
|
- advicelist, _ := service.GetAllHisDoctorAdviceById(item.DrugId, item.PatientId, item.AdviceDate, item.UserOrgId)
|
1432
|
|
- drugoutlist, _ := service.GetAllDrugFlowById(item.DrugId, item.PatientId, item.AdviceDate, item.UserOrgId)
|
1433
|
|
- var total_count int64
|
1434
|
|
- var drug_count int64
|
1435
|
|
- for _, it := range advicelist {
|
1436
|
|
- if it.PrescribingNumberUnit == medical.MaxUnit {
|
1437
|
|
- prescribingNumber_temp := strconv.FormatFloat(math.Abs(it.PrescribingNumber), 'f', 0, 64)
|
1438
|
|
- prenumber, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
|
1439
|
|
- total_count += prenumber * medical.MinNumber
|
1440
|
|
- }
|
1441
|
|
- if it.PrescribingNumberUnit == medical.MinUnit {
|
1442
|
|
- prescribingNumber_temp := strconv.FormatFloat(math.Abs(it.PrescribingNumber), 'f', 0, 64)
|
1443
|
|
- prenumber, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
|
1444
|
|
- total_count += prenumber
|
1445
|
|
- }
|
1446
|
|
-
|
|
1428
|
+ //查询这个患者这个患者这个药已经出库的所有数量
|
|
1429
|
+ advicelist, _ := service.GetAllHisDoctorAdviceById(item.DrugId, item.PatientId, item.AdviceDate, item.UserOrgId)
|
|
1430
|
+ drugoutlist, _ := service.GetAllDrugFlowById(item.DrugId, item.PatientId, item.AdviceDate, item.UserOrgId)
|
|
1431
|
+ var total_count int64
|
|
1432
|
+ var drug_count int64
|
|
1433
|
+ for _, it := range advicelist {
|
|
1434
|
+ if it.PrescribingNumberUnit == medical.MaxUnit {
|
|
1435
|
+ prescribingNumber_temp := strconv.FormatFloat(math.Abs(it.PrescribingNumber), 'f', 0, 64)
|
|
1436
|
+ prenumber, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
|
|
1437
|
+ total_count += prenumber * medical.MinNumber
|
|
1438
|
+ }
|
|
1439
|
+ if it.PrescribingNumberUnit == medical.MinUnit {
|
|
1440
|
+ prescribingNumber_temp := strconv.FormatFloat(math.Abs(it.PrescribingNumber), 'f', 0, 64)
|
|
1441
|
+ prenumber, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
|
|
1442
|
+ total_count += prenumber
|
1447
|
1443
|
}
|
1448
|
1444
|
|
1449
|
|
- for _, its := range drugoutlist {
|
1450
|
|
- if its.CountUnit == medical.MaxUnit {
|
1451
|
|
- drug_count += its.Count * medical.MinNumber
|
1452
|
|
- }
|
1453
|
|
- if its.CountUnit == medical.MinUnit {
|
1454
|
|
- drug_count += its.Count
|
1455
|
|
- }
|
|
1445
|
+ }
|
|
1446
|
+
|
|
1447
|
+ for _, its := range drugoutlist {
|
|
1448
|
+ if its.CountUnit == medical.MaxUnit {
|
|
1449
|
+ drug_count += its.Count * medical.MinNumber
|
1456
|
1450
|
}
|
1457
|
|
- if total_count == drug_count {
|
1458
|
|
-
|
1459
|
|
- advice, _ := service.FindHisDoctorAdviceById(adminInfo.Org.Id, item.ID)
|
1460
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
1461
|
|
- "msg": "1",
|
1462
|
|
- "advice": advice,
|
1463
|
|
- "ids": ids,
|
1464
|
|
- })
|
1465
|
|
- return
|
|
1451
|
+ if its.CountUnit == medical.MinUnit {
|
|
1452
|
+ drug_count += its.Count
|
1466
|
1453
|
}
|
|
1454
|
+ }
|
|
1455
|
+ if total_count == drug_count {
|
1467
|
1456
|
|
1468
|
1457
|
advice, _ := service.FindHisDoctorAdviceById(adminInfo.Org.Id, item.ID)
|
|
1458
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1459
|
+ "msg": "1",
|
|
1460
|
+ "advice": advice,
|
|
1461
|
+ "ids": ids,
|
|
1462
|
+ })
|
|
1463
|
+ return
|
|
1464
|
+ }
|
1469
|
1465
|
|
1470
|
|
- var total int64
|
1471
|
|
- var prescribing_number_total int64
|
|
1466
|
+ advice, _ := service.FindHisDoctorAdviceById(adminInfo.Org.Id, item.ID)
|
1472
|
1467
|
|
1473
|
|
- config, _ := service.GetDrugOpenConfigOne(adminInfo.Org.Id)
|
|
1468
|
+ var total int64
|
|
1469
|
+ var prescribing_number_total int64
|
1474
|
1470
|
|
1475
|
|
- if config.IsOpen != 1 {
|
1476
|
|
- //查询该药品是否有库存
|
1477
|
|
- houseConfig, _ := service.GetAllStoreHouseConfig(advice.UserOrgId)
|
1478
|
|
- list, _ := service.GetDrugTotalCount(advice.DrugId, advice.UserOrgId, houseConfig.DrugStorehouseOut)
|
|
1471
|
+ config, _ := service.GetDrugOpenConfigOne(adminInfo.Org.Id)
|
1479
|
1472
|
|
1480
|
|
- //判断单位是否相等
|
1481
|
|
- if medical.MaxUnit == advice.PrescribingNumberUnit {
|
1482
|
|
- prescribingNumber_temp := strconv.FormatFloat(math.Abs(advice.PrescribingNumber), 'f', 0, 64)
|
1483
|
|
- count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
|
1484
|
|
- //转化为最小单位
|
1485
|
|
- total = list.Count*medical.MinNumber + list.StockMinNumber
|
1486
|
|
- prescribing_number_total = count * medical.MinNumber
|
1487
|
|
- }
|
1488
|
|
- //fmt.Println("医嘱开的数量", total)
|
1489
|
|
- if medical.MinUnit == advice.PrescribingNumberUnit {
|
1490
|
|
- prescribingNumber_temp := strconv.FormatFloat(math.Abs(advice.PrescribingNumber), 'f', 0, 64)
|
1491
|
|
- count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
|
1492
|
|
- total = list.Count*medical.MinNumber + list.StockMinNumber
|
1493
|
|
- prescribing_number_total = count
|
1494
|
|
- }
|
|
1473
|
+ if config.IsOpen != 1 {
|
|
1474
|
+ //查询该药品是否有库存
|
|
1475
|
+ houseConfig, _ := service.GetAllStoreHouseConfig(advice.UserOrgId)
|
|
1476
|
+ list, _ := service.GetDrugTotalCount(advice.DrugId, advice.UserOrgId, houseConfig.DrugStorehouseOut)
|
1495
|
1477
|
|
1496
|
|
- if medical.IsUse == 1 {
|
1497
|
|
-
|
1498
|
|
- if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
|
1499
|
|
- drugError := models.XtDrugError{
|
1500
|
|
- UserOrgId: adminInfo.Org.Id,
|
1501
|
|
- DrugId: item.DrugId,
|
1502
|
|
- RecordDate: item.AdviceDate,
|
1503
|
|
- PatientId: item.PatientId,
|
1504
|
|
- Remark: "零用药品库存不足",
|
1505
|
|
- Status: 1,
|
1506
|
|
- Ctime: time.Now().Unix(),
|
1507
|
|
- Mtime: 0,
|
1508
|
|
- SumCount: list.Count*medical.MinNumber + list.StockMinNumber,
|
1509
|
|
- Prescribingnumber: advice.PrescribingNumber,
|
1510
|
|
- PrescribingNumberUnit: advice.PrescribingNumberUnit,
|
1511
|
|
- }
|
1512
|
|
- service.CreateDrugError(drugError)
|
1513
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
1514
|
|
- "msg": "1",
|
1515
|
|
- "advice": advice,
|
1516
|
|
- "ids": ids,
|
1517
|
|
- })
|
1518
|
|
- return
|
|
1478
|
+ //判断单位是否相等
|
|
1479
|
+ if medical.MaxUnit == advice.PrescribingNumberUnit {
|
|
1480
|
+ prescribingNumber_temp := strconv.FormatFloat(math.Abs(advice.PrescribingNumber), 'f', 0, 64)
|
|
1481
|
+ count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
|
|
1482
|
+ //转化为最小单位
|
|
1483
|
+ total = list.Count*medical.MinNumber + list.StockMinNumber
|
|
1484
|
+ prescribing_number_total = count * medical.MinNumber
|
|
1485
|
+ }
|
|
1486
|
+ //fmt.Println("医嘱开的数量", total)
|
|
1487
|
+ if medical.MinUnit == advice.PrescribingNumberUnit {
|
|
1488
|
+ prescribingNumber_temp := strconv.FormatFloat(math.Abs(advice.PrescribingNumber), 'f', 0, 64)
|
|
1489
|
+ count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
|
|
1490
|
+ total = list.Count*medical.MinNumber + list.StockMinNumber
|
|
1491
|
+ prescribing_number_total = count
|
|
1492
|
+ }
|
|
1493
|
+
|
|
1494
|
+ if medical.IsUse == 1 {
|
|
1495
|
+
|
|
1496
|
+ if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
|
|
1497
|
+ drugError := models.XtDrugError{
|
|
1498
|
+ UserOrgId: adminInfo.Org.Id,
|
|
1499
|
+ DrugId: item.DrugId,
|
|
1500
|
+ RecordDate: item.AdviceDate,
|
|
1501
|
+ PatientId: item.PatientId,
|
|
1502
|
+ Remark: "零用药品库存不足",
|
|
1503
|
+ Status: 1,
|
|
1504
|
+ Ctime: time.Now().Unix(),
|
|
1505
|
+ Mtime: 0,
|
|
1506
|
+ SumCount: list.Count*medical.MinNumber + list.StockMinNumber,
|
|
1507
|
+ Prescribingnumber: advice.PrescribingNumber,
|
|
1508
|
+ PrescribingNumberUnit: advice.PrescribingNumberUnit,
|
1519
|
1509
|
}
|
|
1510
|
+ service.CreateDrugError(drugError)
|
|
1511
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1512
|
+ "msg": "1",
|
|
1513
|
+ "advice": advice,
|
|
1514
|
+ "ids": ids,
|
|
1515
|
+ })
|
|
1516
|
+ return
|
1520
|
1517
|
}
|
1521
|
|
- if medical.IsUse != 1 {
|
1522
|
|
-
|
1523
|
|
- if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
|
1524
|
|
- drugError := models.XtDrugError{
|
1525
|
|
- UserOrgId: adminInfo.Org.Id,
|
1526
|
|
- DrugId: item.DrugId,
|
1527
|
|
- RecordDate: item.AdviceDate,
|
1528
|
|
- PatientId: item.PatientId,
|
1529
|
|
- Remark: "药品库存不足",
|
1530
|
|
- Status: 1,
|
1531
|
|
- Ctime: time.Now().Unix(),
|
1532
|
|
- Mtime: 0,
|
1533
|
|
- SumCount: list.Count*medical.MinNumber + list.StockMinNumber,
|
1534
|
|
- Prescribingnumber: advice.PrescribingNumber,
|
1535
|
|
- PrescribingNumberUnit: advice.PrescribingNumberUnit,
|
1536
|
|
- }
|
1537
|
|
- service.CreateDrugError(drugError)
|
1538
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
1539
|
|
- "msg": "3",
|
1540
|
|
- "advice": advice,
|
1541
|
|
- "ids": ids,
|
1542
|
|
- })
|
1543
|
|
- return
|
|
1518
|
+ }
|
|
1519
|
+ if medical.IsUse != 1 {
|
|
1520
|
+
|
|
1521
|
+ if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
|
|
1522
|
+ drugError := models.XtDrugError{
|
|
1523
|
+ UserOrgId: adminInfo.Org.Id,
|
|
1524
|
+ DrugId: item.DrugId,
|
|
1525
|
+ RecordDate: item.AdviceDate,
|
|
1526
|
+ PatientId: item.PatientId,
|
|
1527
|
+ Remark: "药品库存不足",
|
|
1528
|
+ Status: 1,
|
|
1529
|
+ Ctime: time.Now().Unix(),
|
|
1530
|
+ Mtime: 0,
|
|
1531
|
+ SumCount: list.Count*medical.MinNumber + list.StockMinNumber,
|
|
1532
|
+ Prescribingnumber: advice.PrescribingNumber,
|
|
1533
|
+ PrescribingNumberUnit: advice.PrescribingNumberUnit,
|
1544
|
1534
|
}
|
1545
|
|
- if prescribing_number_total > total {
|
1546
|
|
- drugError := models.XtDrugError{
|
1547
|
|
- UserOrgId: adminInfo.Org.Id,
|
1548
|
|
- DrugId: item.DrugId,
|
1549
|
|
- RecordDate: item.AdviceDate,
|
1550
|
|
- PatientId: item.PatientId,
|
1551
|
|
- Remark: "出库数量大于库存",
|
1552
|
|
- Status: 1,
|
1553
|
|
- Ctime: time.Now().Unix(),
|
1554
|
|
- Mtime: 0,
|
1555
|
|
- SumCount: list.Count*medical.MinNumber + list.StockMinNumber,
|
1556
|
|
- Prescribingnumber: advice.PrescribingNumber,
|
1557
|
|
- PrescribingNumberUnit: advice.PrescribingNumberUnit,
|
1558
|
|
- }
|
1559
|
|
- service.CreateDrugError(drugError)
|
1560
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
1561
|
|
- "msg": "2",
|
1562
|
|
- "advice": advice,
|
1563
|
|
- "ids": ids,
|
1564
|
|
- })
|
1565
|
|
- return
|
|
1535
|
+ service.CreateDrugError(drugError)
|
|
1536
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1537
|
+ "msg": "3",
|
|
1538
|
+ "advice": advice,
|
|
1539
|
+ "ids": ids,
|
|
1540
|
+ })
|
|
1541
|
+ return
|
|
1542
|
+ }
|
|
1543
|
+ if prescribing_number_total > total {
|
|
1544
|
+ drugError := models.XtDrugError{
|
|
1545
|
+ UserOrgId: adminInfo.Org.Id,
|
|
1546
|
+ DrugId: item.DrugId,
|
|
1547
|
+ RecordDate: item.AdviceDate,
|
|
1548
|
+ PatientId: item.PatientId,
|
|
1549
|
+ Remark: "出库数量大于库存",
|
|
1550
|
+ Status: 1,
|
|
1551
|
+ Ctime: time.Now().Unix(),
|
|
1552
|
+ Mtime: 0,
|
|
1553
|
+ SumCount: list.Count*medical.MinNumber + list.StockMinNumber,
|
|
1554
|
+ Prescribingnumber: advice.PrescribingNumber,
|
|
1555
|
+ PrescribingNumberUnit: advice.PrescribingNumberUnit,
|
1566
|
1556
|
}
|
|
1557
|
+ service.CreateDrugError(drugError)
|
|
1558
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1559
|
+ "msg": "2",
|
|
1560
|
+ "advice": advice,
|
|
1561
|
+ "ids": ids,
|
|
1562
|
+ })
|
|
1563
|
+ return
|
1567
|
1564
|
}
|
|
1565
|
+ }
|
1568
|
1566
|
|
1569
|
|
- if prescribing_number_total <= total {
|
|
1567
|
+ if prescribing_number_total <= total {
|
1570
|
1568
|
|
1571
|
|
- pharmacyConfig, _ := service.FindPharmacyConfig(advice.UserOrgId)
|
1572
|
|
- //判断药品是否零用
|
1573
|
|
- if medical.IsUse == 2 {
|
|
1569
|
+ pharmacyConfig, _ := service.FindPharmacyConfig(advice.UserOrgId)
|
|
1570
|
+ //判断药品是否零用
|
|
1571
|
+ if medical.IsUse == 2 {
|
1574
|
1572
|
|
1575
|
|
- if config.IsOpen != 1 {
|
1576
|
|
- if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
|
1577
|
|
- service.HisDrugsDelivery(adminInfo.Org.Id, creater, &advice)
|
1578
|
|
-
|
1579
|
|
- if adminInfo.Org.Id == 3877 || adminInfo.Org.Id == 10265 {
|
1580
|
|
- //查询该药品是否有出库记录
|
1581
|
|
- flowMap, _ := service.GetDrugFLowByAdviceById(advice.DrugId, advice.PatientId, advice.UserOrgId, advice.AdviceDate)
|
1582
|
|
- if len(flowMap) == 0 {
|
1583
|
|
- errs := service.UpdateHisAdviceById(advice.ID)
|
1584
|
|
- if errs != nil {
|
1585
|
|
- drugError := models.XtDrugError{
|
1586
|
|
- UserOrgId: adminInfo.Org.Id,
|
1587
|
|
- DrugId: item.DrugId,
|
1588
|
|
- RecordDate: item.AdviceDate,
|
1589
|
|
- PatientId: item.PatientId,
|
1590
|
|
- Remark: "出库记录为空,更新执行人失败",
|
1591
|
|
- Status: 1,
|
1592
|
|
- Ctime: time.Now().Unix(),
|
1593
|
|
- Mtime: 0,
|
1594
|
|
- SumCount: list.Count*medical.MinNumber + list.StockMinNumber,
|
1595
|
|
- Prescribingnumber: advice.PrescribingNumber,
|
1596
|
|
- PrescribingNumberUnit: advice.PrescribingNumberUnit,
|
1597
|
|
- }
|
1598
|
|
- service.CreateDrugError(drugError)
|
|
1573
|
+ if config.IsOpen != 1 {
|
|
1574
|
+ if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
|
|
1575
|
+ service.HisDrugsDelivery(adminInfo.Org.Id, creater, &advice)
|
|
1576
|
+
|
|
1577
|
+ if adminInfo.Org.Id == 3877 || adminInfo.Org.Id == 10265 {
|
|
1578
|
+ //查询该药品是否有出库记录
|
|
1579
|
+ flowMap, _ := service.GetDrugFLowByAdviceById(advice.DrugId, advice.PatientId, advice.UserOrgId, advice.AdviceDate)
|
|
1580
|
+ if len(flowMap) == 0 {
|
|
1581
|
+ errs := service.UpdateHisAdviceById(advice.ID)
|
|
1582
|
+ if errs != nil {
|
|
1583
|
+ drugError := models.XtDrugError{
|
|
1584
|
+ UserOrgId: adminInfo.Org.Id,
|
|
1585
|
+ DrugId: item.DrugId,
|
|
1586
|
+ RecordDate: item.AdviceDate,
|
|
1587
|
+ PatientId: item.PatientId,
|
|
1588
|
+ Remark: "出库记录为空,更新执行人失败",
|
|
1589
|
+ Status: 1,
|
|
1590
|
+ Ctime: time.Now().Unix(),
|
|
1591
|
+ Mtime: 0,
|
|
1592
|
+ SumCount: list.Count*medical.MinNumber + list.StockMinNumber,
|
|
1593
|
+ Prescribingnumber: advice.PrescribingNumber,
|
|
1594
|
+ PrescribingNumberUnit: advice.PrescribingNumberUnit,
|
1599
|
1595
|
}
|
1600
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
1601
|
|
- "msg": "6",
|
1602
|
|
- "advice": advice,
|
1603
|
|
- "ids": ids,
|
1604
|
|
- })
|
1605
|
|
- return
|
|
1596
|
+ service.CreateDrugError(drugError)
|
1606
|
1597
|
}
|
|
1598
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1599
|
+ "msg": "6",
|
|
1600
|
+ "advice": advice,
|
|
1601
|
+ "ids": ids,
|
|
1602
|
+ })
|
|
1603
|
+ return
|
1607
|
1604
|
}
|
1608
|
1605
|
}
|
1609
|
|
- if pharmacyConfig.IsOpen != 1 {
|
|
1606
|
+ }
|
|
1607
|
+ if pharmacyConfig.IsOpen != 1 {
|
1610
|
1608
|
|
1611
|
|
- service.HisDrugsDelivery(adminInfo.Org.Id, creater, &advice)
|
1612
|
|
- if adminInfo.Org.Id == 3877 || adminInfo.Org.Id == 10265 {
|
1613
|
|
- //查询该药品是否有出库记录
|
1614
|
|
- flowMap, _ := service.GetDrugFLowByAdviceById(advice.DrugId, advice.PatientId, advice.UserOrgId, advice.AdviceDate)
|
1615
|
|
-
|
1616
|
|
- if len(flowMap) == 0 {
|
1617
|
|
-
|
1618
|
|
- errs := service.UpdateHisAdviceById(advice.ID)
|
1619
|
|
- if errs != nil {
|
1620
|
|
- drugError := models.XtDrugError{
|
1621
|
|
- UserOrgId: adminInfo.Org.Id,
|
1622
|
|
- DrugId: item.DrugId,
|
1623
|
|
- RecordDate: item.AdviceDate,
|
1624
|
|
- PatientId: item.PatientId,
|
1625
|
|
- Remark: "出库记录为空,更新执行人失败",
|
1626
|
|
- Status: 1,
|
1627
|
|
- Ctime: time.Now().Unix(),
|
1628
|
|
- Mtime: 0,
|
1629
|
|
- SumCount: list.Count*medical.MinNumber + list.StockMinNumber,
|
1630
|
|
- Prescribingnumber: advice.PrescribingNumber,
|
1631
|
|
- PrescribingNumberUnit: advice.PrescribingNumberUnit,
|
1632
|
|
- }
|
1633
|
|
- service.CreateDrugError(drugError)
|
|
1609
|
+ service.HisDrugsDelivery(adminInfo.Org.Id, creater, &advice)
|
|
1610
|
+ if adminInfo.Org.Id == 3877 || adminInfo.Org.Id == 10265 {
|
|
1611
|
+ //查询该药品是否有出库记录
|
|
1612
|
+ flowMap, _ := service.GetDrugFLowByAdviceById(advice.DrugId, advice.PatientId, advice.UserOrgId, advice.AdviceDate)
|
|
1613
|
+
|
|
1614
|
+ if len(flowMap) == 0 {
|
|
1615
|
+
|
|
1616
|
+ errs := service.UpdateHisAdviceById(advice.ID)
|
|
1617
|
+ if errs != nil {
|
|
1618
|
+ drugError := models.XtDrugError{
|
|
1619
|
+ UserOrgId: adminInfo.Org.Id,
|
|
1620
|
+ DrugId: item.DrugId,
|
|
1621
|
+ RecordDate: item.AdviceDate,
|
|
1622
|
+ PatientId: item.PatientId,
|
|
1623
|
+ Remark: "出库记录为空,更新执行人失败",
|
|
1624
|
+ Status: 1,
|
|
1625
|
+ Ctime: time.Now().Unix(),
|
|
1626
|
+ Mtime: 0,
|
|
1627
|
+ SumCount: list.Count*medical.MinNumber + list.StockMinNumber,
|
|
1628
|
+ Prescribingnumber: advice.PrescribingNumber,
|
|
1629
|
+ PrescribingNumberUnit: advice.PrescribingNumberUnit,
|
1634
|
1630
|
}
|
1635
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
1636
|
|
- "msg": "6",
|
1637
|
|
- "advice": advice,
|
1638
|
|
- "ids": ids,
|
1639
|
|
- })
|
1640
|
|
- return
|
|
1631
|
+ service.CreateDrugError(drugError)
|
1641
|
1632
|
}
|
|
1633
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1634
|
+ "msg": "6",
|
|
1635
|
+ "advice": advice,
|
|
1636
|
+ "ids": ids,
|
|
1637
|
+ })
|
|
1638
|
+ return
|
1642
|
1639
|
}
|
1643
|
1640
|
}
|
|
1641
|
+ }
|
1644
|
1642
|
|
1645
|
|
- //更新字典里面的库存
|
1646
|
|
- stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
|
1647
|
|
- var sum_count int64
|
1648
|
|
- for _, its := range stockInfo {
|
1649
|
|
- if its.MaxUnit == medical.MaxUnit {
|
1650
|
|
- its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
|
1651
|
|
- }
|
1652
|
|
- sum_count += its.StockMaxNumber + its.StockMinNumber
|
|
1643
|
+ //更新字典里面的库存
|
|
1644
|
+ stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
|
|
1645
|
+ var sum_count int64
|
|
1646
|
+ for _, its := range stockInfo {
|
|
1647
|
+ if its.MaxUnit == medical.MaxUnit {
|
|
1648
|
+ its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
|
1653
|
1649
|
}
|
1654
|
|
- service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
|
1655
|
|
- //剩余库存
|
1656
|
|
- service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
|
|
1650
|
+ sum_count += its.StockMaxNumber + its.StockMinNumber
|
1657
|
1651
|
}
|
1658
|
|
-
|
|
1652
|
+ service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
|
|
1653
|
+ //剩余库存
|
|
1654
|
+ service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
|
1659
|
1655
|
}
|
|
1656
|
+
|
1660
|
1657
|
}
|
1661
|
1658
|
}
|
|
1659
|
+ }
|
1662
|
1660
|
|
1663
|
|
- //
|
1664
|
|
- //if config.IsOpen == 1 && item.UserOrgId == 10188 {
|
1665
|
|
- //
|
1666
|
|
- // service.HisDrugsDelivery(adminInfo.Org.Id, creater, &advice)
|
1667
|
|
- // //更新字典里面的库存
|
1668
|
|
- // stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
|
1669
|
|
- // var sum_count int64
|
1670
|
|
- // for _, its := range stockInfo {
|
1671
|
|
- // if its.MaxUnit == medical.MaxUnit {
|
1672
|
|
- // its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
|
1673
|
|
- // }
|
1674
|
|
- // sum_count += its.StockMaxNumber + its.StockMinNumber
|
1675
|
|
- // }
|
1676
|
|
- // service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
|
1677
|
|
- // //剩余库存
|
1678
|
|
- // service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
|
1679
|
|
- //}
|
|
1661
|
+ //
|
|
1662
|
+ //if config.IsOpen == 1 && item.UserOrgId == 10188 {
|
|
1663
|
+ //
|
|
1664
|
+ // service.HisDrugsDelivery(adminInfo.Org.Id, creater, &advice)
|
|
1665
|
+ // //更新字典里面的库存
|
|
1666
|
+ // stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
|
|
1667
|
+ // var sum_count int64
|
|
1668
|
+ // for _, its := range stockInfo {
|
|
1669
|
+ // if its.MaxUnit == medical.MaxUnit {
|
|
1670
|
+ // its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
|
|
1671
|
+ // }
|
|
1672
|
+ // sum_count += its.StockMaxNumber + its.StockMinNumber
|
|
1673
|
+ // }
|
|
1674
|
+ // service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
|
|
1675
|
+ // //剩余库存
|
|
1676
|
+ // service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
|
|
1677
|
+ //}
|
1680
|
1678
|
|
1681
|
|
- }
|
1682
|
1679
|
}
|
1683
|
|
- for _, item := range advices {
|
1684
|
|
- advice, _ := service.FindHisDoctorAdviceById(adminInfo.Org.Id, item.ID)
|
1685
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
1686
|
|
- "msg": "1",
|
1687
|
|
- "advice": advice,
|
1688
|
|
- "ids": ids,
|
1689
|
|
- })
|
1690
|
|
- }
|
1691
|
|
-
|
1692
|
|
- } else {
|
1693
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
1680
|
+ }
|
|
1681
|
+ for _, item := range advices {
|
|
1682
|
+ advice, _ := service.FindHisDoctorAdviceById(adminInfo.Org.Id, item.ID)
|
|
1683
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1684
|
+ "msg": "1",
|
|
1685
|
+ "advice": advice,
|
|
1686
|
+ "ids": ids,
|
|
1687
|
+ })
|
1694
|
1688
|
}
|
1695
|
1689
|
|
1696
|
1690
|
}
|