浏览代码

历史排班

28169 1年前
父节点
当前提交
3d10b601dd

+ 6 - 6
controllers/base_api_controller.go 查看文件

82
 		userAdmin.ModifyTime = 1530786071
82
 		userAdmin.ModifyTime = 1530786071
83
 		var subscibe models.ServeSubscibe
83
 		var subscibe models.ServeSubscibe
84
 		subscibe.ID = 11
84
 		subscibe.ID = 11
85
-		subscibe.OrgId = 10164 //机构id 10344
85
+		subscibe.OrgId = 10510 //机构id 10344
86
 		subscibe.PeriodStart = 1547447814
86
 		subscibe.PeriodStart = 1547447814
87
 		subscibe.PeriodEnd = 1550039814
87
 		subscibe.PeriodEnd = 1550039814
88
 		subscibe.State = 1
88
 		subscibe.State = 1
92
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
92
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
93
 		subscibes[4] = &subscibe
93
 		subscibes[4] = &subscibe
94
 		var adminUserInfo service.AdminUserInfo
94
 		var adminUserInfo service.AdminUserInfo
95
-		adminUserInfo.CurrentOrgId = 10164 //机构id小英9675或4
96
-		adminUserInfo.CurrentAppId = 12123 //4
95
+		adminUserInfo.CurrentOrgId = 10510 //机构id小英9675或4
96
+		adminUserInfo.CurrentAppId = 11211 //4
97
 		adminUserInfo.AdminUser = &userAdmin
97
 		adminUserInfo.AdminUser = &userAdmin
98
 		adminUserInfo.Subscibes = subscibes
98
 		adminUserInfo.Subscibes = subscibes
99
 		this.SetSession("admin_user_info", &adminUserInfo)
99
 		this.SetSession("admin_user_info", &adminUserInfo)
327
 		userAdmin.ModifyTime = 1530786071
327
 		userAdmin.ModifyTime = 1530786071
328
 		var subscibe models.ServeSubscibe
328
 		var subscibe models.ServeSubscibe
329
 		subscibe.ID = 11
329
 		subscibe.ID = 11
330
-		subscibe.OrgId = 10164 //机构id小英10344或4
330
+		subscibe.OrgId = 10510 //机构id小英10344或4或10666
331
 		subscibe.PeriodStart = 1538035409
331
 		subscibe.PeriodStart = 1538035409
332
 		subscibe.PeriodEnd = 1569571409
332
 		subscibe.PeriodEnd = 1569571409
333
 		subscibe.State = 1
333
 		subscibe.State = 1
337
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
337
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
338
 		subscibes[4] = &subscibe
338
 		subscibes[4] = &subscibe
339
 		var adminUserInfo service.AdminUserInfo
339
 		var adminUserInfo service.AdminUserInfo
340
-		adminUserInfo.CurrentOrgId = 10164 //机构id小英9675或4
341
-		adminUserInfo.CurrentAppId = 12123 //4
340
+		adminUserInfo.CurrentOrgId = 10510 //机构id小英10344或4或10666
341
+		adminUserInfo.CurrentAppId = 11211 //4
342
 		adminUserInfo.AdminUser = &userAdmin
342
 		adminUserInfo.AdminUser = &userAdmin
343
 		adminUserInfo.Subscibes = subscibes
343
 		adminUserInfo.Subscibes = subscibes
344
 		this.SetSession("admin_user_info", &adminUserInfo)
344
 		this.SetSession("admin_user_info", &adminUserInfo)

+ 2 - 2
controllers/dialysis_api_controller.go 查看文件

542
 			}
542
 			}
543
 
543
 
544
 			if schedulePatient.ScheduleType == 2 {
544
 			if schedulePatient.ScheduleType == 2 {
545
-				advice.StartTime = recordDate.Unix() + 11*60*60
545
+				advice.StartTime = recordDate.Unix() + 9*60*60
546
 			}
546
 			}
547
 		}
547
 		}
548
 		// 抗凝剂名称
548
 		// 抗凝剂名称
1523
 			}
1523
 			}
1524
 
1524
 
1525
 			if schedulePatient.ScheduleType == 2 {
1525
 			if schedulePatient.ScheduleType == 2 {
1526
-				advice.StartTime = recordDate.Unix() + 11*60*60
1526
+				advice.StartTime = recordDate.Unix() + 9*60*60
1527
 			}
1527
 			}
1528
 		}
1528
 		}
1529
 		// 抗凝剂名称
1529
 		// 抗凝剂名称

+ 196 - 115
controllers/his_api_controller.go 查看文件

3301
 						advices := items["advices"].([]interface{})
3301
 						advices := items["advices"].([]interface{})
3302
 						//group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
3302
 						//group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
3303
 						groupNo := int64(0)
3303
 						groupNo := int64(0)
3304
-						ctime := time.Now().Unix()
3305
-						mtime := ctime
3306
 						if len(advices) > 0 {
3304
 						if len(advices) > 0 {
3307
 							for _, advice := range advices {
3305
 							for _, advice := range advices {
3308
 								tx := db.Begin()
3306
 								tx := db.Begin()
3326
 								s.RecordDate = theTime3.Unix()
3324
 								s.RecordDate = theTime3.Unix()
3327
 								s.StartTime = tempPrescription.PreTime
3325
 								s.StartTime = tempPrescription.PreTime
3328
 								s.Groupno = groupNo
3326
 								s.Groupno = groupNo
3329
-								s.CreatedTime = ctime
3330
-								s.UpdatedTime = mtime
3327
+
3331
 								s.PatientId = patient_id
3328
 								s.PatientId = patient_id
3332
 								s.HisPatientId = his_patient_id
3329
 								s.HisPatientId = his_patient_id
3333
 								s.StartTime = pTime
3330
 								s.StartTime = pTime
3380
 									// 查询该药品最后一次出库记录
3377
 									// 查询该药品最后一次出库记录
3381
 									druginfo, _ := service.GetLastDrugWarehouseOutByDrugIdTwenty(s.DrugId, patient_id, recordDateTime, s.ID)
3378
 									druginfo, _ := service.GetLastDrugWarehouseOutByDrugIdTwenty(s.DrugId, patient_id, recordDateTime, s.ID)
3382
 
3379
 
3380
+									var is_user_total int64
3381
+									var no_user_total int64
3382
+
3383
+									//fmt.Println("s-------------------------------------------", s.PrescribingNumber)
3384
+									//fmt.Println("s.PrescribingNumberUnit------------------", s.PrescribingNumberUnit)
3385
+									//fmt.Println("drug.MaxUnit", drug.MaxUnit)
3386
+									//fmt.Println("drug.MinUnit", drug.MinUnit)
3387
+
3388
+									if s.PrescribingNumberUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
3389
+
3390
+										prescribingNumberTenty := strconv.FormatFloat(s.PrescribingNumber, 'f', -1, 64)
3391
+										prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
3392
+
3393
+										no_user_total += prescribingNumberSevenTy * drug.MinNumber
3394
+									}
3395
+
3396
+									if s.PrescribingNumberUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
3397
+
3398
+										prescribingNumberTenty := strconv.FormatFloat(s.PrescribingNumber, 'f', -1, 64)
3399
+										prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
3400
+										no_user_total += prescribingNumberSevenTy
3401
+									}
3402
+
3403
+									if s.PrescribingNumberUnit == drug.MaxUnit && drug.MaxUnit == drug.MinUnit {
3404
+
3405
+										prescribingNumberTenty := strconv.FormatFloat(s.PrescribingNumber, 'f', -1, 64)
3406
+										prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
3407
+										no_user_total += prescribingNumberSevenTy
3408
+									}
3383
 									if len(druginfo) > 0 {
3409
 									if len(druginfo) > 0 {
3384
-										//回退库存
3385
 										for _, it := range druginfo {
3410
 										for _, it := range druginfo {
3386
 											if it.CountUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
3411
 											if it.CountUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
3387
-
3388
-												service.ModifyDrugWarehouseInfoStockMaxNumber(it.Count, it.DrugId, it.OrgId, it.WarehouseInfoId)
3389
-
3412
+												it.Count = it.Count * drug.MinNumber
3413
+												is_user_total += it.Count
3390
 											}
3414
 											}
3391
-											if it.CountUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
3392
-
3393
-												service.ModifyDrugWarehouseInfoStockMinNumber(it.Count, it.DrugId, it.OrgId, it.WarehouseInfoId)
3394
 
3415
 
3416
+											if it.CountUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
3417
+												is_user_total += it.Count
3395
 											}
3418
 											}
3396
-											if it.CountUnit == drug.MaxUnit && drug.MaxUnit == drug.MinUnit {
3397
 
3419
 
3398
-												service.ModifyDrugWarehouseInfoStockMaxNumber(it.Count, it.DrugId, it.OrgId, it.WarehouseInfoId)
3420
+											if it.CountUnit == drug.MaxUnit && drug.MaxUnit == drug.MinUnit {
3421
+												is_user_total += it.Count
3399
 
3422
 
3400
 											}
3423
 											}
3401
 										}
3424
 										}
3402
 
3425
 
3403
-										//删除记录
3404
-										service.DeleteNewDrugAutoWarehouseSeven(s.DrugId, patient_id, recordDateTime, s.ID)
3405
-
3406
 									}
3426
 									}
3407
 
3427
 
3408
-									service.CreateHisDoctorAdviceOne(&s, tx)
3409
-
3410
-									advicelast, _ := service.GetLastHisAdvicesList(s.PatientId, s.AdviceDate, s.UserOrgId, tx)
3411
-
3412
-									//出库
3413
-									if drug.IsUse == 2 {
3414
-										creater := adminInfo.AdminUser.Id
3415
-										newadviceInfo := &models.HisDoctorAdviceInfo{
3416
-											ID:                    advicelast.ID,
3417
-											UserOrgId:             s.UserOrgId,
3418
-											PatientId:             s.PatientId,
3419
-											HisPatientId:          s.HisPatientId,
3420
-											AdviceType:            s.AdviceType,
3421
-											AdviceDate:            s.AdviceDate,
3422
-											StartTime:             s.StartTime,
3423
-											AdviceName:            s.AdviceName,
3424
-											AdviceDesc:            s.AdviceDesc,
3425
-											ReminderDate:          s.ReminderDate,
3426
-											SingleDose:            s.SingleDose,
3427
-											SingleDoseUnit:        s.SingleDoseUnit,
3428
-											PrescribingNumber:     s.PrescribingNumber,
3429
-											PrescribingNumberUnit: s.PrescribingNumberUnit,
3430
-											DeliveryWay:           s.DeliveryWay,
3431
-											ExecutionFrequency:    s.ExecutionFrequency,
3432
-											AdviceDoctor:          s.AdviceDoctor,
3433
-											Status:                s.Status,
3434
-											CreatedTime:           s.CreatedTime,
3435
-											UpdatedTime:           s.UpdatedTime,
3436
-											AdviceAffirm:          s.AdviceAffirm,
3437
-											Remark:                s.Remark,
3438
-											StopTime:              s.StopTime,
3439
-											StopReason:            s.StopReason,
3440
-											StopDoctor:            s.StopDoctor,
3441
-											StopState:             s.StopState,
3442
-											ParentId:              s.ParentId,
3443
-											ExecutionTime:         s.ExecutionTime,
3444
-											ExecutionStaff:        s.ExecutionStaff,
3445
-											ExecutionState:        s.ExecutionState,
3446
-											Checker:               s.Checker,
3447
-											RecordDate:            s.RecordDate,
3448
-											DialysisOrderId:       s.DialysisOrderId,
3449
-											CheckTime:             s.CheckTime,
3450
-											CheckState:            s.CheckState,
3451
-											DrugSpec:              s.DrugSpec,
3452
-											DrugSpecUnit:          s.DrugSpecUnit,
3453
-											Groupno:               s.Groupno,
3454
-											RemindType:            s.RemindType,
3455
-											FrequencyType:         s.FrequencyType,
3456
-											DayCount:              s.DayCount,
3457
-											WeekDay:               s.WeekDay,
3458
-											TemplateId:            s.TemplateId,
3459
-											Modifier:              s.Modifier,
3460
-											DrugId:                s.DrugId,
3461
-											Price:                 s.Price,
3462
-											PrescriptionId:        s.PrescriptionId,
3463
-											MedListCodg:           s.MedListCodg,
3464
-											FeedetlSn:             s.FeedetlSn,
3465
-											Day:                   s.DayCount,
3466
-											ChildDoctorAdvice:     nil,
3467
-											Drug:                  models.Drug{},
3468
-											Diagnosis:             s.Diagnosis,
3469
-											Way:                   s.Way,
3470
-											HospApprFlag:          s.HospApprFlag,
3471
-											LmtUsedFlag:           s.LmtUsedFlag,
3472
-											HisOrderInfo:          models.HisOrderInfo{},
3473
-											IsMedicine:            s.IsMedicine,
3474
-											ExecutionFrequencyId:  s.ExecutionFrequencyId,
3475
-											Child:                 nil,
3476
-											IsSettle:              s.IsSettle,
3477
-											IsMobile:              s.IsMobile,
3478
-											IsSelfDrug:            s.IsSelfDrug,
3479
-											DrugWayCount:          s.DrugWayCount,
3428
+									//fmt.Println("is_user_total-----------------------------", is_user_total)
3429
+									//fmt.Println("no_user_total-----------------------------", no_user_total)
3430
+
3431
+									if is_user_total != no_user_total {
3432
+
3433
+										if len(druginfo) > 0 {
3434
+											//回退库存
3435
+											for _, it := range druginfo {
3436
+												if it.CountUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
3437
+
3438
+													service.ModifyDrugWarehouseInfoStockMaxNumber(it.Count, it.DrugId, it.OrgId, it.WarehouseInfoId)
3439
+
3440
+												}
3441
+												if it.CountUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
3442
+
3443
+													service.ModifyDrugWarehouseInfoStockMinNumber(it.Count, it.DrugId, it.OrgId, it.WarehouseInfoId)
3444
+
3445
+												}
3446
+												if it.CountUnit == drug.MaxUnit && drug.MaxUnit == drug.MinUnit {
3447
+
3448
+													service.ModifyDrugWarehouseInfoStockMaxNumber(it.Count, it.DrugId, it.OrgId, it.WarehouseInfoId)
3449
+
3450
+												}
3451
+											}
3452
+
3453
+											//删除记录
3454
+											service.DeleteNewDrugAutoWarehouseSeven(s.DrugId, patient_id, recordDateTime, s.ID)
3455
+
3480
 										}
3456
 										}
3481
 
3457
 
3482
-										service.NewHisDrugsDelivery(s.UserOrgId, creater, newadviceInfo, tx)
3458
+										service.CreateHisDoctorAdviceOne(&s, tx)
3459
+
3460
+										advicelast, _ := service.GetLastHisAdvicesList(s.PatientId, s.AdviceDate, s.UserOrgId, tx)
3461
+
3462
+										//出库
3463
+										if drug.IsUse == 2 {
3464
+											creater := adminInfo.AdminUser.Id
3465
+											newadviceInfo := &models.HisDoctorAdviceInfo{
3466
+												ID:                    advicelast.ID,
3467
+												UserOrgId:             s.UserOrgId,
3468
+												PatientId:             s.PatientId,
3469
+												HisPatientId:          s.HisPatientId,
3470
+												AdviceType:            s.AdviceType,
3471
+												AdviceDate:            s.AdviceDate,
3472
+												StartTime:             s.StartTime,
3473
+												AdviceName:            s.AdviceName,
3474
+												AdviceDesc:            s.AdviceDesc,
3475
+												ReminderDate:          s.ReminderDate,
3476
+												SingleDose:            s.SingleDose,
3477
+												SingleDoseUnit:        s.SingleDoseUnit,
3478
+												PrescribingNumber:     s.PrescribingNumber,
3479
+												PrescribingNumberUnit: s.PrescribingNumberUnit,
3480
+												DeliveryWay:           s.DeliveryWay,
3481
+												ExecutionFrequency:    s.ExecutionFrequency,
3482
+												AdviceDoctor:          s.AdviceDoctor,
3483
+												Status:                s.Status,
3484
+												CreatedTime:           s.CreatedTime,
3485
+												UpdatedTime:           s.UpdatedTime,
3486
+												AdviceAffirm:          s.AdviceAffirm,
3487
+												Remark:                s.Remark,
3488
+												StopTime:              s.StopTime,
3489
+												StopReason:            s.StopReason,
3490
+												StopDoctor:            s.StopDoctor,
3491
+												StopState:             s.StopState,
3492
+												ParentId:              s.ParentId,
3493
+												ExecutionTime:         s.ExecutionTime,
3494
+												ExecutionStaff:        s.ExecutionStaff,
3495
+												ExecutionState:        s.ExecutionState,
3496
+												Checker:               s.Checker,
3497
+												RecordDate:            s.RecordDate,
3498
+												DialysisOrderId:       s.DialysisOrderId,
3499
+												CheckTime:             s.CheckTime,
3500
+												CheckState:            s.CheckState,
3501
+												DrugSpec:              s.DrugSpec,
3502
+												DrugSpecUnit:          s.DrugSpecUnit,
3503
+												Groupno:               s.Groupno,
3504
+												RemindType:            s.RemindType,
3505
+												FrequencyType:         s.FrequencyType,
3506
+												DayCount:              s.DayCount,
3507
+												WeekDay:               s.WeekDay,
3508
+												TemplateId:            s.TemplateId,
3509
+												Modifier:              s.Modifier,
3510
+												DrugId:                s.DrugId,
3511
+												Price:                 s.Price,
3512
+												PrescriptionId:        s.PrescriptionId,
3513
+												MedListCodg:           s.MedListCodg,
3514
+												FeedetlSn:             s.FeedetlSn,
3515
+												Day:                   s.DayCount,
3516
+												ChildDoctorAdvice:     nil,
3517
+												Drug:                  models.Drug{},
3518
+												Diagnosis:             s.Diagnosis,
3519
+												Way:                   s.Way,
3520
+												HospApprFlag:          s.HospApprFlag,
3521
+												LmtUsedFlag:           s.LmtUsedFlag,
3522
+												HisOrderInfo:          models.HisOrderInfo{},
3523
+												IsMedicine:            s.IsMedicine,
3524
+												ExecutionFrequencyId:  s.ExecutionFrequencyId,
3525
+												Child:                 nil,
3526
+												IsSettle:              s.IsSettle,
3527
+												IsMobile:              s.IsMobile,
3528
+												IsSelfDrug:            s.IsSelfDrug,
3529
+												DrugWayCount:          s.DrugWayCount,
3530
+											}
3483
 
3531
 
3484
-									}
3532
+											service.NewHisDrugsDelivery(s.UserOrgId, creater, newadviceInfo, tx)
3485
 
3533
 
3486
-									//更新字典里面的库存
3487
-									stockInfo, _ := service.GetNewDrugAllStockInfo(storeConfig.DrugStorehouseOut, s.UserOrgId, s.DrugId, tx)
3488
-									var sum_count int64
3489
-									for _, its := range stockInfo {
3490
-										baseDrug, _ := service.GetNewBaseDrugMedical(its.DrugId, tx)
3491
-										if its.MaxUnit == baseDrug.MaxUnit {
3492
-											its.StockMaxNumber = its.StockMaxNumber * baseDrug.MinNumber
3493
 										}
3534
 										}
3494
-										sum_count += its.StockMaxNumber + its.StockMinNumber
3495
-									}
3496
-									//更新基础库存
3497
-									service.UpdateNewBaseDrugSumTwo(s.DrugId, sum_count, s.UserOrgId, tx)
3498
-									//剩余库存
3499
-									service.UpdateNewDrugStockCount(s.DrugId, s.UserOrgId, storeConfig.DrugStorehouseOut, sum_count, tx)
3500
 
3535
 
3501
-									over, _ := service.FindNewOverCount(s.DrugId, s.UserOrgId, storeConfig.DrugStorehouseOut, tx)
3502
-									service.UpdateNewActOut(over.ID, over.SumInCount, over.FlushCount, over.SumCancelCount, tx)
3536
+										//更新字典里面的库存
3537
+										stockInfo, _ := service.GetNewDrugAllStockInfo(storeConfig.DrugStorehouseOut, s.UserOrgId, s.DrugId, tx)
3538
+										var sum_count int64
3539
+										for _, its := range stockInfo {
3540
+											baseDrug, _ := service.GetNewBaseDrugMedical(its.DrugId, tx)
3541
+											if its.MaxUnit == baseDrug.MaxUnit {
3542
+												its.StockMaxNumber = its.StockMaxNumber * baseDrug.MinNumber
3543
+											}
3544
+											sum_count += its.StockMaxNumber + its.StockMinNumber
3545
+										}
3546
+										//更新基础库存
3547
+										service.UpdateNewBaseDrugSumTwo(s.DrugId, sum_count, s.UserOrgId, tx)
3548
+										//剩余库存
3549
+										service.UpdateNewDrugStockCount(s.DrugId, s.UserOrgId, storeConfig.DrugStorehouseOut, sum_count, tx)
3550
+
3551
+										over, _ := service.FindNewOverCount(s.DrugId, s.UserOrgId, storeConfig.DrugStorehouseOut, tx)
3552
+										service.UpdateNewActOut(over.ID, over.SumInCount, over.FlushCount, over.SumCancelCount, tx)
3503
 
3553
 
3554
+									}
3504
 								}
3555
 								}
3505
 
3556
 
3506
 								//记录日志
3557
 								//记录日志
3612
 
3663
 
3613
 								var p models.HisPrescriptionProject
3664
 								var p models.HisPrescriptionProject
3614
 								p.PrescriptionId = tempPrescription.ID
3665
 								p.PrescriptionId = tempPrescription.ID
3615
-								p.Ctime = time.Now().Unix()
3616
-								p.Mtime = time.Now().Unix()
3666
+
3617
 								p.PatientId = patient_id
3667
 								p.PatientId = patient_id
3618
 								p.RecordDate = theTime3.Unix()
3668
 								p.RecordDate = theTime3.Unix()
3619
 								p.Doctor = doctor_id
3669
 								p.Doctor = doctor_id
4103
 						advices := items["advices"].([]interface{})
4153
 						advices := items["advices"].([]interface{})
4104
 						//group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
4154
 						//group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
4105
 						groupNo := int64(0)
4155
 						groupNo := int64(0)
4106
-						ctime := time.Now().Unix()
4107
-						mtime := ctime
4108
 						if len(advices) > 0 {
4156
 						if len(advices) > 0 {
4109
 							for _, advice := range advices {
4157
 							for _, advice := range advices {
4110
 								var s models.HisDoctorAdviceInfo
4158
 								var s models.HisDoctorAdviceInfo
4119
 								s.RecordDate = theTime3.Unix()
4167
 								s.RecordDate = theTime3.Unix()
4120
 								s.StartTime = tempPrescription.PreTime
4168
 								s.StartTime = tempPrescription.PreTime
4121
 								s.Groupno = groupNo
4169
 								s.Groupno = groupNo
4122
-								s.CreatedTime = ctime
4123
-								s.UpdatedTime = mtime
4170
+
4124
 								s.PatientId = patient_id
4171
 								s.PatientId = patient_id
4125
 								s.HisPatientId = his_patient_id
4172
 								s.HisPatientId = his_patient_id
4126
 								s.StartTime = pTime
4173
 								s.StartTime = pTime
4214
 
4261
 
4215
 								var p models.HisPrescriptionProject
4262
 								var p models.HisPrescriptionProject
4216
 								p.PrescriptionId = tempPrescription.ID
4263
 								p.PrescriptionId = tempPrescription.ID
4217
-								p.Ctime = time.Now().Unix()
4218
-								p.Mtime = time.Now().Unix()
4264
+
4219
 								p.PatientId = patient_id
4265
 								p.PatientId = patient_id
4220
 								p.RecordDate = theTime3.Unix()
4266
 								p.RecordDate = theTime3.Unix()
4221
 								p.Doctor = doctor_id
4267
 								p.Doctor = doctor_id
6918
 							advice.CheckTime = 0
6964
 							advice.CheckTime = 0
6919
 							advice.Checker = 0
6965
 							advice.Checker = 0
6920
 							advice.CheckState = 2
6966
 							advice.CheckState = 2
6967
+							advice.UpdatedTime = time.Now().Unix()
6921
 						}
6968
 						}
6922
 					}
6969
 					}
6923
 
6970
 
7306
 			hisAdvice, err := service.GetHisDoctorAdvicesById(advice.ID)
7353
 			hisAdvice, err := service.GetHisDoctorAdvicesById(advice.ID)
7307
 			if err == nil {
7354
 			if err == nil {
7308
 				if hisAdvice.ID > 0 {
7355
 				if hisAdvice.ID > 0 {
7309
-
7310
 					advice.ExecutionTime = hisAdvice.ExecutionTime
7356
 					advice.ExecutionTime = hisAdvice.ExecutionTime
7311
 					advice.ExecutionStaff = hisAdvice.ExecutionStaff
7357
 					advice.ExecutionStaff = hisAdvice.ExecutionStaff
7312
 					advice.ExecutionState = hisAdvice.ExecutionState
7358
 					advice.ExecutionState = hisAdvice.ExecutionState
7333
 							advice.CheckTime = 0
7379
 							advice.CheckTime = 0
7334
 							advice.Checker = 0
7380
 							advice.Checker = 0
7335
 							advice.CheckState = 2
7381
 							advice.CheckState = 2
7382
+							//advice.UpdatedTime = time.Now().Unix()
7383
+							advice.CreatedTime = hisAdvice.CreatedTime
7384
+							advice.UpdatedTime = time.Now().Unix()
7385
+						} else {
7386
+							advice.CreatedTime = hisAdvice.CreatedTime
7387
+							advice.UpdatedTime = hisAdvice.UpdatedTime
7388
+
7336
 						}
7389
 						}
7337
 					}
7390
 					}
7338
-
7339
 					//advice.Groupno = hisAdvice.Groupno
7391
 					//advice.Groupno = hisAdvice.Groupno
7392
+				} else {
7393
+					ctime := time.Now().Unix()
7394
+					advice.CreatedTime = ctime
7395
+					advice.UpdatedTime = ctime
7340
 
7396
 
7341
 				}
7397
 				}
7342
 			}
7398
 			}
7399
+		} else {
7400
+			ctime := time.Now().Unix()
7401
+			advice.CreatedTime = ctime
7402
+			advice.UpdatedTime = ctime
7403
+
7343
 		}
7404
 		}
7344
 	}
7405
 	}
7345
 
7406
 
7484
 		project.CheckState = temp_project.CheckState
7545
 		project.CheckState = temp_project.CheckState
7485
 		project.CheckTime = temp_project.CheckTime
7546
 		project.CheckTime = temp_project.CheckTime
7486
 		project.TeamId = temp_project.TeamId
7547
 		project.TeamId = temp_project.TeamId
7548
+
7487
 	}
7549
 	}
7488
 	if json["type"] != nil || reflect.TypeOf(json["type"]).String() == "float64" {
7550
 	if json["type"] != nil || reflect.TypeOf(json["type"]).String() == "float64" {
7489
 		types := int64(json["type"].(float64))
7551
 		types := int64(json["type"].(float64))
7599
 	//	}
7661
 	//	}
7600
 	//
7662
 	//
7601
 	//}
7663
 	//}
7664
+	if json["id"] != nil || reflect.TypeOf(json["id"]).String() == "float64" {
7665
+		id := int64(json["id"].(float64))
7666
+		if id > 0 {
7667
+			temp_project, _ := service.GetHisPrescriptionProjectByID(id)
7668
+
7669
+			if temp_project.ExecutionFrequency != project.ExecutionFrequency || temp_project.Count != project.Count || temp_project.Remark != project.Remark {
7670
+				fmt.Println("666666")
7671
+				project.Mtime = time.Now().Unix()
7672
+				project.Ctime = temp_project.Ctime
7602
 
7673
 
7674
+			} else {
7675
+				project.Mtime = temp_project.Mtime
7676
+				project.Ctime = temp_project.Ctime
7677
+			}
7678
+		} else {
7679
+			ctime := time.Now().Unix()
7680
+			project.Mtime = ctime
7681
+			project.Ctime = ctime
7682
+		}
7683
+	}
7603
 	return 0
7684
 	return 0
7604
 }
7685
 }
7605
 
7686
 

+ 213 - 0
controllers/his_export_data_controller.go 查看文件

1
 package controllers
1
 package controllers
2
 
2
 
3
 import (
3
 import (
4
+	"XT_New/enums"
5
+	"XT_New/models"
4
 	"XT_New/service"
6
 	"XT_New/service"
5
 	"github.com/astaxie/beego"
7
 	"github.com/astaxie/beego"
8
+	"github.com/shopspring/decimal"
9
+	"strings"
6
 )
10
 )
7
 
11
 
8
 type HisExportDataController struct {
12
 type HisExportDataController struct {
12
 func HisExportDataApiRegistRouters() {
16
 func HisExportDataApiRegistRouters() {
13
 
17
 
14
 	beego.Router("/api/export", &HisExportDataController{}, "Get:GetExportData")
18
 	beego.Router("/api/export", &HisExportDataController{}, "Get:GetExportData")
19
+
20
+	beego.Router("/api/batchsettle/get", &HisExportDataController{}, "Get:GetExportSettleData")
21
+
22
+}
23
+
24
+func (c *HisExportDataController) GetExportSettleData() {
25
+	patient_id, _ := c.GetInt64("patient_id", 0)
26
+	start_time := c.GetString("start_time")
27
+	end_time := c.GetString("end_time")
28
+	admin_user_id, _ := c.GetInt64("admin_user_id")
29
+
30
+	var order models.HisOrder
31
+	orders, _ := service.GetHisOrderByTime(patient_id, start_time, end_time)
32
+	order = orders[len(orders)-1]
33
+	order.MedfeeSumamt = 0
34
+	order.FundPaySumamt = 0
35
+	order.PsnCashPay = 0
36
+	order.ActPayDedc = 0
37
+	order.PreselfpayAmt = 0
38
+	order.HifpPay = 0
39
+	order.HifmiPay = 0
40
+	order.HifesPay = 0
41
+	order.MafPay = 0
42
+	order.CvlservPay = 0
43
+	order.OthPay = 0
44
+	order.AcctPay = 0
45
+
46
+	decimal.DivisionPrecision = 2
47
+
48
+	var orderInfos []models.BatchHisOrderInfo
49
+	for _, item := range orders {
50
+		order.MedfeeSumamt, _ = decimal.NewFromFloat(order.MedfeeSumamt).Add(decimal.NewFromFloat(item.MedfeeSumamt)).Float64()
51
+		order.FundPaySumamt, _ = decimal.NewFromFloat(order.FundPaySumamt).Add(decimal.NewFromFloat(item.FundPaySumamt)).Float64()
52
+		order.PsnCashPay, _ = decimal.NewFromFloat(order.PsnCashPay).Add(decimal.NewFromFloat(item.PsnCashPay)).Float64()
53
+		order.ActPayDedc, _ = decimal.NewFromFloat(order.ActPayDedc).Add(decimal.NewFromFloat(item.ActPayDedc)).Float64()
54
+		order.PreselfpayAmt, _ = decimal.NewFromFloat(order.PreselfpayAmt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
55
+		order.HifpPay, _ = decimal.NewFromFloat(order.HifpPay).Add(decimal.NewFromFloat(item.HifpPay)).Float64()
56
+
57
+		order.HifmiPay, _ = decimal.NewFromFloat(order.HifmiPay).Add(decimal.NewFromFloat(item.HifmiPay)).Float64()
58
+		order.HifesPay, _ = decimal.NewFromFloat(order.HifesPay).Add(decimal.NewFromFloat(item.HifesPay)).Float64()
59
+		order.MafPay, _ = decimal.NewFromFloat(order.MafPay).Add(decimal.NewFromFloat(item.MafPay)).Float64()
60
+		order.CvlservPay, _ = decimal.NewFromFloat(order.CvlservPay).Add(decimal.NewFromFloat(item.CvlservPay)).Float64()
61
+		order.OthPay, _ = decimal.NewFromFloat(order.OthPay).Add(decimal.NewFromFloat(item.OthPay)).Float64()
62
+		order.AcctPay, _ = decimal.NewFromFloat(order.AcctPay).Add(decimal.NewFromFloat(item.AcctPay)).Float64()
63
+
64
+		orderInfo, _ := service.GetBatchHisOrderInfoByNumber(item.Number)
65
+		orderInfos = append(orderInfos, orderInfo...)
66
+	}
67
+	//role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, c.GetAdminUserInfo().AdminUser.Id)
68
+	if order.ID == 0 {
69
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
70
+		return
71
+	}
72
+	miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
73
+	org_id := c.GetAdminUserInfo().CurrentOrgId
74
+	//adminInfo, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
75
+	patient, _ := service.GetFaPiaoPatientByID(org_id, order.PatientId)
76
+
77
+	printor_admin, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
78
+	charge_admin, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, order.Creator)
79
+
80
+	var bedCostTotal float64 = 0         //床位总费
81
+	var bedCostSelfTotal float64 = 0     //床位自费
82
+	var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
83
+
84
+	var operationCostTotal float64 = 0         //手术费
85
+	var operationCostSelfTotal float64 = 0     //手术费
86
+	var operationCostPartSelfTotal float64 = 0 //手术费
87
+
88
+	var otherCostTotal float64 = 0         //其他费用
89
+	var otherCostSelfTotal float64 = 0     //其他费用
90
+	var otherCostPartSelfTotal float64 = 0 //其他费用
91
+
92
+	var materialCostTotal float64 = 0         //材料费
93
+	var materialCostSelfTotal float64 = 0     //材料费
94
+	var materialCostPartSelfTotal float64 = 0 //材料费
95
+
96
+	var westernMedicineCostTotal float64 = 0         //西药费
97
+	var westernMedicineCostSelfTotal float64 = 0     //西药费
98
+	var westernMedicineCostPartSelfTotal float64 = 0 //西药费
99
+
100
+	var chineseTraditionalMedicineCostTotal float64 = 0         //中成药
101
+	var chineseTraditionalMedicineCostSelfTotal float64 = 0     //中成药
102
+	var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
103
+
104
+	var checkCostTotal float64 = 0         //检查费
105
+	var checkCostSelfTotal float64 = 0     //检查费
106
+	var checkCostPartSelfTotal float64 = 0 //检查费
107
+
108
+	var laboratoryCostTotal float64 = 0         //化验费
109
+	var laboratoryCostSelfTotal float64 = 0     //化验费
110
+	var laboratoryCostPartSelfTotal float64 = 0 //化验费
111
+
112
+	var treatCostTotal float64 = 0         //治疗费用
113
+	var treatCostSelfTotal float64 = 0     //治疗费用
114
+	var treatCostPartSelfTotal float64 = 0 //治疗费用
115
+
116
+	decimal.DivisionPrecision = 2
117
+
118
+	for _, item := range orderInfos {
119
+		if item.MedChrgitmType == "01" { //床位费
120
+			bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
121
+			bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
122
+			bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
123
+		}
124
+
125
+		if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
126
+			if item.MedChrgitmType == "03" { //检查费
127
+				laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
128
+				laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
129
+				laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
130
+			}
131
+		} else {
132
+
133
+			if item.MedChrgitmType == "03" { //检查费
134
+				checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
135
+				checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
136
+				checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
137
+			}
138
+
139
+		}
140
+
141
+		if item.MedChrgitmType == "04" { //化验费
142
+			laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
143
+			laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
144
+			laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
145
+
146
+		}
147
+
148
+		if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
149
+
150
+			treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
151
+			treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
152
+			treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
153
+
154
+		}
155
+
156
+		if item.MedChrgitmType == "06" { //手术费
157
+			operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
158
+			operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
159
+			operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
160
+		}
161
+
162
+		if item.MedChrgitmType == "08" { //材料费
163
+			materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
164
+			materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
165
+			materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
166
+		}
167
+
168
+		if item.MedChrgitmType == "09" { //西药费
169
+			westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
170
+			westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
171
+			westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
172
+		}
173
+
174
+		if item.MedChrgitmType == "11" { //中成费
175
+			chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
176
+			chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
177
+			chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
178
+		}
179
+
180
+		if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
181
+			otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
182
+			otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
183
+			otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
184
+		}
185
+	}
186
+	c.ServeSuccessJSON(map[string]interface{}{
187
+		"order_infos":                                 orderInfos,
188
+		"number":                                      order.MdtrtId,
189
+		"date":                                        order.SettleAccountsDate,
190
+		"charge_admin":                                charge_admin,
191
+		"printor_admin":                               printor_admin,
192
+		"info":                                        order,
193
+		"bedCostTotal":                                bedCostTotal,
194
+		"bedCostSelfTotal":                            bedCostSelfTotal,
195
+		"bedCostPartSelfTotal":                        bedCostPartSelfTotal,
196
+		"operationCostTotal":                          operationCostTotal,
197
+		"operationCostSelfTotal":                      operationCostSelfTotal,
198
+		"operationCostPartSelfTotal":                  operationCostPartSelfTotal,
199
+		"otherCostTotal":                              otherCostTotal,
200
+		"otherCostSelfTotal":                          otherCostSelfTotal,
201
+		"otherCostPartSelfTotal":                      otherCostPartSelfTotal,
202
+		"materialCostTotal":                           materialCostTotal,
203
+		"materialCostSelfTotal":                       materialCostSelfTotal,
204
+		"materialCostPartSelfTotal":                   materialCostPartSelfTotal,
205
+		"westernMedicineCostTotal":                    westernMedicineCostTotal,
206
+		"westernMedicineCostSelfTotal":                westernMedicineCostSelfTotal,
207
+		"westernMedicineCostPartSelfTotal":            westernMedicineCostPartSelfTotal,
208
+		"chineseTraditionalMedicineCostTotal":         chineseTraditionalMedicineCostTotal,
209
+		"chineseTraditionalMedicineCostSelfTotal":     chineseTraditionalMedicineCostSelfTotal,
210
+		"chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
211
+		"checkCostTotal":                              checkCostTotal,
212
+		"checkCostSelfTotal":                          checkCostSelfTotal,
213
+		"checkCostPartSelfTotal":                      checkCostPartSelfTotal,
214
+		"laboratoryCostTotal":                         laboratoryCostTotal,
215
+		"laboratoryCostSelfTotal":                     laboratoryCostSelfTotal,
216
+		"laboratoryCostPartSelfTotal":                 laboratoryCostPartSelfTotal,
217
+		"treatCostTotal":                              treatCostTotal,
218
+		"treatCostSelfTotal":                          treatCostSelfTotal,
219
+		"treatCostPartSelfTotal":                      treatCostPartSelfTotal,
220
+		"patient":                                     patient,
221
+		"org_name":                                    miConfig.OrgName,
222
+		"org_code":                                    miConfig.Code,
223
+		"num":                                         len(orders),
224
+		"f_time":                                      strings.Split(orders[0].SetlTime, " ")[0],
225
+		"l_time":                                      strings.Split(orders[len(orders)-1].SetlTime, " ")[0],
226
+	})
227
+
15
 }
228
 }
16
 
229
 
17
 func (this *HisExportDataController) GetExportData() {
230
 func (this *HisExportDataController) GetExportData() {

+ 4 - 4
controllers/mobile_api_controllers/dialysis_api_controller.go 查看文件

2178
 				}
2178
 				}
2179
 
2179
 
2180
 				if schedulePatient.ScheduleType == 2 {
2180
 				if schedulePatient.ScheduleType == 2 {
2181
-					advice.StartTime = recordDate.Unix() + 10*60*60
2181
+					advice.StartTime = recordDate.Unix() + 9*60*60
2182
 				}
2182
 				}
2183
 			}
2183
 			}
2184
 			// 抗凝剂名称
2184
 			// 抗凝剂名称
4191
 			}
4191
 			}
4192
 
4192
 
4193
 			if schedulePatient.ScheduleType == 2 {
4193
 			if schedulePatient.ScheduleType == 2 {
4194
-				advice.StartTime = recordDate.Unix() + 10*60*60
4194
+				advice.StartTime = recordDate.Unix() + 9*60*60
4195
 			}
4195
 			}
4196
 		}
4196
 		}
4197
 		// 抗凝剂名称
4197
 		// 抗凝剂名称
4483
 				record.UltrafiltrationRate = ultrafiltration_rate
4483
 				record.UltrafiltrationRate = ultrafiltration_rate
4484
 			}
4484
 			}
4485
 
4485
 
4486
-			if adminInfo.Org.Id == 10395 || adminInfo.Org.Id == 10138 || adminInfo.Org.Id == 10278 || adminInfo.Org.Id == 10340 || adminInfo.Org.Id == 10432 || adminInfo.Org.Id == 10441 || adminInfo.Org.Id == 10445 || adminInfo.Org.Id == 9829 || adminInfo.Org.Id == 10440 {
4486
+			if adminInfo.Org.Id == 10395 || adminInfo.Org.Id == 10138 || adminInfo.Org.Id == 10278 || adminInfo.Org.Id == 10340 || adminInfo.Org.Id == 10432 || adminInfo.Org.Id == 10441 || adminInfo.Org.Id == 10445 || adminInfo.Org.Id == 9829 || adminInfo.Org.Id == 10440 || adminInfo.Org.Id == 10610 {
4487
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / 1000 / float64(totalMin) * 1000)
4487
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / 1000 / float64(totalMin) * 1000)
4488
 
4488
 
4489
 				record.UltrafiltrationRate = ultrafiltration_rate
4489
 				record.UltrafiltrationRate = ultrafiltration_rate
4551
 	}
4551
 	}
4552
 
4552
 
4553
 	//长沙南雅
4553
 	//长沙南雅
4554
-	if adminInfo.Org.Id == 10395 || adminInfo.Org.Id == 10138 || adminInfo.Org.Id == 10278 || adminInfo.Org.Id == 10432 || adminInfo.Org.Id == 10441 || adminInfo.Org.Id == 10445 || adminInfo.Org.Id == 10469 || adminInfo.Org.Id == 10375 {
4554
+	if adminInfo.Org.Id == 10395 || adminInfo.Org.Id == 10138 || adminInfo.Org.Id == 10278 || adminInfo.Org.Id == 10432 || adminInfo.Org.Id == 10441 || adminInfo.Org.Id == 10445 || adminInfo.Org.Id == 10469 || adminInfo.Org.Id == 10375 || adminInfo.Org.Id == 10610 {
4555
 
4555
 
4556
 		if ultrafiltration_rate > 0 {
4556
 		if ultrafiltration_rate > 0 {
4557
 			ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
4557
 			ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)

+ 40 - 38
controllers/pharmacy_controller.go 查看文件

179
 	}
179
 	}
180
 
180
 
181
 	list, _ := service.GetTodayAdviceCountOne(stime, etime, orgid, 1, ids)
181
 	list, _ := service.GetTodayAdviceCountOne(stime, etime, orgid, 1, ids)
182
-	fmt.Println("LIST=================", list)
182
+
183
 	var flist []models.TmpPatientOne
183
 	var flist []models.TmpPatientOne
184
 	if len(list) > 0 {
184
 	if len(list) > 0 {
185
 		for _, item := range list {
185
 		for _, item := range list {
389
 		stime = stmp.Unix()
389
 		stime = stmp.Unix()
390
 		etime = stime + 86399
390
 		etime = stime + 86399
391
 	}
391
 	}
392
+	tmp_bool := service.IsPharmacyConfig(orgid)
393
+	if tmp_bool == true {
394
+		advicelist, _ := service.FindeHisAdviceDocAdvice(orgid, patient_id, stime, etime)
395
+		if len(advicelist) > 0 {
396
+			var total int64
397
+			var prescribing_number_total int64
398
+			for _, item := range advicelist {
399
+				//查询改药品信息
400
+				medical, _ := service.GetBaseDrugMedical(item.DrugId)
401
+				//如果是药房发药的方式
402
+				if medical.IsPharmacy == 1 {
403
+					houseConfig, _ := service.GetAllStoreHouseConfig(orgid)
404
+					//查询该药品是否有库存
405
+					list, _ := service.GetDrugTotalCountTwenty(item.DrugId, item.UserOrgId, houseConfig.DrugStorehouseOut)
406
+
407
+					//判断单位是否相等
408
+					if medical.MaxUnit == item.PrescribingNumberUnit {
409
+						prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
410
+						count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
411
+						//转化为最小单位
412
+						total = list.Count*medical.MinNumber + list.StockMinNumber
413
+						prescribing_number_total = count * medical.MinNumber
414
+					}
415
+					if medical.MinUnit == item.PrescribingNumberUnit {
416
+						prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
417
+						count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
418
+						total = list.Count*medical.MinNumber + list.StockMinNumber
419
+						prescribing_number_total = count
420
+					}
392
 
421
 
393
-	advicelist, _ := service.FindeHisAdviceDocAdvice(orgid, patient_id, stime, etime)
394
-	if len(advicelist) > 0 {
395
-		var total int64
396
-		var prescribing_number_total int64
397
-		for _, item := range advicelist {
398
-			//查询改药品信息
399
-			medical, _ := service.GetBaseDrugMedical(item.DrugId)
400
-			//如果是药房发药的方式
401
-			if medical.IsPharmacy == 1 {
402
-				houseConfig, _ := service.GetAllStoreHouseConfig(orgid)
403
-				//查询该药品是否有库存
404
-				list, _ := service.GetDrugTotalCountTwenty(item.DrugId, item.UserOrgId, houseConfig.DrugStorehouseOut)
405
-
406
-				//判断单位是否相等
407
-				if medical.MaxUnit == item.PrescribingNumberUnit {
408
-					prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
409
-					count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
410
-					//转化为最小单位
411
-					total = list.Count*medical.MinNumber + list.StockMinNumber
412
-					prescribing_number_total = count * medical.MinNumber
413
-				}
414
-				if medical.MinUnit == item.PrescribingNumberUnit {
415
-					prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
416
-					count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
417
-					total = list.Count*medical.MinNumber + list.StockMinNumber
418
-					prescribing_number_total = count
419
-				}
420
-
421
-				if medical.IsUse != 1 {
422
-					//如果出库数量大于库存数量
423
-					if prescribing_number_total > total {
424
-						err := fmt.Errorf(service.FindDrugsName(item.DrugId) + "库存不足")
425
-						if err != nil {
426
-							utils.ErrorLog(err.Error())
427
-							this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
428
-							return
422
+					if medical.IsUse != 1 {
423
+						//如果出库数量大于库存数量
424
+						if prescribing_number_total > total {
425
+							err := fmt.Errorf(service.FindDrugsName(item.DrugId) + "库存不足")
426
+							if err != nil {
427
+								utils.ErrorLog(err.Error())
428
+								this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
429
+								return
430
+							}
429
 						}
431
 						}
430
 					}
432
 					}
431
 				}
433
 				}
432
-			}
433
 
434
 
435
+			}
434
 		}
436
 		}
435
 	}
437
 	}
436
 
438
 

+ 9 - 0
service/export_data_service.go 查看文件

125
 	}
125
 	}
126
 	return
126
 	return
127
 }
127
 }
128
+func GetHisOrderByTime(patient_id int64, start_time string, end_time string) (order []models.HisOrder, err error) {
129
+	err = readDb.Model(&models.HisOrder{}).Where("patient_id = ? AND status = 1 and order_status = 2 and setl_time >= ? and setl_time <= ?", patient_id, start_time+" 00:00:00", end_time+" 23:59:00").Find(&order).Error
130
+	return
131
+}
132
+
133
+func GetBatchHisOrderInfoByNumber(order_number string) (order []models.BatchHisOrderInfo, err error) {
134
+	err = readDb.Model(&models.BatchHisOrderInfo{}).Where("order_number = ? and status = 1", order_number).Find(&order).Error
135
+	return
136
+}

+ 2 - 2
service/his_service.go 查看文件

1005
 
1005
 
1006
 func SaveNewHisProjectTwo(project *models.HisPrescriptionProject, tx *gorm.DB) (err error) {
1006
 func SaveNewHisProjectTwo(project *models.HisPrescriptionProject, tx *gorm.DB) (err error) {
1007
 	//err = tx.Model(&models.HisPrescriptionProject{}).Where("user_org_id = ? AND id = ?", project.UserOrgId, project.ID).Updates(map[string]interface{}{"feedetl_sn": project.FeedetlSn, "mtime": time.Now().Unix()}).Error
1007
 	//err = tx.Model(&models.HisPrescriptionProject{}).Where("user_org_id = ? AND id = ?", project.UserOrgId, project.ID).Updates(map[string]interface{}{"feedetl_sn": project.FeedetlSn, "mtime": time.Now().Unix()}).Error
1008
-	if err = tx.Model(&models.HisPrescriptionProject{}).Where("user_org_id = ? AND id = ?", project.UserOrgId, project.ID).Updates(map[string]interface{}{"feedetl_sn": project.FeedetlSn, "mtime": time.Now().Unix()}).Error; err != nil {
1008
+	if err = tx.Model(&models.HisPrescriptionProject{}).Where("user_org_id = ? AND id = ?", project.UserOrgId, project.ID).Updates(map[string]interface{}{"feedetl_sn": project.FeedetlSn}).Error; err != nil {
1009
 		tx.Rollback()
1009
 		tx.Rollback()
1010
 		return
1010
 		return
1011
 	}
1011
 	}
1013
 }
1013
 }
1014
 
1014
 
1015
 func SaveHisProjectTwo(project *models.HisPrescriptionProject) (err error) {
1015
 func SaveHisProjectTwo(project *models.HisPrescriptionProject) (err error) {
1016
-	err = writeDb.Model(&models.HisPrescriptionProject{}).Where("user_org_id = ? AND id = ?", project.UserOrgId, project.ID).Updates(map[string]interface{}{"feedetl_sn": project.FeedetlSn, "mtime": time.Now().Unix()}).Error
1016
+	err = writeDb.Model(&models.HisPrescriptionProject{}).Where("user_org_id = ? AND id = ?", project.UserOrgId, project.ID).Updates(map[string]interface{}{"feedetl_sn": project.FeedetlSn}).Error
1017
 	return
1017
 	return
1018
 }
1018
 }
1019
 
1019
 

+ 3 - 3
service/new_warehouse_service.go 查看文件

3682
 	var deliver_number_one int64 = 0
3682
 	var deliver_number_one int64 = 0
3683
 	var stock_number int64 = 0
3683
 	var stock_number int64 = 0
3684
 
3684
 
3685
-	fmt.Println(deliver_number)
3686
-	fmt.Println(deliver_number_one)
3687
-	fmt.Println(stock_number)
3685
+	//fmt.Println(deliver_number)
3686
+	//fmt.Println(deliver_number_one)
3687
+	//fmt.Println(stock_number)
3688
 	prescribingNumber_temp := strconv.FormatFloat(math.Abs(prescribingNumber), 'f', 0, 64)
3688
 	prescribingNumber_temp := strconv.FormatFloat(math.Abs(prescribingNumber), 'f', 0, 64)
3689
 	count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
3689
 	count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
3690
 
3690
 

+ 3 - 1
service/pharmacy_service.go 查看文件

300
 				DataSources:  "临时医嘱",
300
 				DataSources:  "临时医嘱",
301
 				Remarks:      v.Remark,
301
 				Remarks:      v.Remark,
302
 				DrugId:       v.DrugId,
302
 				DrugId:       v.DrugId,
303
-				Price:        v.Price,
304
 			})
303
 			})
305
 		}
304
 		}
306
 		return
305
 		return
336
 				ExecutionState: v.ExecutionState,
335
 				ExecutionState: v.ExecutionState,
337
 				ExecutionStaff: v.ExecutionStaff,
336
 				ExecutionStaff: v.ExecutionStaff,
338
 				ExecutionTime:  v.ExecutionTime,
337
 				ExecutionTime:  v.ExecutionTime,
338
+				Price:          v.Price,
339
 			})
339
 			})
340
 		}
340
 		}
341
 
341
 
369
 				ExecutionState: v.ExecutionState,
369
 				ExecutionState: v.ExecutionState,
370
 				ExecutionStaff: v.ExecutionStaff,
370
 				ExecutionStaff: v.ExecutionStaff,
371
 				ExecutionTime:  v.ExecutionTime,
371
 				ExecutionTime:  v.ExecutionTime,
372
+				//Price:        v.Price,
373
+
372
 			})
374
 			})
373
 		}
375
 		}
374
 		return
376
 		return