Browse Source

历史排班

28169 9 months ago
parent
commit
3ea03d231a

+ 4 - 4
controllers/base_api_controller.go View File

@@ -83,7 +83,7 @@ func (this *BaseAuthAPIController) Prepare() {
83 83
 		userAdmin.ModifyTime = 1530786071
84 84
 		var subscibe models.ServeSubscibe
85 85
 		subscibe.ID = 11
86
-		subscibe.OrgId = 10480 //机构id
86
+		subscibe.OrgId = 10633 //机构id
87 87
 		subscibe.PeriodStart = 1547447814
88 88
 		subscibe.PeriodEnd = 1550039814
89 89
 		subscibe.State = 1
@@ -93,7 +93,7 @@ func (this *BaseAuthAPIController) Prepare() {
93 93
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
94 94
 		subscibes[4] = &subscibe
95 95
 		var adminUserInfo service.AdminUserInfo
96
-		adminUserInfo.CurrentOrgId = 10480 //机构id小英9675或4
96
+		adminUserInfo.CurrentOrgId = 10633 //机构id小英9675或4
97 97
 		adminUserInfo.CurrentAppId = 14    //4
98 98
 		adminUserInfo.AdminUser = &userAdmin
99 99
 		adminUserInfo.Subscibes = subscibes
@@ -329,7 +329,7 @@ func (this *BaseServeAPIController) Prepare() {
329 329
 		userAdmin.ModifyTime = 1530786071
330 330
 		var subscibe models.ServeSubscibe
331 331
 		subscibe.ID = 11
332
-		subscibe.OrgId = 10480 //机构id小英9675或4
332
+		subscibe.OrgId = 10633 //机构id小英9675或4
333 333
 		subscibe.PeriodStart = 1538035409
334 334
 		subscibe.PeriodEnd = 1569571409
335 335
 		subscibe.State = 1
@@ -339,7 +339,7 @@ func (this *BaseServeAPIController) Prepare() {
339 339
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
340 340
 		subscibes[4] = &subscibe
341 341
 		var adminUserInfo service.AdminUserInfo
342
-		adminUserInfo.CurrentOrgId = 10480 //机构id小英9675或4
342
+		adminUserInfo.CurrentOrgId = 10633 //机构id小英9675或4
343 343
 		adminUserInfo.CurrentAppId = 14    //4
344 344
 		adminUserInfo.AdminUser = &userAdmin
345 345
 		adminUserInfo.Subscibes = subscibes

+ 39 - 0
controllers/dialysis_api_controller.go View File

@@ -146,6 +146,8 @@ func DialysisApiRegistRouters() {
146 146
 	beego.Router("/api/getpatientdialysisrecordlist", &DialysisApiController{}, "Get:GetPatientDialysisRecordList")
147 147
 
148 148
 	beego.Router("/api/patient/getpatientrecordlist", &DialysisApiController{}, "Get:GetPatientRecordList")
149
+
150
+	beego.Router("/api/patient/getdialysistotalcount", &DialysisApiController{}, "Get:GetDialysisTotalCount")
149 151
 }
150 152
 
151 153
 func (c *DialysisApiController) GetQueueCall() {
@@ -7697,3 +7699,40 @@ func (this *DialysisApiController) GetPatientRecordList() {
7697 7699
 	})
7698 7700
 
7699 7701
 }
7702
+
7703
+func (this *DialysisApiController) GetDialysisTotalCount() {
7704
+
7705
+	timeLayout := "2006-01-02"
7706
+	loc, _ := time.LoadLocation("Local")
7707
+
7708
+	start_time := this.GetString("start_time")
7709
+
7710
+	end_time := this.GetString("end_time")
7711
+
7712
+	patient_id, _ := this.GetInt64("patient_id")
7713
+
7714
+	var startdateunix int64
7715
+	if len(start_time) > 0 {
7716
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
7717
+		if err != nil {
7718
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
7719
+			return
7720
+		}
7721
+		startdateunix = theTime.Unix()
7722
+	}
7723
+	var enddateunix int64
7724
+	if len(end_time) > 0 {
7725
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
7726
+		if err != nil {
7727
+			utils.ErrorLog(err.Error())
7728
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
7729
+			return
7730
+		}
7731
+		enddateunix = theTime.Unix()
7732
+	}
7733
+	orgId := this.GetAdminUserInfo().CurrentOrgId
7734
+	order, _ := service.GetDialysisTotalCountByTime(orgId, startdateunix, enddateunix, patient_id)
7735
+	this.ServeSuccessJSON(map[string]interface{}{
7736
+		"order": order,
7737
+	})
7738
+}

+ 369 - 389
controllers/his_api_controller.go View File

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

+ 6 - 1
controllers/his_project_api_controller.go View File

@@ -1207,8 +1207,13 @@ func (this *HisProjectApiController) ChangePatient() {
1207 1207
 func (this *HisProjectApiController) GetPatientcaseHistory() {
1208 1208
 
1209 1209
 	patient_id, _ := this.GetInt64("patient_id")
1210
+	record_date := this.GetString("record_date")
1211
+	timeLayout := "2006-01-02"
1212
+	loc, _ := time.LoadLocation("Local")
1213
+	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
1214
+
1210 1215
 	patient, err := service.GetBloodPatientInfoById(patient_id)
1211
-	history, _ := service.GetPatientCaseHistory(patient_id)
1216
+	history, _ := service.GetPatientCaseHistory(patient_id, startTime.Unix())
1212 1217
 	hispatient, _ := service.GetHisPatientById(patient_id)
1213 1218
 
1214 1219
 	//获取患者最后一次的血管通路

+ 2 - 0
controllers/mobile_api_controllers/dialysis_api_controller.go View File

@@ -2811,6 +2811,8 @@ func (c *DialysisAPIController) Finish() {
2811 2811
 		tempassessmentAfterDislysis.BloodFlow = lastAssessmentAfterDislysis.BloodFlow
2812 2812
 		tempassessmentAfterDislysis.SealingFluidDispose = lastAssessmentAfterDislysis.SealingFluidDispose
2813 2813
 		tempassessmentAfterDislysis.SealingFluidSpecial = lastAssessmentAfterDislysis.SealingFluidSpecial
2814
+		tempassessmentAfterDislysis.Ktv = lastAssessmentAfterDislysis.Ktv
2815
+		tempassessmentAfterDislysis.Urr = lastAssessmentAfterDislysis.Urr
2814 2816
 		if tempassessmentAfterDislysis.PatientId == 18695 {
2815 2817
 			tempassessmentAfterDislysis.ActualDisplacement = 0
2816 2818
 		}

+ 37 - 0
controllers/new_mobile_api_controllers/staff_schedule_api_controller.go View File

@@ -1547,3 +1547,40 @@ func (c *StaffScheduleApiController) GetPatientMap() {
1547 1547
 	})
1548 1548
 	return
1549 1549
 }
1550
+
1551
+func (c *StaffScheduleApiController) GetMobileDialysisCount() {
1552
+
1553
+	timeLayout := "2006-01-02"
1554
+	loc, _ := time.LoadLocation("Local")
1555
+
1556
+	start_time := c.GetString("start_time")
1557
+
1558
+	end_time := c.GetString("end_time")
1559
+
1560
+	patient_id, _ := c.GetInt64("patient_id")
1561
+
1562
+	var startdateunix int64
1563
+	if len(start_time) > 0 {
1564
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
1565
+		if err != nil {
1566
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1567
+			return
1568
+		}
1569
+		startdateunix = theTime.Unix()
1570
+	}
1571
+	var enddateunix int64
1572
+	if len(end_time) > 0 {
1573
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
1574
+		if err != nil {
1575
+			utils.ErrorLog(err.Error())
1576
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1577
+			return
1578
+		}
1579
+		enddateunix = theTime.Unix()
1580
+	}
1581
+	orgId := c.GetMobileAdminUserInfo().Org.Id
1582
+	order, _ := service.GetDialysisTotalCountByTime(orgId, startdateunix, enddateunix, patient_id)
1583
+	c.ServeSuccessJSON(map[string]interface{}{
1584
+		"order": order,
1585
+	})
1586
+}

+ 2 - 0
controllers/new_mobile_api_controllers/staff_schedule_api_router.go View File

@@ -40,4 +40,6 @@ func StaffScheduleApiControllersRegisterRouters() {
40 40
 
41 41
 	beego.Router("m/api/patient/getpatientmap", &StaffScheduleApiController{}, "Get:GetPatientMap")
42 42
 
43
+	beego.Router("/m/api/patient/getmobiledialysiscount", &StaffScheduleApiController{}, "Get:GetMobileDialysisCount")
44
+
43 45
 }

+ 6 - 6
controllers/sign_api_controller.go View File

@@ -1244,12 +1244,12 @@ func (this *SignApiController) ToAutoDiagnose() {
1244 1244
 	//	service.UpdateScheduleByOrder(item.PatientId, item.DialysisDate, orgId, item.BedId, item.ZoneId, item.SchedualType, schedule.ID)
1245 1245
 	//}
1246 1246
 
1247
-	//drugList, _ := service.GetAllBaseDrugList(10653)
1248
-	//for _, item := range drugList {
1249
-	//	service.UpdateDrugWarehouseInfoByDrug(item.ID, item.MinPrice, item.OrgId)
1250
-	//
1251
-	//	//service.UpdateHisDoctorAdviceOne(item.ID, item.MinPrice, item.OrgId)
1252
-	//}
1247
+	drugList, _ := service.GetAllBaseDrugList(10318)
1248
+	for _, item := range drugList {
1249
+		service.UpdateDrugWarehouseInfoByDrug(item.ID, item.MinPrice, item.OrgId)
1250
+
1251
+		//service.UpdateHisDoctorAdviceOne(item.ID, item.MinPrice, item.OrgId)
1252
+	}
1253 1253
 
1254 1254
 	//goodList, _ := service.GetAllGoodList(10571)
1255 1255
 	//for _, item := range goodList {

+ 25 - 0
models/schedule_models.go View File

@@ -150,6 +150,31 @@ func (SchedulePatients) TableName() string {
150 150
 	return "xt_schedule"
151 151
 }
152 152
 
153
+type XtTreatmentMode struct {
154
+	ID                  int64  `gorm:"column:id" json:"id" form:"id"`
155
+	Name                string `gorm:"column:name" json:"name" form:"name"`
156
+	DialysisDuration    int64  `gorm:"column:dialysis_duration" json:"dialysis_duration" form:"dialysis_duration"`
157
+	ReplacementWay      int64  `gorm:"column:replacement_way" json:"replacement_way" form:"replacement_way"`
158
+	HemodialysisMachine int64  `gorm:"column:hemodialysis_machine" json:"hemodialysis_machine" form:"hemodialysis_machine"`
159
+	BloodFilter         int64  `gorm:"column:blood_filter" json:"blood_filter" form:"blood_filter"`
160
+	PerfusionApparatus  int64  `gorm:"column:perfusion_apparatus" json:"perfusion_apparatus" form:"perfusion_apparatus"`
161
+	BloodFlowVolume     int64  `gorm:"column:blood_flow_volume" json:"blood_flow_volume" form:"blood_flow_volume"`
162
+	DialysateFlow       int64  `gorm:"column:dialysate_flow" json:"dialysate_flow" form:"dialysate_flow"`
163
+	Kalium              int64  `gorm:"column:kalium" json:"kalium" form:"kalium"`
164
+	Sodium              int64  `gorm:"column:sodium" json:"sodium" form:"sodium"`
165
+	Calcium             int64  `gorm:"column:calcium" json:"calcium" form:"calcium"`
166
+	Bicarbonate         int64  `gorm:"column:bicarbonate" json:"bicarbonate" form:"bicarbonate"`
167
+	Remark              string `gorm:"column:remark" json:"remark" form:"remark"`
168
+	Status              int64  `gorm:"column:status" json:"status" form:"status"`
169
+	CreatedTime         int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
170
+	UpdatedTime         int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
171
+	ModeID              int64  `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
172
+}
173
+
174
+func (XtTreatmentMode) TableName() string {
175
+	return "xt_treatment_mode"
176
+}
177
+
153 178
 type PatientSchedule struct {
154 179
 	Schedule
155 180
 

+ 11 - 3
service/his_project_service.go View File

@@ -1,9 +1,10 @@
1 1
 package service
2 2
 
3 3
 import (
4
+	"time"
5
+
4 6
 	"XT_New/models"
5 7
 	"github.com/jinzhu/gorm"
6
-	"time"
7 8
 )
8 9
 
9 10
 func GetHisProjectIsExist(projectName string, orgid int64) (*models.XtHisProject, error) {
@@ -366,10 +367,17 @@ func GetBloodPatientInfoById(patientid int64) (models.XtPatients, error) {
366 367
 	return patients, err
367 368
 }
368 369
 
369
-func GetPatientCaseHistory(patientid int64) (models.HisPatientCaseHistory, error) {
370
+func GetPatientCaseHistory(patientid int64, record_date int64) (models.HisPatientCaseHistory, error) {
370 371
 
371 372
 	history := models.HisPatientCaseHistory{}
372
-	err := XTReadDB().Model(&history).Where("patient_id = ? and status = 1", patientid).Last(&history).Error
373
+	db := XTReadDB().Model(&history).Where("status=1")
374
+	if patientid > 0 {
375
+		db = db.Where("patient_id =?", patientid)
376
+	}
377
+	if record_date > 0 {
378
+		db = db.Where("record_date = ?", record_date)
379
+	}
380
+	err := db.Last(&history).Error
373 381
 	return history, err
374 382
 }
375 383
 

+ 21 - 0
service/patient_service.go View File

@@ -4052,3 +4052,24 @@ func GetMonitorRecordList(patient_id int64, monitor_date int64, user_org_id int6
4052 4052
 	err = XTReadDB().Where("patient_id = ? and user_org_id =? and monitoring_date = ? and status =1", patient_id, user_org_id, monitor_date).Find(&monitor).Error
4053 4053
 	return monitor, err
4054 4054
 }
4055
+
4056
+func GetDialysisTotalCountByTime(user_org_id int64, start_time int64, end_time int64, patient_id int64) (order []*models.XtDialysisOrder, err error) {
4057
+
4058
+	db := XTReadDB().Table("xt_dialysis_order").Where("status =1")
4059
+	if user_org_id > 0 {
4060
+		db = db.Where("user_org_id =?", user_org_id)
4061
+	}
4062
+	if start_time > 0 {
4063
+		db = db.Where("dialysis_date >=?", start_time)
4064
+	}
4065
+	if end_time > 0 {
4066
+		db = db.Where("dialysis_date <=?", end_time)
4067
+	}
4068
+	if patient_id > 0 {
4069
+		db = db.Where("patient_id = ?", patient_id)
4070
+	}
4071
+
4072
+	err = db.Find(&order).Error
4073
+
4074
+	return order, err
4075
+}

+ 13 - 13
service/schedule_service.go View File

@@ -575,19 +575,19 @@ func (WeekSchedulePrintDeviceNumber) TableName() string {
575 575
 }
576 576
 
577 577
 type WeekSchedulePrintVMTwo struct {
578
-	ID             int64 `gorm:"column:id" json:"id"`
579
-	ZoneID         int64 `gorm:"column:partition_id" json:"zone_id"`
580
-	DeviceNumberID int64 `gorm:"column:bed_id" json:"device_number_id"`
581
-	PatientID      int64 `gorm:"column:patient_id" json:"patient_id"`
582
-	ScheduleDate   int64 `gorm:"column:schedule_date" json:"schedule_date"`
583
-	ScheduleType   int64 `gorm:"column:schedule_type" json:"schedule_type"`
584
-	ScheduleWeek   int64 `gorm:"column:schedule_week" json:"schedule_week"`
585
-	ModeID         int64 `gorm:"column:mode_id" json:"mode_id"`
586
-
587
-	Patient      *WeekSchedulePrintPatients     `gorm:"ForeignKey:PatientID" json:"patient"`
588
-	DeviceNumber *WeekSchedulePrintDeviceNumber `gorm:"ForeignKey:DeviceNumberID" json:"device_number"`
589
-	Zone         *models.DeviceZone             `gorm:"ForeignKey:ZoneID" json:"zone"`
590
-	Mode         *models.TreatmentMode          `gorm:"ForeignKey:ModeID" json:"mode"`
578
+	ID             int64                          `gorm:"column:id" json:"id"`
579
+	ZoneID         int64                          `gorm:"column:partition_id" json:"zone_id"`
580
+	DeviceNumberID int64                          `gorm:"column:bed_id" json:"device_number_id"`
581
+	PatientID      int64                          `gorm:"column:patient_id" json:"patient_id"`
582
+	ScheduleDate   int64                          `gorm:"column:schedule_date" json:"schedule_date"`
583
+	ScheduleType   int64                          `gorm:"column:schedule_type" json:"schedule_type"`
584
+	ScheduleWeek   int64                          `gorm:"column:schedule_week" json:"schedule_week"`
585
+	ModeID         int64                          `gorm:"column:mode_id" json:"mode_id"`
586
+	Patient        *WeekSchedulePrintPatients     `gorm:"ForeignKey:PatientID" json:"patient"`
587
+	DeviceNumber   *WeekSchedulePrintDeviceNumber `gorm:"ForeignKey:DeviceNumberID" json:"device_number"`
588
+	Zone           *models.DeviceZone             `gorm:"ForeignKey:ZoneID" json:"zone"`
589
+	//Mode           *models.TreatmentMode          `gorm:"ForeignKey:ModeID" json:"mode"`
590
+	Mode *models.XtTreatmentMode `json:"mode" gorm:"foreignkey:ModeID,ModeID;AssociationForeignKey:ModeID,ModeID"`
591 591
 }
592 592
 
593 593
 type PrintCount struct {

+ 1 - 1
service/secondary_service.go View File

@@ -1153,7 +1153,7 @@ func DeleteSecondOrderInfo(id int64) error {
1153 1153
 
1154 1154
 func GetStockFlowOrderList(good_id int64, user_org_id int64) (list []*models.VmStockFlow, err error) {
1155 1155
 
1156
-	err = XTReadDB().Where("good_id = ? and user_org_id =?  and status=1", good_id, user_org_id).Order("id asc").Find(&list).Error
1156
+	err = XTReadDB().Where("good_id = ? and user_org_id =?  and status=1 and ctime>=1711900800", good_id, user_org_id).Order("id asc").Find(&list).Error
1157 1157
 	return list, err
1158 1158
 }
1159 1159
 

+ 3 - 2
service/statistis_qc_service.go View File

@@ -1,13 +1,14 @@
1 1
 package service
2 2
 
3 3
 import (
4
-	"XT_New/models"
5 4
 	"database/sql"
6 5
 	"fmt"
7
-	"github.com/jinzhu/gorm"
8 6
 	"reflect"
9 7
 	"strings"
10 8
 	"time"
9
+
10
+	"XT_New/models"
11
+	"github.com/jinzhu/gorm"
11 12
 )
12 13
 
13 14
 func GetDialysisTotalDatas() {