|
@@ -2382,6 +2382,20 @@ func (c *PatientApiController) ExecDoctorAdvice() {
|
2382
|
2382
|
}
|
2383
|
2383
|
|
2384
|
2384
|
if medical.IsUse == 1 {
|
|
2385
|
+ drugError := models.XtDrugError{
|
|
2386
|
+ UserOrgId: item.UserOrgId,
|
|
2387
|
+ DrugId: item.DrugId,
|
|
2388
|
+ RecordDate: item.AdviceDate,
|
|
2389
|
+ PatientId: item.PatientId,
|
|
2390
|
+ Remark: "电脑端零用药品",
|
|
2391
|
+ Status: 1,
|
|
2392
|
+ Ctime: time.Now().Unix(),
|
|
2393
|
+ Mtime: 0,
|
|
2394
|
+ SumCount: list.Count*medical.MinNumber + list.StockMinNumber,
|
|
2395
|
+ Prescribingnumber: item.PrescribingNumber,
|
|
2396
|
+ PrescribingNumberUnit: item.PrescribingNumberUnit,
|
|
2397
|
+ }
|
|
2398
|
+ service.CreateDrugError(drugError)
|
2385
|
2399
|
c.ServeSuccessJSON(map[string]interface{}{
|
2386
|
2400
|
"msg": "1",
|
2387
|
2401
|
"advice": advice,
|
|
@@ -2390,6 +2404,20 @@ func (c *PatientApiController) ExecDoctorAdvice() {
|
2390
|
2404
|
}
|
2391
|
2405
|
if medical.IsUse != 1 {
|
2392
|
2406
|
if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
|
|
2407
|
+ drugError := models.XtDrugError{
|
|
2408
|
+ UserOrgId: item.UserOrgId,
|
|
2409
|
+ DrugId: item.DrugId,
|
|
2410
|
+ RecordDate: item.AdviceDate,
|
|
2411
|
+ PatientId: item.PatientId,
|
|
2412
|
+ Remark: "电脑端药品库存不足",
|
|
2413
|
+ Status: 1,
|
|
2414
|
+ Ctime: time.Now().Unix(),
|
|
2415
|
+ Mtime: 0,
|
|
2416
|
+ SumCount: list.Count*medical.MinNumber + list.StockMinNumber,
|
|
2417
|
+ Prescribingnumber: item.PrescribingNumber,
|
|
2418
|
+ PrescribingNumberUnit: item.PrescribingNumberUnit,
|
|
2419
|
+ }
|
|
2420
|
+ service.CreateDrugError(drugError)
|
2393
|
2421
|
c.ServeSuccessJSON(map[string]interface{}{
|
2394
|
2422
|
"msg": "3",
|
2395
|
2423
|
"advice": advice,
|
|
@@ -2398,6 +2426,20 @@ func (c *PatientApiController) ExecDoctorAdvice() {
|
2398
|
2426
|
}
|
2399
|
2427
|
|
2400
|
2428
|
if prescribing_number_total > total {
|
|
2429
|
+ drugError := models.XtDrugError{
|
|
2430
|
+ UserOrgId: item.UserOrgId,
|
|
2431
|
+ DrugId: item.DrugId,
|
|
2432
|
+ RecordDate: item.AdviceDate,
|
|
2433
|
+ PatientId: item.PatientId,
|
|
2434
|
+ Remark: "电脑端出库数量大于总库存",
|
|
2435
|
+ Status: 1,
|
|
2436
|
+ Ctime: time.Now().Unix(),
|
|
2437
|
+ Mtime: 0,
|
|
2438
|
+ SumCount: list.Count*medical.MinNumber + list.StockMinNumber,
|
|
2439
|
+ Prescribingnumber: item.PrescribingNumber,
|
|
2440
|
+ PrescribingNumberUnit: item.PrescribingNumberUnit,
|
|
2441
|
+ }
|
|
2442
|
+ service.CreateDrugError(drugError)
|
2401
|
2443
|
c.ServeSuccessJSON(map[string]interface{}{
|
2402
|
2444
|
"msg": "2",
|
2403
|
2445
|
"advice": advice,
|
|
@@ -2414,10 +2456,66 @@ func (c *PatientApiController) ExecDoctorAdvice() {
|
2414
|
2456
|
if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
|
2415
|
2457
|
service.HisDrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
|
2416
|
2458
|
|
|
2459
|
+ if item.UserOrgId == 3877 || item.UserOrgId == 10265 {
|
|
2460
|
+ //查询该药品是否有出库记录
|
|
2461
|
+ flowMap, _ := service.GetDrugFLowByAdviceById(item.DrugId, item.PatientId, item.UserOrgId, item.AdviceDate)
|
|
2462
|
+ if len(flowMap) == 0 {
|
|
2463
|
+ errs := service.UpdateHisAdviceById(item.ID)
|
|
2464
|
+ if errs != nil {
|
|
2465
|
+ drugError := models.XtDrugError{
|
|
2466
|
+ UserOrgId: item.UserOrgId,
|
|
2467
|
+ DrugId: item.DrugId,
|
|
2468
|
+ RecordDate: item.AdviceDate,
|
|
2469
|
+ PatientId: item.PatientId,
|
|
2470
|
+ Remark: "出库记录为空,更新执行人失败",
|
|
2471
|
+ Status: 1,
|
|
2472
|
+ Ctime: time.Now().Unix(),
|
|
2473
|
+ Mtime: 0,
|
|
2474
|
+ SumCount: list.Count*medical.MinNumber + list.StockMinNumber,
|
|
2475
|
+ Prescribingnumber: item.PrescribingNumber,
|
|
2476
|
+ PrescribingNumberUnit: item.PrescribingNumberUnit,
|
|
2477
|
+ }
|
|
2478
|
+ service.CreateDrugError(drugError)
|
|
2479
|
+ }
|
|
2480
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
2481
|
+ "msg": "6",
|
|
2482
|
+ "advice": advice,
|
|
2483
|
+ })
|
|
2484
|
+ return
|
|
2485
|
+ }
|
|
2486
|
+ }
|
2417
|
2487
|
}
|
2418
|
2488
|
//不通过药房发药
|
2419
|
2489
|
if pharmacyConfig.IsOpen != 1 {
|
2420
|
2490
|
service.HisDrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
|
|
2491
|
+ if item.UserOrgId == 3877 || item.UserOrgId == 10265 {
|
|
2492
|
+ //查询该药品是否有出库记录
|
|
2493
|
+ flowMap, _ := service.GetDrugFLowByAdviceById(item.DrugId, item.PatientId, item.UserOrgId, item.AdviceDate)
|
|
2494
|
+ if len(flowMap) == 0 {
|
|
2495
|
+ errs := service.UpdateHisAdviceById(item.ID)
|
|
2496
|
+ if errs != nil {
|
|
2497
|
+ drugError := models.XtDrugError{
|
|
2498
|
+ UserOrgId: item.UserOrgId,
|
|
2499
|
+ DrugId: item.DrugId,
|
|
2500
|
+ RecordDate: item.AdviceDate,
|
|
2501
|
+ PatientId: item.PatientId,
|
|
2502
|
+ Remark: "出库记录为空,更新执行人失败",
|
|
2503
|
+ Status: 1,
|
|
2504
|
+ Ctime: time.Now().Unix(),
|
|
2505
|
+ Mtime: 0,
|
|
2506
|
+ SumCount: list.Count*medical.MinNumber + list.StockMinNumber,
|
|
2507
|
+ Prescribingnumber: item.PrescribingNumber,
|
|
2508
|
+ PrescribingNumberUnit: item.PrescribingNumberUnit,
|
|
2509
|
+ }
|
|
2510
|
+ service.CreateDrugError(drugError)
|
|
2511
|
+ }
|
|
2512
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
2513
|
+ "msg": "6",
|
|
2514
|
+ "advice": advice,
|
|
2515
|
+ })
|
|
2516
|
+ return
|
|
2517
|
+ }
|
|
2518
|
+ }
|
2421
|
2519
|
}
|
2422
|
2520
|
//查询默认仓库
|
2423
|
2521
|
storeHouseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
|