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