Browse Source

修改bug

csx 3 years ago
parent
commit
8ba5398d87
1 changed files with 140 additions and 34 deletions
  1. 140 34
      controllers/patient_api_controller.go

+ 140 - 34
controllers/patient_api_controller.go View File

@@ -3452,17 +3452,33 @@ func (c *PatientApiController) ExportPatients() {
3452 3452
 			if patientNameM["phone"] != nil || reflect.TypeOf(patientNameM["phone"]).String() == "string" {
3453 3453
 				phone, _ := patientNameM["phone"].(string)
3454 3454
 				if VerifyMobileFormat(phone) == false { //手机号码不符合要求则生成一条导入错误日志
3455
-					err_log := models.ExportErrLog{
3456
-						LogType:    1,
3457
-						UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
3458
-						ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的手机号码格式不符合要求",
3459
-						Status:     1,
3460
-						CreateTime: time.Now().Unix(),
3461
-						UpdateTime: time.Now().Unix(),
3462
-						ExportTime: export_time,
3455
+
3456
+					if len(phone) == 0 {
3457
+						err_log := models.ExportErrLog{
3458
+							LogType:    1,
3459
+							UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
3460
+							ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的手机号码格式不能为空",
3461
+							Status:     1,
3462
+							CreateTime: time.Now().Unix(),
3463
+							UpdateTime: time.Now().Unix(),
3464
+							ExportTime: export_time,
3465
+						}
3466
+						service.CreateExportErrLog(&err_log)
3467
+						continue
3468
+					} else {
3469
+						err_log := models.ExportErrLog{
3470
+							LogType:    1,
3471
+							UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
3472
+							ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的手机号码格式不符合要求",
3473
+							Status:     1,
3474
+							CreateTime: time.Now().Unix(),
3475
+							UpdateTime: time.Now().Unix(),
3476
+							ExportTime: export_time,
3477
+						}
3478
+						service.CreateExportErrLog(&err_log)
3479
+						continue
3463 3480
 					}
3464
-					service.CreateExportErrLog(&err_log)
3465
-					continue
3481
+
3466 3482
 				} else {
3467 3483
 					var tempPatient *models.Patients
3468 3484
 					for _, item := range all_patient {
@@ -3492,19 +3508,37 @@ func (c *PatientApiController) ExportPatients() {
3492 3508
 
3493 3509
 			if patientNameM["id_card_no"] != nil || reflect.TypeOf(patientNameM["id_card_no"]).String() == "string" {
3494 3510
 				id_card_no, _ := patientNameM["id_card_no"].(string)
3495
-				fmt.Println(IsIdCard(id_card_no))
3511
+
3496 3512
 				if IsIdCard(id_card_no) == false { //身份证号码不符合要求则生成一条导入错误日志
3497
-					err_log := models.ExportErrLog{
3498
-						LogType:    1,
3499
-						UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
3500
-						ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的身份证号码格式不符合要求",
3501
-						Status:     1,
3502
-						CreateTime: time.Now().Unix(),
3503
-						UpdateTime: time.Now().Unix(),
3504
-						ExportTime: export_time,
3513
+
3514
+					if len(id_card_no) == 0 {
3515
+						err_log := models.ExportErrLog{
3516
+							LogType:    1,
3517
+							UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
3518
+							ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的身份证号码不能为空",
3519
+							Status:     1,
3520
+							CreateTime: time.Now().Unix(),
3521
+							UpdateTime: time.Now().Unix(),
3522
+							ExportTime: export_time,
3523
+						}
3524
+						service.CreateExportErrLog(&err_log)
3525
+						continue
3526
+
3527
+					} else {
3528
+						err_log := models.ExportErrLog{
3529
+							LogType:    1,
3530
+							UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
3531
+							ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的身份证号码格式不符合要求",
3532
+							Status:     1,
3533
+							CreateTime: time.Now().Unix(),
3534
+							UpdateTime: time.Now().Unix(),
3535
+							ExportTime: export_time,
3536
+						}
3537
+						service.CreateExportErrLog(&err_log)
3538
+						continue
3539
+
3505 3540
 					}
3506
-					service.CreateExportErrLog(&err_log)
3507
-					continue
3541
+
3508 3542
 				} else {
3509 3543
 					var tempPatient *models.Patients
3510 3544
 					for _, item := range all_patient {
@@ -3538,24 +3572,40 @@ func (c *PatientApiController) ExportPatients() {
3538 3572
 				first_dialysis_date, err := time.ParseInLocation(timeLayout, first_treatment_date, loc)
3539 3573
 
3540 3574
 				if err != nil { //首次肾脏治疗时间不符合要求则生成一条导入错误日志
3541
-					err_log := models.ExportErrLog{
3542
-						LogType:    1,
3543
-						UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
3544
-						ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的首次肾脏治疗时间格式不符合要求",
3545
-						Status:     1,
3546
-						CreateTime: time.Now().Unix(),
3547
-						UpdateTime: time.Now().Unix(),
3548
-						ExportTime: export_time,
3575
+					if len(first_treatment_date) == 0 {
3576
+						err_log := models.ExportErrLog{
3577
+							LogType:    1,
3578
+							UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
3579
+							ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的首次肾脏治疗时间不能为空",
3580
+							Status:     1,
3581
+							CreateTime: time.Now().Unix(),
3582
+							UpdateTime: time.Now().Unix(),
3583
+							ExportTime: export_time,
3584
+						}
3585
+						service.CreateExportErrLog(&err_log)
3586
+						continue
3587
+
3588
+					} else {
3589
+						err_log := models.ExportErrLog{
3590
+							LogType:    1,
3591
+							UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
3592
+							ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的首次肾脏治疗时间格式不符合要求",
3593
+							Status:     1,
3594
+							CreateTime: time.Now().Unix(),
3595
+							UpdateTime: time.Now().Unix(),
3596
+							ExportTime: export_time,
3597
+						}
3598
+						service.CreateExportErrLog(&err_log)
3599
+						continue
3600
+
3549 3601
 					}
3550
-					service.CreateExportErrLog(&err_log)
3551
-					continue
3552 3602
 
3553 3603
 				} else {
3554
-					if first_dialysis_date.Unix() == 0 { //首次肾脏治疗时间不符合要求则生成一条导入错误日志
3604
+					if len(first_treatment_date) == 0 {
3555 3605
 						err_log := models.ExportErrLog{
3556 3606
 							LogType:    1,
3557 3607
 							UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
3558
-							ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的首次肾脏治疗时间格式不符合要求",
3608
+							ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的首次肾脏治疗时间不能为空",
3559 3609
 							Status:     1,
3560 3610
 							CreateTime: time.Now().Unix(),
3561 3611
 							UpdateTime: time.Now().Unix(),
@@ -3564,8 +3614,25 @@ func (c *PatientApiController) ExportPatients() {
3564 3614
 						service.CreateExportErrLog(&err_log)
3565 3615
 						continue
3566 3616
 					} else {
3567
-						patient.FirstDialysisDate = first_dialysis_date.Unix()
3617
+
3618
+						if first_dialysis_date.Unix() == 0 { //首次肾脏治疗时间不符合要求则生成一条导入错误日志
3619
+							err_log := models.ExportErrLog{
3620
+								LogType:    1,
3621
+								UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
3622
+								ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的首次肾脏治疗时间格式不符合要求",
3623
+								Status:     1,
3624
+								CreateTime: time.Now().Unix(),
3625
+								UpdateTime: time.Now().Unix(),
3626
+								ExportTime: export_time,
3627
+							}
3628
+							service.CreateExportErrLog(&err_log)
3629
+							continue
3630
+						} else {
3631
+							patient.FirstDialysisDate = first_dialysis_date.Unix()
3632
+						}
3633
+
3568 3634
 					}
3635
+
3569 3636
 				}
3570 3637
 			}
3571 3638
 
@@ -3583,6 +3650,19 @@ func (c *PatientApiController) ExportPatients() {
3583 3650
 					}
3584 3651
 					service.CreateExportErrLog(&err_log)
3585 3652
 					continue
3653
+				} else if source == 3 {
3654
+					err_log := models.ExportErrLog{
3655
+						LogType:    1,
3656
+						UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
3657
+						ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的患者来源不能为空",
3658
+						Status:     1,
3659
+						CreateTime: time.Now().Unix(),
3660
+						UpdateTime: time.Now().Unix(),
3661
+						ExportTime: export_time,
3662
+					}
3663
+					service.CreateExportErrLog(&err_log)
3664
+					continue
3665
+
3586 3666
 				} else {
3587 3667
 					patient.Source = source
3588 3668
 				}
@@ -3602,6 +3682,19 @@ func (c *PatientApiController) ExportPatients() {
3602 3682
 					}
3603 3683
 					service.CreateExportErrLog(&err_log)
3604 3684
 					continue
3685
+				} else if lapseto == 3 {
3686
+					err_log := models.ExportErrLog{
3687
+						LogType:    1,
3688
+						UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
3689
+						ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的治疗状态不能为空",
3690
+						Status:     1,
3691
+						CreateTime: time.Now().Unix(),
3692
+						UpdateTime: time.Now().Unix(),
3693
+						ExportTime: export_time,
3694
+					}
3695
+					service.CreateExportErrLog(&err_log)
3696
+					continue
3697
+
3605 3698
 				} else {
3606 3699
 					patient.Lapseto = lapseto
3607 3700
 				}
@@ -3621,6 +3714,19 @@ func (c *PatientApiController) ExportPatients() {
3621 3714
 					}
3622 3715
 					service.CreateExportErrLog(&err_log)
3623 3716
 					continue
3717
+				} else if is_infectious == 3 {
3718
+					err_log := models.ExportErrLog{
3719
+						LogType:    1,
3720
+						UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
3721
+						ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的传染病状态不能为空",
3722
+						Status:     1,
3723
+						CreateTime: time.Now().Unix(),
3724
+						UpdateTime: time.Now().Unix(),
3725
+						ExportTime: export_time,
3726
+					}
3727
+					service.CreateExportErrLog(&err_log)
3728
+					continue
3729
+
3624 3730
 				} else {
3625 3731
 					patient.IsInfectious = is_infectious
3626 3732
 				}