Browse Source

合并代码

csx 4 years ago
parent
commit
3e91fcb56b

+ 0 - 4
controllers/dialysis_api_controller.go View File

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

+ 79 - 22
controllers/patient_api_controller.go View File

@@ -69,6 +69,9 @@ func PatientApiRegistRouters() {
69 69
 	beego.Router("/api/patients/export", &PatientApiController{}, "Post:ExportPatients")
70 70
 
71 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 77
 //GetPatientsList 取患者列表
@@ -3383,12 +3386,12 @@ func (c *PatientApiController) GetPatientScheduleOne() {
3383 3386
 
3384 3387
 func (c *PatientApiController) ExportPatients() {
3385 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 3396
 	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
3394 3397
 	if err != nil {
@@ -3399,7 +3402,6 @@ func (c *PatientApiController) ExportPatients() {
3399 3402
 	export_time := time.Now().Unix()
3400 3403
 	var patients []*models.Patients
3401 3404
 	var total_patients []interface{}
3402
-
3403 3405
 	if dataBody["patients"] != nil || reflect.TypeOf(dataBody["patients"]).String() == "[]interface {}" {
3404 3406
 		tempPatients := dataBody["patients"].([]interface{})
3405 3407
 		total_patients = tempPatients
@@ -3461,9 +3463,16 @@ func (c *PatientApiController) ExportPatients() {
3461 3463
 					service.CreateExportErrLog(&err_log)
3462 3464
 					continue
3463 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 3476
 						err_log := models.ExportErrLog{
3468 3477
 							LogType:    1,
3469 3478
 							UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
@@ -3482,8 +3491,7 @@ func (c *PatientApiController) ExportPatients() {
3482 3491
 
3483 3492
 			if patientNameM["id_card_no"] != nil || reflect.TypeOf(patientNameM["id_card_no"]).String() == "string" {
3484 3493
 				id_card_no, _ := patientNameM["id_card_no"].(string)
3485
-				fmt.Println(id_card_no)
3486
-
3494
+				fmt.Println(IsIdCard(id_card_no))
3487 3495
 				if IsIdCard(id_card_no) == false { //身份证号码不符合要求则生成一条导入错误日志
3488 3496
 					err_log := models.ExportErrLog{
3489 3497
 						LogType:    1,
@@ -3497,8 +3505,14 @@ func (c *PatientApiController) ExportPatients() {
3497 3505
 					service.CreateExportErrLog(&err_log)
3498 3506
 					continue
3499 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 3516
 						err_log := models.ExportErrLog{
3503 3517
 							LogType:    1,
3504 3518
 							UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
@@ -3633,16 +3647,51 @@ func (c *PatientApiController) ExportPatients() {
3633 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 3695
 			patient.CreatedTime = time.Now().Unix()
3647 3696
 			patient.UpdatedTime = time.Now().Unix()
3648 3697
 			patient.Status = 1
@@ -3656,7 +3705,7 @@ func (c *PatientApiController) ExportPatients() {
3656 3705
 
3657 3706
 	if len(patients) > 0 {
3658 3707
 		for _, item := range patients {
3659
-			service.CreateExportPatient(item, item.ContagionIds)
3708
+			service.CreateExportPatient(item, item.ContagionIds, org.Creator)
3660 3709
 		}
3661 3710
 
3662 3711
 		log := models.ExportLog{
@@ -3728,9 +3777,9 @@ func (c *PatientApiController) SaveEditAdvices() {
3728 3777
 	adminInfo := c.GetAdminUserInfo()
3729 3778
 	orgid := adminInfo.CurrentOrgId
3730 3779
 	startTime := c.GetString("start_time")
3731
-	fmt.Println("开始时间", startTime)
3780
+
3732 3781
 	theTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", startTime)
3733
-	fmt.Println(theTime.Unix())
3782
+
3734 3783
 	groupno, _ := c.GetInt64("groupno")
3735 3784
 	fmt.Println("组", groupno)
3736 3785
 	date, _ := c.GetInt64("date")
@@ -3749,3 +3798,11 @@ func (c *PatientApiController) SaveEditAdvices() {
3749 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 View File

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

+ 1 - 0
models/patient_models.go View File

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

+ 14 - 1
service/patient_service.go View File

@@ -1162,7 +1162,7 @@ func GetPatientScheduleOne(patientid int64, nowdate int64, orgid int64) (models.
1162 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 1166
 	user, _ := GetSgjUserByMobild(patient.Phone)
1167 1167
 	customer, _ := GetSgjCoustomerByMobile(patient.UserOrgId, patient.Phone)
1168 1168
 	utx := writeDb.Begin()
@@ -1217,6 +1217,19 @@ func CreateExportPatient(patient *models.Patients, contagions []int64) (err erro
1217 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 1233
 	var lapseto models.PatientLapseto
1221 1234
 	lapseto.PatientId = patient.ID
1222 1235
 	lapseto.LapsetoType = patient.Lapseto

+ 2 - 2
service/schedule_service.go View File

@@ -375,8 +375,8 @@ func FindSchedualExportLog(org_id int64, export_time int64) (errLogs []*models.E
375 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 380
 	return
381 381
 }
382 382