Browse Source

Merge branch '20230223_xt_api_new_branch' of http://git.shengws.com/csx/XT_New into 20230223_xt_api_new_branch

陈少旭 9 months ago
parent
commit
5d22ea9001

+ 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

@@ -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
 						}

+ 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() {