|
@@ -3174,7 +3174,7 @@ func (c *HisApiController) CreateHisPrescription() {
|
3174
|
3174
|
var adviceList []models.HisDoctorAdviceInfo
|
3175
|
3175
|
var projectList []models.HisPrescriptionProject
|
3176
|
3176
|
|
3177
|
|
- if adminInfo.CurrentOrgId == 10489 || adminInfo.CurrentOrgId == 10510 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 10478 || adminInfo.CurrentOrgId == 10318 || adminInfo.CurrentOrgId == 10480 {
|
|
3177
|
+ if adminInfo.CurrentOrgId == 10489 || adminInfo.CurrentOrgId == 10510 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 10478 || adminInfo.CurrentOrgId == 10318 || adminInfo.CurrentOrgId == 10480 || adminInfo.CurrentOrgId == 10633 || adminInfo.CurrentOrgId == 9504 {
|
3178
|
3178
|
if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
|
3179
|
3179
|
prescriptions, _ := dataBody["prescriptions"].([]interface{})
|
3180
|
3180
|
|
|
@@ -3373,267 +3373,244 @@ func (c *HisApiController) CreateHisPrescription() {
|
3373
|
3373
|
//查询保存处方出库开关是否打开
|
3374
|
3374
|
drugOutConfig, _ := service.GetDrugOpenConfigOne(adminInfo.CurrentOrgId)
|
3375
|
3375
|
|
3376
|
|
- if drugOutConfig.IsOpen == 1 {
|
|
3376
|
+ if s.PatientId != 30038 {
|
|
3377
|
+ if drugOutConfig.IsOpen == 1 {
|
3377
|
3378
|
|
3378
|
|
- drug, _ := service.FindBaseDrugLibRecordSeven(adminInfo.CurrentOrgId, s.DrugId)
|
3379
|
|
- // 查询该药品最后一次出库记录
|
3380
|
|
- druginfo, _ := service.GetLastDrugWarehouseOutByDrugIdTwenty(s.DrugId, patient_id, recordDateTime, s.ID)
|
|
3379
|
+ drug, _ := service.FindBaseDrugLibRecordSeven(adminInfo.CurrentOrgId, s.DrugId)
|
|
3380
|
+ // 查询该药品最后一次出库记录
|
|
3381
|
+ druginfo, _ := service.GetLastDrugWarehouseOutByDrugIdTwenty(s.DrugId, patient_id, recordDateTime, s.ID)
|
3381
|
3382
|
|
3382
|
|
- var is_user_total int64
|
3383
|
|
- var no_user_total int64
|
|
3383
|
+ var is_user_total int64
|
|
3384
|
+ var no_user_total int64
|
3384
|
3385
|
|
3385
|
|
- if s.PrescribingNumberUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
|
|
3386
|
+ if s.PrescribingNumberUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
|
3386
|
3387
|
|
3387
|
|
- prescribingNumberTenty := strconv.FormatFloat(s.PrescribingNumber, 'f', -1, 64)
|
3388
|
|
- prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
|
|
3388
|
+ prescribingNumberTenty := strconv.FormatFloat(s.PrescribingNumber, 'f', -1, 64)
|
|
3389
|
+ prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
|
3389
|
3390
|
|
3390
|
|
- no_user_total += prescribingNumberSevenTy * drug.MinNumber
|
3391
|
|
- }
|
|
3391
|
+ no_user_total += prescribingNumberSevenTy * drug.MinNumber
|
|
3392
|
+ }
|
3392
|
3393
|
|
3393
|
|
- if s.PrescribingNumberUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
|
|
3394
|
+ if s.PrescribingNumberUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
|
3394
|
3395
|
|
3395
|
|
- prescribingNumberTenty := strconv.FormatFloat(s.PrescribingNumber, 'f', -1, 64)
|
3396
|
|
- prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
|
3397
|
|
- no_user_total += prescribingNumberSevenTy
|
3398
|
|
- }
|
|
3396
|
+ prescribingNumberTenty := strconv.FormatFloat(s.PrescribingNumber, 'f', -1, 64)
|
|
3397
|
+ prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
|
|
3398
|
+ no_user_total += prescribingNumberSevenTy
|
|
3399
|
+ }
|
3399
|
3400
|
|
3400
|
|
- if s.PrescribingNumberUnit == drug.MaxUnit && drug.MaxUnit == drug.MinUnit {
|
|
3401
|
+ if s.PrescribingNumberUnit == drug.MaxUnit && drug.MaxUnit == drug.MinUnit {
|
3401
|
3402
|
|
3402
|
|
- prescribingNumberTenty := strconv.FormatFloat(s.PrescribingNumber, 'f', -1, 64)
|
3403
|
|
- prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
|
3404
|
|
- no_user_total += prescribingNumberSevenTy
|
3405
|
|
- }
|
3406
|
|
- if len(druginfo) > 0 {
|
3407
|
|
- for _, it := range druginfo {
|
3408
|
|
- if it.CountUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
|
3409
|
|
- it.Count = it.Count * drug.MinNumber
|
3410
|
|
- is_user_total += it.Count
|
3411
|
|
- }
|
|
3403
|
+ prescribingNumberTenty := strconv.FormatFloat(s.PrescribingNumber, 'f', -1, 64)
|
|
3404
|
+ prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
|
|
3405
|
+ no_user_total += prescribingNumberSevenTy
|
|
3406
|
+ }
|
|
3407
|
+ if len(druginfo) > 0 {
|
|
3408
|
+ for _, it := range druginfo {
|
|
3409
|
+ if it.CountUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
|
|
3410
|
+ it.Count = it.Count * drug.MinNumber
|
|
3411
|
+ is_user_total += it.Count
|
|
3412
|
+ }
|
3412
|
3413
|
|
3413
|
|
- if it.CountUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
|
3414
|
|
- is_user_total += it.Count
|
3415
|
|
- }
|
|
3414
|
+ if it.CountUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
|
|
3415
|
+ is_user_total += it.Count
|
|
3416
|
+ }
|
3416
|
3417
|
|
3417
|
|
- if it.CountUnit == drug.MaxUnit && drug.MaxUnit == drug.MinUnit {
|
3418
|
|
- is_user_total += it.Count
|
|
3418
|
+ if it.CountUnit == drug.MaxUnit && drug.MaxUnit == drug.MinUnit {
|
|
3419
|
+ is_user_total += it.Count
|
3419
|
3420
|
|
|
3421
|
+ }
|
3420
|
3422
|
}
|
3421
|
|
- }
|
3422
|
3423
|
|
3423
|
|
- }
|
|
3424
|
+ }
|
3424
|
3425
|
|
3425
|
|
- fmt.Println("is_user_total-----------------------------", is_user_total)
|
3426
|
|
- fmt.Println("no_user_total-----------------------------", no_user_total)
|
|
3426
|
+ //fmt.Println("is_user_total-----------------------------", is_user_total)
|
|
3427
|
+ //fmt.Println("no_user_total-----------------------------", no_user_total)
|
3427
|
3428
|
|
3428
|
|
- if is_user_total != no_user_total {
|
|
3429
|
+ if is_user_total != no_user_total {
|
|
3430
|
+ //出库
|
|
3431
|
+ if drug.IsUse == 2 {
|
|
3432
|
+ creater := adminInfo.AdminUser.Id
|
|
3433
|
+ newadviceInfo := &models.HisDoctorAdviceInfo{
|
|
3434
|
+ ID: s.ID,
|
|
3435
|
+ UserOrgId: s.UserOrgId,
|
|
3436
|
+ PatientId: s.PatientId,
|
|
3437
|
+ HisPatientId: s.HisPatientId,
|
|
3438
|
+ AdviceType: s.AdviceType,
|
|
3439
|
+ AdviceDate: s.AdviceDate,
|
|
3440
|
+ StartTime: s.StartTime,
|
|
3441
|
+ AdviceName: s.AdviceName,
|
|
3442
|
+ AdviceDesc: s.AdviceDesc,
|
|
3443
|
+ ReminderDate: s.ReminderDate,
|
|
3444
|
+ SingleDose: s.SingleDose,
|
|
3445
|
+ SingleDoseUnit: s.SingleDoseUnit,
|
|
3446
|
+ PrescribingNumber: s.PrescribingNumber,
|
|
3447
|
+ PrescribingNumberUnit: s.PrescribingNumberUnit,
|
|
3448
|
+ DeliveryWay: s.DeliveryWay,
|
|
3449
|
+ ExecutionFrequency: s.ExecutionFrequency,
|
|
3450
|
+ AdviceDoctor: s.AdviceDoctor,
|
|
3451
|
+ Status: s.Status,
|
|
3452
|
+ CreatedTime: s.CreatedTime,
|
|
3453
|
+ UpdatedTime: s.UpdatedTime,
|
|
3454
|
+ AdviceAffirm: s.AdviceAffirm,
|
|
3455
|
+ Remark: s.Remark,
|
|
3456
|
+ StopTime: s.StopTime,
|
|
3457
|
+ StopReason: s.StopReason,
|
|
3458
|
+ StopDoctor: s.StopDoctor,
|
|
3459
|
+ StopState: s.StopState,
|
|
3460
|
+ ParentId: s.ParentId,
|
|
3461
|
+ ExecutionTime: s.ExecutionTime,
|
|
3462
|
+ ExecutionStaff: s.ExecutionStaff,
|
|
3463
|
+ ExecutionState: s.ExecutionState,
|
|
3464
|
+ Checker: s.Checker,
|
|
3465
|
+ RecordDate: s.RecordDate,
|
|
3466
|
+ DialysisOrderId: s.DialysisOrderId,
|
|
3467
|
+ CheckTime: s.CheckTime,
|
|
3468
|
+ CheckState: s.CheckState,
|
|
3469
|
+ DrugSpec: s.DrugSpec,
|
|
3470
|
+ DrugSpecUnit: s.DrugSpecUnit,
|
|
3471
|
+ Groupno: s.Groupno,
|
|
3472
|
+ RemindType: s.RemindType,
|
|
3473
|
+ FrequencyType: s.FrequencyType,
|
|
3474
|
+ DayCount: s.DayCount,
|
|
3475
|
+ WeekDay: s.WeekDay,
|
|
3476
|
+ TemplateId: s.TemplateId,
|
|
3477
|
+ Modifier: s.Modifier,
|
|
3478
|
+ DrugId: s.DrugId,
|
|
3479
|
+ Price: s.Price,
|
|
3480
|
+ PrescriptionId: s.PrescriptionId,
|
|
3481
|
+ MedListCodg: s.MedListCodg,
|
|
3482
|
+ FeedetlSn: s.FeedetlSn,
|
|
3483
|
+ Day: s.DayCount,
|
|
3484
|
+ ChildDoctorAdvice: nil,
|
|
3485
|
+ Drug: models.Drug{},
|
|
3486
|
+ Diagnosis: s.Diagnosis,
|
|
3487
|
+ Way: s.Way,
|
|
3488
|
+ HospApprFlag: s.HospApprFlag,
|
|
3489
|
+ LmtUsedFlag: s.LmtUsedFlag,
|
|
3490
|
+ HisOrderInfo: models.HisOrderInfo{},
|
|
3491
|
+ IsMedicine: s.IsMedicine,
|
|
3492
|
+ ExecutionFrequencyId: s.ExecutionFrequencyId,
|
|
3493
|
+ Child: nil,
|
|
3494
|
+ IsSettle: s.IsSettle,
|
|
3495
|
+ IsMobile: s.IsMobile,
|
|
3496
|
+ IsSelfDrug: s.IsSelfDrug,
|
|
3497
|
+ DrugWayCount: s.DrugWayCount,
|
|
3498
|
+ }
|
3429
|
3499
|
|
3430
|
|
- if len(druginfo) > 0 {
|
3431
|
|
- //回退库存
|
3432
|
|
- //for _, it := range druginfo {
|
3433
|
|
- // if it.CountUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
|
3434
|
|
- //
|
3435
|
|
- // service.ModifyDrugWarehouseInfoStockMaxNumber(it.Count, it.DrugId, it.OrgId, it.WarehouseInfoId)
|
3436
|
|
- //
|
3437
|
|
- // }
|
3438
|
|
- // if it.CountUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
|
3439
|
|
- //
|
3440
|
|
- // service.ModifyDrugWarehouseInfoStockMinNumber(it.Count, it.DrugId, it.OrgId, it.WarehouseInfoId)
|
3441
|
|
- //
|
3442
|
|
- // }
|
3443
|
|
- // if it.CountUnit == drug.MaxUnit && drug.MaxUnit == drug.MinUnit {
|
3444
|
|
- //
|
3445
|
|
- // service.ModifyDrugWarehouseInfoStockMaxNumber(it.Count, it.DrugId, it.OrgId, it.WarehouseInfoId)
|
3446
|
|
- //
|
3447
|
|
- // }
|
3448
|
|
- //}
|
3449
|
|
-
|
3450
|
|
- //删除记录
|
3451
|
|
- //service.DeleteNewDrugAutoWarehouseSeven(s.DrugId, patient_id, recordDateTime, s.ID)
|
|
3500
|
+ var history_count int64
|
|
3501
|
+ var local_count int64
|
|
3502
|
+ //查找已经开过的医嘱信息
|
|
3503
|
+ adviceHistory, _ := service.GetHistory(s.ID, s.UserOrgId, tx)
|
3452
|
3504
|
|
3453
|
|
- }
|
|
3505
|
+ if s.PrescribingNumberUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
|
3454
|
3506
|
|
3455
|
|
- //出库
|
3456
|
|
- if drug.IsUse == 2 {
|
3457
|
|
- creater := adminInfo.AdminUser.Id
|
3458
|
|
- newadviceInfo := &models.HisDoctorAdviceInfo{
|
3459
|
|
- ID: s.ID,
|
3460
|
|
- UserOrgId: s.UserOrgId,
|
3461
|
|
- PatientId: s.PatientId,
|
3462
|
|
- HisPatientId: s.HisPatientId,
|
3463
|
|
- AdviceType: s.AdviceType,
|
3464
|
|
- AdviceDate: s.AdviceDate,
|
3465
|
|
- StartTime: s.StartTime,
|
3466
|
|
- AdviceName: s.AdviceName,
|
3467
|
|
- AdviceDesc: s.AdviceDesc,
|
3468
|
|
- ReminderDate: s.ReminderDate,
|
3469
|
|
- SingleDose: s.SingleDose,
|
3470
|
|
- SingleDoseUnit: s.SingleDoseUnit,
|
3471
|
|
- PrescribingNumber: s.PrescribingNumber,
|
3472
|
|
- PrescribingNumberUnit: s.PrescribingNumberUnit,
|
3473
|
|
- DeliveryWay: s.DeliveryWay,
|
3474
|
|
- ExecutionFrequency: s.ExecutionFrequency,
|
3475
|
|
- AdviceDoctor: s.AdviceDoctor,
|
3476
|
|
- Status: s.Status,
|
3477
|
|
- CreatedTime: s.CreatedTime,
|
3478
|
|
- UpdatedTime: s.UpdatedTime,
|
3479
|
|
- AdviceAffirm: s.AdviceAffirm,
|
3480
|
|
- Remark: s.Remark,
|
3481
|
|
- StopTime: s.StopTime,
|
3482
|
|
- StopReason: s.StopReason,
|
3483
|
|
- StopDoctor: s.StopDoctor,
|
3484
|
|
- StopState: s.StopState,
|
3485
|
|
- ParentId: s.ParentId,
|
3486
|
|
- ExecutionTime: s.ExecutionTime,
|
3487
|
|
- ExecutionStaff: s.ExecutionStaff,
|
3488
|
|
- ExecutionState: s.ExecutionState,
|
3489
|
|
- Checker: s.Checker,
|
3490
|
|
- RecordDate: s.RecordDate,
|
3491
|
|
- DialysisOrderId: s.DialysisOrderId,
|
3492
|
|
- CheckTime: s.CheckTime,
|
3493
|
|
- CheckState: s.CheckState,
|
3494
|
|
- DrugSpec: s.DrugSpec,
|
3495
|
|
- DrugSpecUnit: s.DrugSpecUnit,
|
3496
|
|
- Groupno: s.Groupno,
|
3497
|
|
- RemindType: s.RemindType,
|
3498
|
|
- FrequencyType: s.FrequencyType,
|
3499
|
|
- DayCount: s.DayCount,
|
3500
|
|
- WeekDay: s.WeekDay,
|
3501
|
|
- TemplateId: s.TemplateId,
|
3502
|
|
- Modifier: s.Modifier,
|
3503
|
|
- DrugId: s.DrugId,
|
3504
|
|
- Price: s.Price,
|
3505
|
|
- PrescriptionId: s.PrescriptionId,
|
3506
|
|
- MedListCodg: s.MedListCodg,
|
3507
|
|
- FeedetlSn: s.FeedetlSn,
|
3508
|
|
- Day: s.DayCount,
|
3509
|
|
- ChildDoctorAdvice: nil,
|
3510
|
|
- Drug: models.Drug{},
|
3511
|
|
- Diagnosis: s.Diagnosis,
|
3512
|
|
- Way: s.Way,
|
3513
|
|
- HospApprFlag: s.HospApprFlag,
|
3514
|
|
- LmtUsedFlag: s.LmtUsedFlag,
|
3515
|
|
- HisOrderInfo: models.HisOrderInfo{},
|
3516
|
|
- IsMedicine: s.IsMedicine,
|
3517
|
|
- ExecutionFrequencyId: s.ExecutionFrequencyId,
|
3518
|
|
- Child: nil,
|
3519
|
|
- IsSettle: s.IsSettle,
|
3520
|
|
- IsMobile: s.IsMobile,
|
3521
|
|
- IsSelfDrug: s.IsSelfDrug,
|
3522
|
|
- DrugWayCount: s.DrugWayCount,
|
3523
|
|
- }
|
|
3507
|
+ prescribingNumberTenty := strconv.FormatFloat(s.PrescribingNumber, 'f', -1, 64)
|
|
3508
|
+ prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
|
3524
|
3509
|
|
3525
|
|
- var history_count int64
|
3526
|
|
- var local_count int64
|
3527
|
|
- //查找已经开过的医嘱信息
|
3528
|
|
- adviceHistory, _ := service.GetHistory(s.ID, s.UserOrgId, tx)
|
|
3510
|
+ local_count += prescribingNumberSevenTy * drug.MinNumber
|
|
3511
|
+ }
|
3529
|
3512
|
|
3530
|
|
- if s.PrescribingNumberUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
|
|
3513
|
+ if s.PrescribingNumberUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
|
3531
|
3514
|
|
3532
|
|
- prescribingNumberTenty := strconv.FormatFloat(s.PrescribingNumber, 'f', -1, 64)
|
3533
|
|
- prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
|
|
3515
|
+ prescribingNumberTenty := strconv.FormatFloat(s.PrescribingNumber, 'f', -1, 64)
|
|
3516
|
+ prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
|
|
3517
|
+ local_count += prescribingNumberSevenTy
|
|
3518
|
+ }
|
3534
|
3519
|
|
3535
|
|
- local_count += prescribingNumberSevenTy * drug.MinNumber
|
3536
|
|
- }
|
|
3520
|
+ if s.PrescribingNumberUnit == drug.MaxUnit && drug.MaxUnit == drug.MinUnit {
|
3537
|
3521
|
|
3538
|
|
- if s.PrescribingNumberUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
|
|
3522
|
+ prescribingNumberTenty := strconv.FormatFloat(s.PrescribingNumber, 'f', -1, 64)
|
|
3523
|
+ prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
|
|
3524
|
+ local_count += prescribingNumberSevenTy
|
|
3525
|
+ }
|
3539
|
3526
|
|
3540
|
|
- prescribingNumberTenty := strconv.FormatFloat(s.PrescribingNumber, 'f', -1, 64)
|
3541
|
|
- prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
|
3542
|
|
- local_count += prescribingNumberSevenTy
|
3543
|
|
- }
|
|
3527
|
+ if adviceHistory.PrescribingNumberUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
|
3544
|
3528
|
|
3545
|
|
- if s.PrescribingNumberUnit == drug.MaxUnit && drug.MaxUnit == drug.MinUnit {
|
|
3529
|
+ prescribingNumberTenty := strconv.FormatFloat(adviceHistory.PrescribingNumber, 'f', -1, 64)
|
|
3530
|
+ prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
|
3546
|
3531
|
|
3547
|
|
- prescribingNumberTenty := strconv.FormatFloat(s.PrescribingNumber, 'f', -1, 64)
|
3548
|
|
- prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
|
3549
|
|
- local_count += prescribingNumberSevenTy
|
3550
|
|
- }
|
|
3532
|
+ history_count += prescribingNumberSevenTy * drug.MinNumber
|
|
3533
|
+ }
|
3551
|
3534
|
|
3552
|
|
- if adviceHistory.PrescribingNumberUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
|
|
3535
|
+ if adviceHistory.PrescribingNumberUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
|
3553
|
3536
|
|
3554
|
|
- prescribingNumberTenty := strconv.FormatFloat(adviceHistory.PrescribingNumber, 'f', -1, 64)
|
3555
|
|
- prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
|
|
3537
|
+ prescribingNumberTenty := strconv.FormatFloat(adviceHistory.PrescribingNumber, 'f', -1, 64)
|
|
3538
|
+ prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
|
|
3539
|
+ history_count += prescribingNumberSevenTy
|
|
3540
|
+ }
|
3556
|
3541
|
|
3557
|
|
- history_count += prescribingNumberSevenTy * drug.MinNumber
|
3558
|
|
- }
|
|
3542
|
+ if adviceHistory.PrescribingNumberUnit == drug.MaxUnit && drug.MaxUnit == drug.MinUnit {
|
3559
|
3543
|
|
3560
|
|
- if adviceHistory.PrescribingNumberUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
|
|
3544
|
+ prescribingNumberTenty := strconv.FormatFloat(adviceHistory.PrescribingNumber, 'f', -1, 64)
|
|
3545
|
+ prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
|
|
3546
|
+ history_count += prescribingNumberSevenTy
|
|
3547
|
+ }
|
3561
|
3548
|
|
3562
|
|
- prescribingNumberTenty := strconv.FormatFloat(adviceHistory.PrescribingNumber, 'f', -1, 64)
|
3563
|
|
- prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
|
3564
|
|
- history_count += prescribingNumberSevenTy
|
3565
|
|
- }
|
|
3549
|
+ //fmt.Println("local_count0000000000000000000000000000000000000000000", local_count)
|
|
3550
|
+ //
|
|
3551
|
+ //fmt.Println("history_count999999999999999999999999999999999999999", history_count)
|
3566
|
3552
|
|
3567
|
|
- if adviceHistory.PrescribingNumberUnit == drug.MaxUnit && drug.MaxUnit == drug.MinUnit {
|
|
3553
|
+ //如果当前出库数量大于历史出库数量则需要出库
|
|
3554
|
+ if local_count > history_count {
|
|
3555
|
+ //按最小单位出库
|
|
3556
|
+ var cha_count = local_count - history_count
|
3568
|
3557
|
|
3569
|
|
- prescribingNumberTenty := strconv.FormatFloat(adviceHistory.PrescribingNumber, 'f', -1, 64)
|
3570
|
|
- prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
|
3571
|
|
- history_count += prescribingNumberSevenTy
|
3572
|
|
- }
|
|
3558
|
+ //fmt.Println("cha_count000000000000000000000000000", cha_count)
|
3573
|
3559
|
|
3574
|
|
- //fmt.Println("local_count0000000000000000000000000000000000000000000", local_count)
|
3575
|
|
- //
|
3576
|
|
- //fmt.Println("history_count999999999999999999999999999999999999999", history_count)
|
|
3560
|
+ newadviceInfo.PrescribingNumber = float64(cha_count)
|
|
3561
|
+ newadviceInfo.PrescribingNumberUnit = drug.MinUnit
|
3577
|
3562
|
|
3578
|
|
- //如果当前出库数量大于历史出库数量则需要出库
|
3579
|
|
- if local_count > history_count {
|
3580
|
|
- //按最小单位出库
|
3581
|
|
- var cha_count = local_count - history_count
|
|
3563
|
+ service.NewHisDrugsDelivery(s.UserOrgId, creater, newadviceInfo, tx)
|
|
3564
|
+ }
|
3582
|
3565
|
|
3583
|
|
- //fmt.Println("cha_count000000000000000000000000000", cha_count)
|
|
3566
|
+ //如果当前出库数量小于历史出库数量则需要退库
|
|
3567
|
+ if local_count < history_count {
|
3584
|
3568
|
|
3585
|
|
- newadviceInfo.PrescribingNumber = float64(cha_count)
|
3586
|
|
- newadviceInfo.PrescribingNumberUnit = drug.MinUnit
|
3587
|
|
- service.NewHisDrugsDelivery(s.UserOrgId, creater, newadviceInfo, tx)
|
3588
|
|
- }
|
|
3569
|
+ var cha_count = history_count - local_count
|
3589
|
3570
|
|
3590
|
|
- //如果当前出库数量小于历史出库数量则需要退库
|
3591
|
|
- if local_count < history_count {
|
|
3571
|
+ service.NewHisDrugCancelInfo(s.UserOrgId, creater, newadviceInfo, cha_count, drug, tx)
|
3592
|
3572
|
|
3593
|
|
- var cha_count = history_count - local_count
|
3594
|
|
- //fmt.Println("退库----------------------------", cha_count)
|
3595
|
|
- service.NewHisDrugCancelInfo(s.UserOrgId, creater, newadviceInfo, cha_count, drug, tx)
|
|
3573
|
+ service.NewHisDrugAutoCancelInfo(s.UserOrgId, creater, newadviceInfo, cha_count, drug, tx)
|
|
3574
|
+ }
|
3596
|
3575
|
|
3597
|
|
- service.NewHisDrugAutoCancelInfo(s.UserOrgId, creater, newadviceInfo, cha_count, drug, tx)
|
3598
|
3576
|
}
|
3599
|
3577
|
|
3600
|
|
- }
|
3601
|
|
-
|
3602
|
|
- //更新字典里面的库存
|
3603
|
|
- stockInfo, _ := service.GetNewDrugAllStockInfo(storeConfig.DrugStorehouseOut, s.UserOrgId, s.DrugId, tx)
|
3604
|
|
- var sum_count int64
|
3605
|
|
- for _, its := range stockInfo {
|
3606
|
|
- baseDrug, _ := service.GetNewBaseDrugMedical(its.DrugId, tx)
|
3607
|
|
- if its.MaxUnit == baseDrug.MaxUnit {
|
3608
|
|
- its.StockMaxNumber = its.StockMaxNumber * baseDrug.MinNumber
|
|
3578
|
+ //更新字典里面的库存
|
|
3579
|
+ stockInfo, _ := service.GetNewDrugAllStockInfo(storeConfig.DrugStorehouseOut, s.UserOrgId, s.DrugId, tx)
|
|
3580
|
+ var sum_count int64
|
|
3581
|
+ for _, its := range stockInfo {
|
|
3582
|
+ baseDrug, _ := service.GetNewBaseDrugMedical(its.DrugId, tx)
|
|
3583
|
+ if its.MaxUnit == baseDrug.MaxUnit {
|
|
3584
|
+ its.StockMaxNumber = its.StockMaxNumber * baseDrug.MinNumber
|
|
3585
|
+ }
|
|
3586
|
+ sum_count += its.StockMaxNumber + its.StockMinNumber
|
3609
|
3587
|
}
|
3610
|
|
- sum_count += its.StockMaxNumber + its.StockMinNumber
|
3611
|
|
- }
|
3612
|
|
- //更新基础库存
|
3613
|
|
- service.UpdateNewBaseDrugSumTwo(s.DrugId, sum_count, s.UserOrgId, tx)
|
3614
|
|
- //剩余库存
|
3615
|
|
- service.UpdateNewDrugStockCount(s.DrugId, s.UserOrgId, storeConfig.DrugStorehouseOut, sum_count, tx)
|
|
3588
|
+ //更新基础库存
|
|
3589
|
+ service.UpdateNewBaseDrugSumTwo(s.DrugId, sum_count, s.UserOrgId, tx)
|
|
3590
|
+ //剩余库存
|
|
3591
|
+ service.UpdateNewDrugStockCount(s.DrugId, s.UserOrgId, storeConfig.DrugStorehouseOut, sum_count, tx)
|
3616
|
3592
|
|
3617
|
|
- over, _ := service.FindNewOverCount(s.DrugId, s.UserOrgId, storeConfig.DrugStorehouseOut, tx)
|
3618
|
|
- service.UpdateNewActOut(over.ID, over.SumInCount, over.FlushCount, over.SumCancelCount, tx)
|
|
3593
|
+ over, _ := service.FindNewOverCount(s.DrugId, s.UserOrgId, storeConfig.DrugStorehouseOut, tx)
|
|
3594
|
+ service.UpdateNewActOut(over.ID, over.SumInCount, over.FlushCount, over.SumCancelCount, tx)
|
3619
|
3595
|
|
3620
|
|
- //创建医嘱
|
3621
|
|
- service.CreateHisDoctorAdviceOne(&s, tx)
|
|
3596
|
+ //创建医嘱
|
|
3597
|
+ service.CreateHisDoctorAdviceOne(&s, tx)
|
3622
|
3598
|
|
3623
|
|
- adviceObj, _ := service.GetLastHisDoctorAdviceById(s.PatientId, s.UserOrgId, s.AdviceDate, s.DrugId, tx)
|
|
3599
|
+ adviceObj, _ := service.GetLastHisDoctorAdviceById(s.PatientId, s.UserOrgId, s.AdviceDate, s.DrugId, tx)
|
3624
|
3600
|
|
3625
|
|
- outInfoTwo, _ := service.GetDrugWarehouseOutInfoByAdviceId(s.PatientId, s.UserOrgId, s.AdviceDate, s.DrugId, tx)
|
|
3601
|
+ outInfoTwo, _ := service.GetDrugWarehouseOutInfoByAdviceId(s.PatientId, s.UserOrgId, s.AdviceDate, s.DrugId, tx)
|
3626
|
3602
|
|
3627
|
|
- if len(outInfoTwo) > 0 {
|
3628
|
|
- for _, item := range outInfoTwo {
|
3629
|
|
- service.UpdateDrugOutInfoByAdviceId(item.ID, adviceObj.ID, tx)
|
|
3603
|
+ if len(outInfoTwo) > 0 {
|
|
3604
|
+ for _, item := range outInfoTwo {
|
|
3605
|
+ service.UpdateDrugOutInfoByAdviceId(item.ID, adviceObj.ID, tx)
|
|
3606
|
+ }
|
3630
|
3607
|
}
|
3631
|
|
- }
|
3632
|
3608
|
|
3633
|
|
- drugAutoDetail, _ := service.GetDrugAutoDetail(s.PatientId, s.UserOrgId, s.AdviceDate, s.DrugId, tx)
|
3634
|
|
- if len(drugAutoDetail) > 0 {
|
3635
|
|
- for _, item := range drugAutoDetail {
|
3636
|
|
- service.UpdateDrugAutoDetail(item.ID, adviceObj.ID, tx)
|
|
3609
|
+ drugAutoDetail, _ := service.GetDrugAutoDetail(s.PatientId, s.UserOrgId, s.AdviceDate, s.DrugId, tx)
|
|
3610
|
+ if len(drugAutoDetail) > 0 {
|
|
3611
|
+ for _, item := range drugAutoDetail {
|
|
3612
|
+ service.UpdateDrugAutoDetail(item.ID, adviceObj.ID, tx)
|
|
3613
|
+ }
|
3637
|
3614
|
}
|
3638
|
3615
|
}
|
3639
|
3616
|
}
|
|
@@ -3764,142 +3741,96 @@ func (c *HisApiController) CreateHisPrescription() {
|
3764
|
3741
|
service.CreateNewHisProjectTwo(&p, tx)
|
3765
|
3742
|
|
3766
|
3743
|
//查询保存耗材出库开关是否打开
|
3767
|
|
- if goodOutConfig.IsOpen == 1 {
|
3768
|
|
- //耗材出库
|
3769
|
|
- if p.Type == 3 {
|
3770
|
|
- lastHisProject, _ := service.GetLastHisProject(p.PatientId, p.UserOrgId, p.RecordDate, tx, p.ProjectId)
|
3771
|
|
- //查询历史出库数据
|
3772
|
|
- flowGood, _ := service.GetStockFlowIsBatchNumberSeventy(p.PatientId, p.RecordDate, p.ProjectId, lastHisProject.ID)
|
3773
|
|
-
|
3774
|
|
- var out_count_five int64
|
3775
|
|
- for _, item := range flowGood {
|
3776
|
|
- out_count_five += item.Count
|
3777
|
|
- }
|
3778
|
|
- parseIntCount, _ := strconv.ParseInt(p.Count, 10, 64)
|
3779
|
|
-
|
3780
|
|
- //如果当前处方的出库数量和已经出库的数量不一致,需要进行退库或者出库
|
3781
|
|
- if out_count_five != parseIntCount {
|
3782
|
|
- //查询耗材最后一次出库记录
|
3783
|
|
- wareOut, _ := service.GetLastGoodWarehouseOutInfoByProjectId(p.ProjectId, patient_id, recordDateTime, lastHisProject.ID)
|
3784
|
|
- //查询默认出库仓库库存
|
3785
|
|
- storeConfig, _ := service.GetAllStoreHouseConfig(adminInfo.CurrentOrgId)
|
3786
|
|
- if len(wareOut) > 0 {
|
3787
|
|
-
|
3788
|
|
- for _, it := range wareOut {
|
3789
|
|
- //回退库存
|
3790
|
|
- service.ModifyGoodWarehouseInfo(it.GoodId, it.WarehouseInfotId, it.OrgId, it.Count)
|
3791
|
|
-
|
3792
|
|
- //删除出库记录
|
3793
|
|
- service.DeleteGoodWarehouseOutInfo(it.GoodId, it.SysRecordTime, it.OrgId, it.ProjectId)
|
3794
|
|
-
|
3795
|
|
- }
|
|
3744
|
+ if p.PatientId != 30038 {
|
|
3745
|
+ if goodOutConfig.IsOpen == 1 {
|
|
3746
|
+ //耗材出库
|
|
3747
|
+ if p.Type == 3 {
|
|
3748
|
+ lastHisProject, _ := service.GetLastHisProject(p.PatientId, p.UserOrgId, p.RecordDate, tx, p.ProjectId)
|
|
3749
|
+ //查询历史出库数据
|
|
3750
|
+ flowGood, _ := service.GetStockFlowIsBatchNumberSeventy(p.PatientId, p.RecordDate, p.ProjectId, lastHisProject.ID)
|
|
3751
|
+
|
|
3752
|
+ var out_count_five int64
|
|
3753
|
+ for _, item := range flowGood {
|
|
3754
|
+ out_count_five += item.Count
|
3796
|
3755
|
}
|
|
3756
|
+ parseIntCount, _ := strconv.ParseInt(p.Count, 10, 64)
|
3797
|
3757
|
|
3798
|
|
- timeStr := time.Now().Format("2006-01-02")
|
3799
|
|
- timeArr := strings.Split(timeStr, "-")
|
3800
|
|
- total, _ := service.FindAllWarehouseOut(adminInfo.CurrentOrgId)
|
3801
|
|
-
|
3802
|
|
- total = total + 1
|
3803
|
|
- warehousing_out_order := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
|
3804
|
|
- number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
|
3805
|
|
- number = number + total
|
3806
|
|
- warehousing_out_order = "CKD" + strconv.FormatInt(number, 10)
|
3807
|
|
-
|
3808
|
|
- operation_time := time.Now().Unix()
|
3809
|
|
- creater := c.GetAdminUserInfo().AdminUser.Id
|
3810
|
|
-
|
3811
|
|
- recordDateStr := time.Now().Format("2006-01-02")
|
3812
|
|
- recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
|
3813
|
|
- nowtime := recordDate.Unix()
|
3814
|
|
- warehouseOut := models.WarehouseOut{
|
3815
|
|
- WarehouseOutOrderNumber: warehousing_out_order,
|
3816
|
|
- OperationTime: operation_time,
|
3817
|
|
- OrgId: adminInfo.CurrentOrgId,
|
3818
|
|
- Creater: creater,
|
3819
|
|
- Ctime: time.Now().Unix(),
|
3820
|
|
- Status: 1,
|
3821
|
|
- WarehouseOutTime: nowtime,
|
3822
|
|
- Type: 1,
|
3823
|
|
- StorehouseId: storeConfig.StorehouseOutInfo,
|
3824
|
|
- IsCheck: 1,
|
3825
|
|
- IsSys: 1,
|
3826
|
|
- }
|
3827
|
|
- //查询是否生成出库单
|
3828
|
|
- out, _ := service.FindNewPrescriptionWarehouseOut(adminInfo.CurrentOrgId, nowtime, tx)
|
3829
|
|
- if out.ID == 0 {
|
3830
|
|
- service.AddNewSigleWarehouseOut(&warehouseOut, tx)
|
3831
|
|
- }
|
|
3758
|
+ //如果当前处方的出库数量和已经出库的数量不一致,需要进行退库或者出库
|
|
3759
|
+ if out_count_five != parseIntCount {
|
|
3760
|
+ //查询耗材最后一次出库记录
|
|
3761
|
+ wareOut, _ := service.GetLastGoodWarehouseOutInfoByProjectId(p.ProjectId, patient_id, recordDateTime, lastHisProject.ID)
|
|
3762
|
+ //查询默认出库仓库库存
|
|
3763
|
+ storeConfig, _ := service.GetAllStoreHouseConfig(adminInfo.CurrentOrgId)
|
|
3764
|
+ if len(wareOut) > 0 {
|
3832
|
3765
|
|
3833
|
|
- lastOut, _ := service.FindNewLastPrescriptionWarehouseOut(adminInfo.CurrentOrgId, nowtime, tx)
|
3834
|
|
-
|
3835
|
|
- goodObj, _ := service.GetNewGoodInformationByGoodIdThirty(p.ProjectId, tx)
|
3836
|
|
- houseConfig, _ := service.GetNewAllStoreHouseConfig(p.UserOrgId, tx)
|
3837
|
|
-
|
3838
|
|
- dialyPrepareOne := models.DialysisBeforePrepare{
|
3839
|
|
- GoodTypeId: goodObj.GoodTypeId,
|
3840
|
|
- GoodId: p.ProjectId,
|
3841
|
|
- PatientId: p.PatientId,
|
3842
|
|
- RecordDate: p.RecordDate,
|
3843
|
|
- UserOrgId: adminInfo.CurrentOrgId,
|
3844
|
|
- Count: parseIntCount,
|
3845
|
|
- Ctime: time.Now().Unix(),
|
3846
|
|
- Creater: creater,
|
3847
|
|
- Status: 1,
|
3848
|
|
- StorehouseId: houseConfig.StorehouseOutInfo,
|
3849
|
|
- ProjectId: lastHisProject.ID,
|
3850
|
|
- }
|
3851
|
|
- //判断是否是零用耗材(非零用)
|
3852
|
|
- if goodObj.IsUse == 2 || goodObj.IsUse == 0 {
|
3853
|
|
-
|
3854
|
|
- //查询历史出库数据
|
3855
|
|
- flowGood, _ := service.GetNewStockFlowIsBatchNumberSeventy(p.PatientId, p.RecordDate, p.ProjectId, lastHisProject.ID, tx)
|
3856
|
|
- var out_count int64
|
3857
|
|
- for _, item := range flowGood {
|
3858
|
|
- out_count += item.Count
|
3859
|
|
- }
|
3860
|
|
- //如果历史数和当前数据不想等才进行退库出库
|
3861
|
|
- if out_count != parseIntCount {
|
3862
|
|
- service.ConsumableNewPrescriptionDelivery(adminInfo.CurrentOrgId, p.PatientId, p.RecordDate, &dialyPrepareOne, &lastOut, creater, parseIntCount, tx)
|
3863
|
|
-
|
3864
|
|
- service.UpdateNewAutomaticReduce(p.PatientId, p.RecordDate, p.ProjectId, lastHisProject.ID, tx)
|
3865
|
|
- detail := models.AutomaticReduceDetail{
|
3866
|
|
- WarehouseOutId: 0,
|
3867
|
|
- WarehouseOutOrderNumber: "",
|
3868
|
|
- PatientId: p.PatientId,
|
3869
|
|
- Ctime: time.Now().Unix(),
|
3870
|
|
- Mtime: 0,
|
3871
|
|
- Status: 1,
|
3872
|
|
- RecordTime: p.RecordDate,
|
3873
|
|
- OrgId: p.UserOrgId,
|
3874
|
|
- GoodId: p.ProjectId,
|
3875
|
|
- GoodTypeId: 0,
|
3876
|
|
- Count: parseIntCount,
|
3877
|
|
- Type: 0,
|
3878
|
|
- ProjectId: lastHisProject.ID,
|
3879
|
|
- StorehouseId: 0,
|
3880
|
|
- }
|
|
3766
|
+ for _, it := range wareOut {
|
|
3767
|
+ //回退库存
|
|
3768
|
+ service.ModifyGoodWarehouseInfo(it.GoodId, it.WarehouseInfotId, it.OrgId, it.Count)
|
3881
|
3769
|
|
3882
|
|
- service.CreateNewAutoDetail(detail, tx)
|
|
3770
|
+ //删除出库记录
|
|
3771
|
+ service.DeleteGoodWarehouseOutInfo(it.GoodId, it.SysRecordTime, it.OrgId, it.ProjectId)
|
3883
|
3772
|
|
3884
|
|
- //查询剩余库存
|
3885
|
|
- goodList, _ := service.GetNewAllGoodSumCount(p.ProjectId, adminInfo.CurrentOrgId, houseConfig.StorehouseOutInfo, tx)
|
3886
|
|
- var sum_count int64
|
3887
|
|
- for _, item := range goodList {
|
3888
|
|
- sum_count += item.StockCount
|
3889
|
3773
|
}
|
|
3774
|
+ }
|
3890
|
3775
|
|
3891
|
|
- //更新剩余库存
|
3892
|
|
- service.UpdateNewGoodFlushCount(houseConfig.StorehouseOutInfo, p.ProjectId, adminInfo.CurrentOrgId, sum_count, tx)
|
3893
|
|
-
|
3894
|
|
- //耗材
|
3895
|
|
- service.UpdateNewGoodSumCountSeven(sum_count, p.ProjectId, adminInfo.CurrentOrgId, tx)
|
|
3776
|
+ timeStr := time.Now().Format("2006-01-02")
|
|
3777
|
+ timeArr := strings.Split(timeStr, "-")
|
|
3778
|
+ total, _ := service.FindAllWarehouseOut(adminInfo.CurrentOrgId)
|
|
3779
|
+
|
|
3780
|
+ total = total + 1
|
|
3781
|
+ warehousing_out_order := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
|
|
3782
|
+ number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
|
|
3783
|
+ number = number + total
|
|
3784
|
+ warehousing_out_order = "CKD" + strconv.FormatInt(number, 10)
|
|
3785
|
+
|
|
3786
|
+ operation_time := time.Now().Unix()
|
|
3787
|
+ creater := c.GetAdminUserInfo().AdminUser.Id
|
|
3788
|
+
|
|
3789
|
+ recordDateStr := time.Now().Format("2006-01-02")
|
|
3790
|
+ recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
|
|
3791
|
+ nowtime := recordDate.Unix()
|
|
3792
|
+ warehouseOut := models.WarehouseOut{
|
|
3793
|
+ WarehouseOutOrderNumber: warehousing_out_order,
|
|
3794
|
+ OperationTime: operation_time,
|
|
3795
|
+ OrgId: adminInfo.CurrentOrgId,
|
|
3796
|
+ Creater: creater,
|
|
3797
|
+ Ctime: time.Now().Unix(),
|
|
3798
|
+ Status: 1,
|
|
3799
|
+ WarehouseOutTime: nowtime,
|
|
3800
|
+ Type: 1,
|
|
3801
|
+ StorehouseId: storeConfig.StorehouseOutInfo,
|
|
3802
|
+ IsCheck: 1,
|
|
3803
|
+ IsSys: 1,
|
|
3804
|
+ }
|
|
3805
|
+ //查询是否生成出库单
|
|
3806
|
+ out, _ := service.FindNewPrescriptionWarehouseOut(adminInfo.CurrentOrgId, nowtime, tx)
|
|
3807
|
+ if out.ID == 0 {
|
|
3808
|
+ service.AddNewSigleWarehouseOut(&warehouseOut, tx)
|
|
3809
|
+ }
|
3896
|
3810
|
|
|
3811
|
+ lastOut, _ := service.FindNewLastPrescriptionWarehouseOut(adminInfo.CurrentOrgId, nowtime, tx)
|
|
3812
|
+
|
|
3813
|
+ goodObj, _ := service.GetNewGoodInformationByGoodIdThirty(p.ProjectId, tx)
|
|
3814
|
+ houseConfig, _ := service.GetNewAllStoreHouseConfig(p.UserOrgId, tx)
|
|
3815
|
+
|
|
3816
|
+ dialyPrepareOne := models.DialysisBeforePrepare{
|
|
3817
|
+ GoodTypeId: goodObj.GoodTypeId,
|
|
3818
|
+ GoodId: p.ProjectId,
|
|
3819
|
+ PatientId: p.PatientId,
|
|
3820
|
+ RecordDate: p.RecordDate,
|
|
3821
|
+ UserOrgId: adminInfo.CurrentOrgId,
|
|
3822
|
+ Count: parseIntCount,
|
|
3823
|
+ Ctime: time.Now().Unix(),
|
|
3824
|
+ Creater: creater,
|
|
3825
|
+ Status: 1,
|
|
3826
|
+ StorehouseId: houseConfig.StorehouseOutInfo,
|
|
3827
|
+ ProjectId: lastHisProject.ID,
|
3897
|
3828
|
}
|
3898
|
|
- //判断是否是零用耗材(零用但是是出库耗材)
|
3899
|
|
- if goodObj.IsUse == 1 && goodObj.IsWarehouse == 1 {
|
|
3829
|
+ //判断是否是零用耗材(非零用)
|
|
3830
|
+ if goodObj.IsUse == 2 || goodObj.IsUse == 0 {
|
3900
|
3831
|
|
3901
|
3832
|
//查询历史出库数据
|
3902
|
|
- flowGood, _ := service.GetStockFlowIsBatchNumberSeventy(p.PatientId, p.RecordDate, p.ProjectId, lastHisProject.ID)
|
|
3833
|
+ flowGood, _ := service.GetNewStockFlowIsBatchNumberSeventy(p.PatientId, p.RecordDate, p.ProjectId, lastHisProject.ID, tx)
|
3903
|
3834
|
var out_count int64
|
3904
|
3835
|
for _, item := range flowGood {
|
3905
|
3836
|
out_count += item.Count
|
|
@@ -3922,7 +3853,7 @@ func (c *HisApiController) CreateHisPrescription() {
|
3922
|
3853
|
GoodTypeId: 0,
|
3923
|
3854
|
Count: parseIntCount,
|
3924
|
3855
|
Type: 0,
|
3925
|
|
- ProjectId: p.ID,
|
|
3856
|
+ ProjectId: lastHisProject.ID,
|
3926
|
3857
|
StorehouseId: 0,
|
3927
|
3858
|
}
|
3928
|
3859
|
|
|
@@ -3940,84 +3871,133 @@ func (c *HisApiController) CreateHisPrescription() {
|
3940
|
3871
|
|
3941
|
3872
|
//耗材
|
3942
|
3873
|
service.UpdateNewGoodSumCountSeven(sum_count, p.ProjectId, adminInfo.CurrentOrgId, tx)
|
|
3874
|
+
|
|
3875
|
+ }
|
|
3876
|
+ //判断是否是零用耗材(零用但是是出库耗材)
|
|
3877
|
+ if goodObj.IsUse == 1 && goodObj.IsWarehouse == 1 {
|
|
3878
|
+
|
|
3879
|
+ //查询历史出库数据
|
|
3880
|
+ flowGood, _ := service.GetStockFlowIsBatchNumberSeventy(p.PatientId, p.RecordDate, p.ProjectId, lastHisProject.ID)
|
|
3881
|
+ var out_count int64
|
|
3882
|
+ for _, item := range flowGood {
|
|
3883
|
+ out_count += item.Count
|
|
3884
|
+ }
|
|
3885
|
+ //如果历史数和当前数据不想等才进行退库出库
|
|
3886
|
+ if out_count != parseIntCount {
|
|
3887
|
+ service.ConsumableNewPrescriptionDelivery(adminInfo.CurrentOrgId, p.PatientId, p.RecordDate, &dialyPrepareOne, &lastOut, creater, parseIntCount, tx)
|
|
3888
|
+
|
|
3889
|
+ service.UpdateNewAutomaticReduce(p.PatientId, p.RecordDate, p.ProjectId, lastHisProject.ID, tx)
|
|
3890
|
+ detail := models.AutomaticReduceDetail{
|
|
3891
|
+ WarehouseOutId: 0,
|
|
3892
|
+ WarehouseOutOrderNumber: "",
|
|
3893
|
+ PatientId: p.PatientId,
|
|
3894
|
+ Ctime: time.Now().Unix(),
|
|
3895
|
+ Mtime: 0,
|
|
3896
|
+ Status: 1,
|
|
3897
|
+ RecordTime: p.RecordDate,
|
|
3898
|
+ OrgId: p.UserOrgId,
|
|
3899
|
+ GoodId: p.ProjectId,
|
|
3900
|
+ GoodTypeId: 0,
|
|
3901
|
+ Count: parseIntCount,
|
|
3902
|
+ Type: 0,
|
|
3903
|
+ ProjectId: p.ID,
|
|
3904
|
+ StorehouseId: 0,
|
|
3905
|
+ }
|
|
3906
|
+
|
|
3907
|
+ service.CreateNewAutoDetail(detail, tx)
|
|
3908
|
+
|
|
3909
|
+ //查询剩余库存
|
|
3910
|
+ goodList, _ := service.GetNewAllGoodSumCount(p.ProjectId, adminInfo.CurrentOrgId, houseConfig.StorehouseOutInfo, tx)
|
|
3911
|
+ var sum_count int64
|
|
3912
|
+ for _, item := range goodList {
|
|
3913
|
+ sum_count += item.StockCount
|
|
3914
|
+ }
|
|
3915
|
+
|
|
3916
|
+ //更新剩余库存
|
|
3917
|
+ service.UpdateNewGoodFlushCount(houseConfig.StorehouseOutInfo, p.ProjectId, adminInfo.CurrentOrgId, sum_count, tx)
|
|
3918
|
+
|
|
3919
|
+ //耗材
|
|
3920
|
+ service.UpdateNewGoodSumCountSeven(sum_count, p.ProjectId, adminInfo.CurrentOrgId, tx)
|
|
3921
|
+ }
|
|
3922
|
+
|
3943
|
3923
|
}
|
3944
|
3924
|
|
3945
|
3925
|
}
|
3946
|
3926
|
|
3947
|
3927
|
}
|
3948
|
3928
|
|
3949
|
|
- }
|
3950
|
|
-
|
3951
|
|
- //记录日志
|
3952
|
|
- byterequest, _ := json.Marshal(p)
|
3953
|
|
- adviceLog := models.XtDoctorAdviceLog{
|
3954
|
|
- UserOrgId: p.UserOrgId,
|
3955
|
|
- PatientId: p.PatientId,
|
3956
|
|
- AdminUserId: adminInfo.AdminUser.Id,
|
3957
|
|
- Module: 1,
|
3958
|
|
- ErrLog: string(byterequest),
|
3959
|
|
- Status: 1,
|
3960
|
|
- Ctime: time.Now().Unix(),
|
3961
|
|
- Mtime: 0,
|
3962
|
|
- Source: "电脑端新建his项目",
|
3963
|
|
- RecordDate: p.RecordDate,
|
3964
|
|
- }
|
3965
|
|
- service.CreateDoctorAdviceLog(adviceLog)
|
3966
|
|
-
|
3967
|
|
- projectList = append(projectList, p)
|
3968
|
|
-
|
3969
|
|
- if p.Type == 2 { //因为项目和耗材的基础库存在id相同的情况,所以需要根据该字段来判断,type为2的话为从项目开出来的
|
3970
|
|
- //新增或者编辑项目,修改对应的标签数据
|
3971
|
|
- labelOrigin, _ := service.GetProjectById(p.UserOrgId, p.ID, patient_id, recordDateTime)
|
3972
|
|
- if labelOrigin.ID == 0 { //当天某个人的处方中的项目不存在
|
3973
|
|
- var label models.HisLabelPrintInfo
|
3974
|
|
- project, _ := service.GetProjectDetail(p.ProjectId)
|
3975
|
|
- if project.CostClassify == 3 { //类别为检验检查
|
3976
|
|
- if p.TeamId > 0 { //检验检查组套
|
3977
|
|
- tempLabel, _ := service.GetProjectByTeamId(p.UserOrgId, p.TeamId, patient_id, recordDateTime)
|
3978
|
|
- if tempLabel.ID == 0 {
|
3979
|
|
- team, _ := service.GetProjectTeamDetail(p.TeamId)
|
|
3929
|
+ //记录日志
|
|
3930
|
+ byterequest, _ := json.Marshal(p)
|
|
3931
|
+ adviceLog := models.XtDoctorAdviceLog{
|
|
3932
|
+ UserOrgId: p.UserOrgId,
|
|
3933
|
+ PatientId: p.PatientId,
|
|
3934
|
+ AdminUserId: adminInfo.AdminUser.Id,
|
|
3935
|
+ Module: 1,
|
|
3936
|
+ ErrLog: string(byterequest),
|
|
3937
|
+ Status: 1,
|
|
3938
|
+ Ctime: time.Now().Unix(),
|
|
3939
|
+ Mtime: 0,
|
|
3940
|
+ Source: "电脑端新建his项目",
|
|
3941
|
+ RecordDate: p.RecordDate,
|
|
3942
|
+ }
|
|
3943
|
+ service.CreateDoctorAdviceLog(adviceLog)
|
|
3944
|
+
|
|
3945
|
+ projectList = append(projectList, p)
|
|
3946
|
+
|
|
3947
|
+ if p.Type == 2 { //因为项目和耗材的基础库存在id相同的情况,所以需要根据该字段来判断,type为2的话为从项目开出来的
|
|
3948
|
+ //新增或者编辑项目,修改对应的标签数据
|
|
3949
|
+ labelOrigin, _ := service.GetProjectById(p.UserOrgId, p.ID, patient_id, recordDateTime)
|
|
3950
|
+ if labelOrigin.ID == 0 { //当天某个人的处方中的项目不存在
|
|
3951
|
+ var label models.HisLabelPrintInfo
|
|
3952
|
+ project, _ := service.GetProjectDetail(p.ProjectId)
|
|
3953
|
+ if project.CostClassify == 3 { //类别为检验检查
|
|
3954
|
+ if p.TeamId > 0 { //检验检查组套
|
|
3955
|
+ tempLabel, _ := service.GetProjectByTeamId(p.UserOrgId, p.TeamId, patient_id, recordDateTime)
|
|
3956
|
+ if tempLabel.ID == 0 {
|
|
3957
|
+ team, _ := service.GetProjectTeamDetail(p.TeamId)
|
|
3958
|
+ label.Number = tempPrescription.PrescriptionNumber
|
|
3959
|
+ label.ProjectId = project.ID
|
|
3960
|
+ label.Status = 1
|
|
3961
|
+ label.IsPrint = 2
|
|
3962
|
+ label.DoctorId = info.DoctorId
|
|
3963
|
+ label.UserOrgId = p.UserOrgId
|
|
3964
|
+ label.PatientId = patient_id
|
|
3965
|
+ label.RecordDate = recordDateTime
|
|
3966
|
+ label.Ctime = time.Now().Unix()
|
|
3967
|
+ label.Mtime = time.Now().Unix()
|
|
3968
|
+ label.ItemId = p.TeamId
|
|
3969
|
+ label.FeedetlSn = p.FeedetlSn
|
|
3970
|
+ label.PProjectId = p.ID
|
|
3971
|
+ label.ProjectName = team.ProjectTeam
|
|
3972
|
+ label.PatientName = patient.Name
|
|
3973
|
+ service.CreateNewHisLabelRecord(&label, tx)
|
|
3974
|
+ }
|
|
3975
|
+ } else { //单条检验检查项目
|
3980
|
3976
|
label.Number = tempPrescription.PrescriptionNumber
|
3981
|
3977
|
label.ProjectId = project.ID
|
3982
|
3978
|
label.Status = 1
|
3983
|
|
- label.IsPrint = 2
|
3984
|
3979
|
label.DoctorId = info.DoctorId
|
3985
|
3980
|
label.UserOrgId = p.UserOrgId
|
3986
|
3981
|
label.PatientId = patient_id
|
3987
|
3982
|
label.RecordDate = recordDateTime
|
|
3983
|
+ label.IsPrint = 2
|
3988
|
3984
|
label.Ctime = time.Now().Unix()
|
3989
|
3985
|
label.Mtime = time.Now().Unix()
|
3990
|
|
- label.ItemId = p.TeamId
|
3991
|
3986
|
label.FeedetlSn = p.FeedetlSn
|
3992
|
3987
|
label.PProjectId = p.ID
|
3993
|
|
- label.ProjectName = team.ProjectTeam
|
|
3988
|
+ label.ItemId = p.TeamId
|
|
3989
|
+ label.ProjectName = project.ProjectName
|
3994
|
3990
|
label.PatientName = patient.Name
|
3995
|
3991
|
service.CreateNewHisLabelRecord(&label, tx)
|
3996
|
3992
|
}
|
3997
|
|
- } else { //单条检验检查项目
|
3998
|
|
- label.Number = tempPrescription.PrescriptionNumber
|
3999
|
|
- label.ProjectId = project.ID
|
4000
|
|
- label.Status = 1
|
4001
|
|
- label.DoctorId = info.DoctorId
|
4002
|
|
- label.UserOrgId = p.UserOrgId
|
4003
|
|
- label.PatientId = patient_id
|
4004
|
|
- label.RecordDate = recordDateTime
|
4005
|
|
- label.IsPrint = 2
|
4006
|
|
- label.Ctime = time.Now().Unix()
|
4007
|
|
- label.Mtime = time.Now().Unix()
|
4008
|
|
- label.FeedetlSn = p.FeedetlSn
|
4009
|
|
- label.PProjectId = p.ID
|
4010
|
|
- label.ItemId = p.TeamId
|
4011
|
|
- label.ProjectName = project.ProjectName
|
4012
|
|
- label.PatientName = patient.Name
|
4013
|
|
- service.CreateNewHisLabelRecord(&label, tx)
|
4014
|
3993
|
}
|
4015
|
3994
|
}
|
4016
|
3995
|
}
|
4017
|
|
- }
|
4018
|
3996
|
|
|
3997
|
+ }
|
4019
|
3998
|
}
|
4020
|
3999
|
}
|
|
4000
|
+
|
4021
|
4001
|
tx.Commit()
|
4022
|
4002
|
}
|
4023
|
4003
|
}
|