Ver código fonte

合并代码

csx 4 anos atrás
pai
commit
3e91fcb56b

+ 0 - 4
controllers/dialysis_api_controller.go Ver arquivo

5022
 		} else {
5022
 		} else {
5023
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdminUserIsExit)
5023
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdminUserIsExit)
5024
 			return
5024
 			return
5025
-
5026
 		}
5025
 		}
5027
-
5028
 	} else {
5026
 	} else {
5029
 		this.ServeSuccessJSON(map[string]interface{}{
5027
 		this.ServeSuccessJSON(map[string]interface{}{
5030
 			"is_has_create":       true,
5028
 			"is_has_create":       true,
5037
 			"is_has_modify_exce":  true,
5035
 			"is_has_modify_exce":  true,
5038
 			"module":              true,
5036
 			"module":              true,
5039
 		})
5037
 		})
5040
-
5041
 	}
5038
 	}
5042
-
5043
 }
5039
 }

+ 79 - 22
controllers/patient_api_controller.go Ver arquivo

69
 	beego.Router("/api/patients/export", &PatientApiController{}, "Post:ExportPatients")
69
 	beego.Router("/api/patients/export", &PatientApiController{}, "Post:ExportPatients")
70
 
70
 
71
 	beego.Router("/api/patients/advices/saveditadvices", &PatientApiController{}, "Get:SaveEditAdvices")
71
 	beego.Router("/api/patients/advices/saveditadvices", &PatientApiController{}, "Get:SaveEditAdvices")
72
+
73
+	beego.Router("/api/patients/dialysis_no", &PatientApiController{}, "Get:GetMaxDialysisNo")
74
+
72
 }
75
 }
73
 
76
 
74
 //GetPatientsList 取患者列表
77
 //GetPatientsList 取患者列表
3383
 
3386
 
3384
 func (c *PatientApiController) ExportPatients() {
3387
 func (c *PatientApiController) ExportPatients() {
3385
 	dataBody := make(map[string]interface{}, 0)
3388
 	dataBody := make(map[string]interface{}, 0)
3386
-	dialysisNo := service.ChechLastDialysisNo(c.GetAdminUserInfo().CurrentOrgId)
3387
-	if dialysisNo == 0 {
3388
-		dialysisNo = 1
3389
-	} else {
3390
-		dialysisNo++
3391
-	}
3389
+
3390
+	all_patient, _, _ := service.GetAllPatientList(c.GetAdminUserInfo().CurrentOrgId)
3391
+
3392
+	//all_patient, _,_ := service.GetAllPatientList(c.GetAdminUserInfo().CurrentOrgId )
3393
+
3394
+	org, _ := service.GetOrgById(c.GetAdminUserInfo().CurrentOrgId)
3392
 
3395
 
3393
 	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
3396
 	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
3394
 	if err != nil {
3397
 	if err != nil {
3399
 	export_time := time.Now().Unix()
3402
 	export_time := time.Now().Unix()
3400
 	var patients []*models.Patients
3403
 	var patients []*models.Patients
3401
 	var total_patients []interface{}
3404
 	var total_patients []interface{}
3402
-
3403
 	if dataBody["patients"] != nil || reflect.TypeOf(dataBody["patients"]).String() == "[]interface {}" {
3405
 	if dataBody["patients"] != nil || reflect.TypeOf(dataBody["patients"]).String() == "[]interface {}" {
3404
 		tempPatients := dataBody["patients"].([]interface{})
3406
 		tempPatients := dataBody["patients"].([]interface{})
3405
 		total_patients = tempPatients
3407
 		total_patients = tempPatients
3461
 					service.CreateExportErrLog(&err_log)
3463
 					service.CreateExportErrLog(&err_log)
3462
 					continue
3464
 					continue
3463
 				} else {
3465
 				} else {
3466
+					var tempPatient *models.Patients
3467
+					for _, item := range all_patient {
3468
+						if item.Phone == phone {
3469
+							tempPatient = item
3470
+						}
3471
+					}
3472
+
3464
 					//需要判断该号码是否已经在系统内存在了,存在了则生成一条导入错误日志
3473
 					//需要判断该号码是否已经在系统内存在了,存在了则生成一条导入错误日志
3465
-					count := service.FindPatientPhoneIsExist(phone, c.GetAdminUserInfo().CurrentOrgId)
3466
-					if count > 0 {
3474
+					//count := service.FindPatientPhoneIsExist(phone, c.GetAdminUserInfo().CurrentOrgId)
3475
+					if tempPatient != nil && tempPatient.ID > 0 {
3467
 						err_log := models.ExportErrLog{
3476
 						err_log := models.ExportErrLog{
3468
 							LogType:    1,
3477
 							LogType:    1,
3469
 							UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
3478
 							UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
3482
 
3491
 
3483
 			if patientNameM["id_card_no"] != nil || reflect.TypeOf(patientNameM["id_card_no"]).String() == "string" {
3492
 			if patientNameM["id_card_no"] != nil || reflect.TypeOf(patientNameM["id_card_no"]).String() == "string" {
3484
 				id_card_no, _ := patientNameM["id_card_no"].(string)
3493
 				id_card_no, _ := patientNameM["id_card_no"].(string)
3485
-				fmt.Println(id_card_no)
3486
-
3494
+				fmt.Println(IsIdCard(id_card_no))
3487
 				if IsIdCard(id_card_no) == false { //身份证号码不符合要求则生成一条导入错误日志
3495
 				if IsIdCard(id_card_no) == false { //身份证号码不符合要求则生成一条导入错误日志
3488
 					err_log := models.ExportErrLog{
3496
 					err_log := models.ExportErrLog{
3489
 						LogType:    1,
3497
 						LogType:    1,
3497
 					service.CreateExportErrLog(&err_log)
3505
 					service.CreateExportErrLog(&err_log)
3498
 					continue
3506
 					continue
3499
 				} else {
3507
 				} else {
3500
-					count := service.FindPatientIdCardNoIsExist(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
3501
-					if count > 0 {
3508
+					var tempPatient *models.Patients
3509
+					for _, item := range all_patient {
3510
+						if item.IdCardNo == id_card_no {
3511
+							tempPatient = item
3512
+						}
3513
+					}
3514
+					//count := service.FindPatientIdCardNoIsExist(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
3515
+					if tempPatient != nil && tempPatient.ID > 0 {
3502
 						err_log := models.ExportErrLog{
3516
 						err_log := models.ExportErrLog{
3503
 							LogType:    1,
3517
 							LogType:    1,
3504
 							UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
3518
 							UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
3633
 				patient.Diagnose = diagnose
3647
 				patient.Diagnose = diagnose
3634
 
3648
 
3635
 			}
3649
 			}
3636
-			dialysisNo = dialysisNo + int64(index)
3637
 
3650
 
3638
-			no := strconv.FormatInt(dialysisNo, 10)
3639
-			rep := 3 - len(no)
3651
+			if patientNameM["dialysis_no"] != nil || reflect.TypeOf(patientNameM["dialysis_no"]).String() == "string" {
3652
+				dialysis_no, _ := patientNameM["dialysis_no"].(string)
3653
+
3654
+				var tempPatient *models.Patients
3655
+				for _, item := range all_patient {
3656
+					if item.DialysisNo == dialysis_no {
3657
+						tempPatient = item
3658
+					}
3659
+				}
3660
+				if tempPatient != nil && tempPatient.ID > 0 {
3661
+					err_log := models.ExportErrLog{
3662
+						LogType:    1,
3663
+						UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
3664
+						ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的透析号在系统中已经存在",
3665
+						Status:     1,
3666
+						CreateTime: time.Now().Unix(),
3667
+						UpdateTime: time.Now().Unix(),
3668
+						ExportTime: export_time,
3669
+					}
3670
+					service.CreateExportErrLog(&err_log)
3671
+					continue
3672
+				}
3673
+
3674
+				patient.DialysisNo = dialysis_no
3675
+
3676
+			}
3677
+
3678
+			if patientNameM["height"] != nil || reflect.TypeOf(patientNameM["height"]).String() == "string" {
3679
+				height, _ := patientNameM["height"].(string)
3680
+				heights, _ := strconv.ParseFloat(height, 64)
3681
+				patient.Height = int64(heights)
3682
+			}
3683
+
3684
+			if patientNameM["home_address"] != nil || reflect.TypeOf(patientNameM["home_address"]).String() == "string" {
3685
+				home_address, _ := patientNameM["home_address"].(string)
3686
+				patient.HomeAddress = home_address
3687
+			}
3688
+			if patientNameM["dry_weight"] != nil || reflect.TypeOf(patientNameM["dry_weight"]).String() == "string" {
3689
+				dry_weight, _ := patientNameM["dry_weight"].(string)
3690
+				dry_weights, _ := strconv.ParseFloat(dry_weight, 64)
3691
+				patient.DryWeight = dry_weights
3640
 
3692
 
3641
-			if rep > 0 {
3642
-				no = strings.Repeat("0", rep) + no
3643
 			}
3693
 			}
3644
 
3694
 
3645
-			patient.DialysisNo = no
3646
 			patient.CreatedTime = time.Now().Unix()
3695
 			patient.CreatedTime = time.Now().Unix()
3647
 			patient.UpdatedTime = time.Now().Unix()
3696
 			patient.UpdatedTime = time.Now().Unix()
3648
 			patient.Status = 1
3697
 			patient.Status = 1
3656
 
3705
 
3657
 	if len(patients) > 0 {
3706
 	if len(patients) > 0 {
3658
 		for _, item := range patients {
3707
 		for _, item := range patients {
3659
-			service.CreateExportPatient(item, item.ContagionIds)
3708
+			service.CreateExportPatient(item, item.ContagionIds, org.Creator)
3660
 		}
3709
 		}
3661
 
3710
 
3662
 		log := models.ExportLog{
3711
 		log := models.ExportLog{
3728
 	adminInfo := c.GetAdminUserInfo()
3777
 	adminInfo := c.GetAdminUserInfo()
3729
 	orgid := adminInfo.CurrentOrgId
3778
 	orgid := adminInfo.CurrentOrgId
3730
 	startTime := c.GetString("start_time")
3779
 	startTime := c.GetString("start_time")
3731
-	fmt.Println("开始时间", startTime)
3780
+
3732
 	theTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", startTime)
3781
 	theTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", startTime)
3733
-	fmt.Println(theTime.Unix())
3782
+
3734
 	groupno, _ := c.GetInt64("groupno")
3783
 	groupno, _ := c.GetInt64("groupno")
3735
 	fmt.Println("组", groupno)
3784
 	fmt.Println("组", groupno)
3736
 	date, _ := c.GetInt64("date")
3785
 	date, _ := c.GetInt64("date")
3749
 		"advice": advice,
3798
 		"advice": advice,
3750
 	})
3799
 	})
3751
 }
3800
 }
3801
+
3802
+func (c *PatientApiController) GetMaxDialysisNo() {
3803
+	dialysisNo := service.ChechLastDialysisNo(c.GetAdminUserInfo().CurrentOrgId)
3804
+	c.ServeSuccessJSON(map[string]interface{}{
3805
+		"dialysis_no": dialysisNo,
3806
+	})
3807
+
3808
+}

+ 4 - 1
controllers/schedule_api_controller.go Ver arquivo

1349
 				return
1349
 				return
1350
 			}
1350
 			}
1351
 
1351
 
1352
+			partition_name, _ := schMapM["partition_name"].(string)
1353
+			zone, _ := service.FindDeviceZoneByName(partition_name, this.GetAdminUserInfo().CurrentOrgId)
1354
+
1352
 			device_number_name, _ := schMapM["device_number_name"].(string)
1355
 			device_number_name, _ := schMapM["device_number_name"].(string)
1353
 			if len(device_number_name) == 0 { //分区为空
1356
 			if len(device_number_name) == 0 { //分区为空
1354
 				log := models.ExportLog{
1357
 				log := models.ExportLog{
1380
 				return
1383
 				return
1381
 
1384
 
1382
 			} else {
1385
 			} else {
1383
-				device, err := service.FindDeviceByNameTwo(device_number_name, this.GetAdminUserInfo().CurrentOrgId)
1386
+				device, err := service.FindDeviceByNameTwo(device_number_name, this.GetAdminUserInfo().CurrentOrgId, zone.ID)
1384
 				if err == nil {
1387
 				if err == nil {
1385
 					if len(device) == 0 { //没查到数据,插入错误日志
1388
 					if len(device) == 0 { //没查到数据,插入错误日志
1386
 						log := models.ExportLog{
1389
 						log := models.ExportLog{

+ 1 - 0
models/patient_models.go Ver arquivo

89
 	IsExcelExport            int64  `gorm:"column:is_excel_export" json:"is_excel_export" form:"is_excel_export"`
89
 	IsExcelExport            int64  `gorm:"column:is_excel_export" json:"is_excel_export" form:"is_excel_export"`
90
 
90
 
91
 	ContagionIds []int64 `gorm:"-"`
91
 	ContagionIds []int64 `gorm:"-"`
92
+	DryWeight    float64 `gorm:"-"`
92
 }
93
 }
93
 
94
 
94
 func (Patients) TableName() string {
95
 func (Patients) TableName() string {

+ 14 - 1
service/patient_service.go Ver arquivo

1162
 	return schedule, err
1162
 	return schedule, err
1163
 }
1163
 }
1164
 
1164
 
1165
-func CreateExportPatient(patient *models.Patients, contagions []int64) (err error) {
1165
+func CreateExportPatient(patient *models.Patients, contagions []int64, org_creator int64) (err error) {
1166
 	user, _ := GetSgjUserByMobild(patient.Phone)
1166
 	user, _ := GetSgjUserByMobild(patient.Phone)
1167
 	customer, _ := GetSgjCoustomerByMobile(patient.UserOrgId, patient.Phone)
1167
 	customer, _ := GetSgjCoustomerByMobile(patient.UserOrgId, patient.Phone)
1168
 	utx := writeDb.Begin()
1168
 	utx := writeDb.Begin()
1217
 		return
1217
 		return
1218
 	}
1218
 	}
1219
 
1219
 
1220
+	var dryWeight models.SgjPatientDryweight
1221
+	dryWeight.PatientId = patient.ID
1222
+	dryWeight.UserOrgId = patient.UserOrgId
1223
+	dryWeight.Status = 1
1224
+	dryWeight.AdjustedValue = "/"
1225
+	dryWeight.Creator = org_creator
1226
+	dryWeight.UserId = org_creator
1227
+	dryWeight.Ctime = time.Now().Unix()
1228
+	dryWeight.Mtime = time.Now().Unix()
1229
+	dryWeight.DryWeight = patient.DryWeight
1230
+	dryWeight.Remakes = ""
1231
+	err = utx.Create(&dryWeight).Error
1232
+
1220
 	var lapseto models.PatientLapseto
1233
 	var lapseto models.PatientLapseto
1221
 	lapseto.PatientId = patient.ID
1234
 	lapseto.PatientId = patient.ID
1222
 	lapseto.LapsetoType = patient.Lapseto
1235
 	lapseto.LapsetoType = patient.Lapseto

+ 2 - 2
service/schedule_service.go Ver arquivo

375
 	return
375
 	return
376
 }
376
 }
377
 
377
 
378
-func FindDeviceByNameTwo(device_name string, org_id int64) (devices []*models.DeviceNumber, err error) {
379
-	err = readDb.Model(&models.DeviceNumber{}).Where("org_id = ? AND number = ? AND status = 1", org_id, device_name).Find(&devices).Error
378
+func FindDeviceByNameTwo(device_name string, org_id int64, zone_id int64) (devices []*models.DeviceNumber, err error) {
379
+	err = readDb.Model(&models.DeviceNumber{}).Where("org_id = ? AND number = ? AND status = 1 AND zone_id = ?", org_id, device_name, zone_id).Find(&devices).Error
380
 	return
380
 	return
381
 }
381
 }
382
 
382