|
@@ -321,10 +321,10 @@ func (this *NewDialysisApiController) SavePatient() {
|
321
|
321
|
}
|
322
|
322
|
errcodetwo := service.CreateCdmPatient(&patients)
|
323
|
323
|
fmt.Print("报错", errcodetwo)
|
324
|
|
- patient, errcodetwo := service.GetOldCdmPatient(orgid)
|
325
|
|
- errcodetwo = service.AddSlowContagions(patient.ID, patient.CreatedTime, patient.UpdatedTime, idss, orgid)
|
|
324
|
+ slowPatient, errcodetwo := service.GetOldCdmPatient(orgid)
|
|
325
|
+ errcodetwo = service.AddSlowContagions(slowPatient.ID, slowPatient.CreatedTime, slowPatient.UpdatedTime, idss, orgid)
|
326
|
326
|
fmt.Print("添加慢病传染病失败", errcodetwo)
|
327
|
|
- errcodethree := service.AddSlowDiseases(patient.ID, patient.CreatedTime, patient.UpdatedTime, idsss, orgid)
|
|
327
|
+ errcodethree := service.AddSlowDiseases(slowPatient.ID, slowPatient.CreatedTime, slowPatient.UpdatedTime, idsss, orgid)
|
328
|
328
|
fmt.Print("添加慢性病失败", errcodethree)
|
329
|
329
|
|
330
|
330
|
_, errcodefour := service.GetLastNewSlowPatient(phone, orgid)
|
|
@@ -348,7 +348,7 @@ func (this *NewDialysisApiController) SavePatient() {
|
348
|
348
|
MemberPatients: memberpatient,
|
349
|
349
|
BloodPatients: bloodPatient,
|
350
|
350
|
SlowPatients: slowpatient,
|
351
|
|
- BloodId: patient.ID,
|
|
351
|
+ SlowId: slowPatient.ID,
|
352
|
352
|
}
|
353
|
353
|
err = service.CreateNewPatient(&patientsNew)
|
354
|
354
|
if err != nil {
|
|
@@ -360,6 +360,73 @@ func (this *NewDialysisApiController) SavePatient() {
|
360
|
360
|
})
|
361
|
361
|
} else if errcodetwo == nil {
|
362
|
362
|
fmt.Print("病人已存在")
|
|
363
|
+ if memberpatient == 1 {
|
|
364
|
+ fmt.Print("进来没有", memberpatient)
|
|
365
|
+ _, errmembercode := service.GetMemberPatientInfo(orgid, phone)
|
|
366
|
+ if errmembercode == gorm.ErrRecordNotFound {
|
|
367
|
+ customer := models.SgjUserCustomer{
|
|
368
|
+ Name: name,
|
|
369
|
+ UserOrgId: orgid,
|
|
370
|
+ Mobile: phone,
|
|
371
|
+ Gender: sex,
|
|
372
|
+ Birthday: birth,
|
|
373
|
+ IllDate: memtime,
|
|
374
|
+ Status: 1,
|
|
375
|
+ CreatedTime: time.Now().Unix(),
|
|
376
|
+ Avatar: avatar,
|
|
377
|
+ IllnessId: patient_type,
|
|
378
|
+ TreatType: treatmentmethod,
|
|
379
|
+ }
|
|
380
|
+ errmembercode := service.CreateMemberPatient(&customer)
|
|
381
|
+ fmt.Print("创建会员病人失败", errmembercode)
|
|
382
|
+ _, errmembercodetwo := service.GetMemberNewPatient(phone, orgid)
|
|
383
|
+ fmt.Print("错误", errmembercodetwo)
|
|
384
|
+ //获取机构的最后一条数据
|
|
385
|
+ memberPatient, errmembercode := service.GetLastMemberPatient(orgid)
|
|
386
|
+ if errmembercodetwo == gorm.ErrRecordNotFound {
|
|
387
|
+ patientsNew := models.XtPatientsNew{
|
|
388
|
+ Name: name,
|
|
389
|
+ Gender: sex,
|
|
390
|
+ Birthday: birth,
|
|
391
|
+ Age: ages,
|
|
392
|
+ Phone: phone,
|
|
393
|
+ Lapseto: lapseto,
|
|
394
|
+ AdmissionNumber: adminssionNumber,
|
|
395
|
+ FirstDialysisDate: fisttime,
|
|
396
|
+ Diagnose: diagonse,
|
|
397
|
+ Source: patientsoure,
|
|
398
|
+ DialysisNo: dialysis,
|
|
399
|
+ UserOrgId: orgid,
|
|
400
|
+ Status: 1,
|
|
401
|
+ CreatedTime: time.Now().Unix(),
|
|
402
|
+ Avatar: avatar,
|
|
403
|
+ MemberPatients: memberpatient,
|
|
404
|
+ BloodPatients: bloodPatient,
|
|
405
|
+ SlowPatients: slowpatient,
|
|
406
|
+ MemberId: memberPatient.ID,
|
|
407
|
+ }
|
|
408
|
+ err = service.CreateNewPatient(&patientsNew)
|
|
409
|
+ fmt.Print("报错-----------------------", err)
|
|
410
|
+ if err != nil {
|
|
411
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
412
|
+ return
|
|
413
|
+ }
|
|
414
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
415
|
+ "patient": patientsNew,
|
|
416
|
+ })
|
|
417
|
+ } else if errmembercode == nil {
|
|
418
|
+ fmt.Print("病人已存在")
|
|
419
|
+ return
|
|
420
|
+ } else {
|
|
421
|
+
|
|
422
|
+ }
|
|
423
|
+ } else if errmembercode == nil {
|
|
424
|
+ fmt.Print("病人已存在")
|
|
425
|
+ return
|
|
426
|
+ } else {
|
|
427
|
+
|
|
428
|
+ }
|
|
429
|
+ }
|
363
|
430
|
return
|
364
|
431
|
} else {
|
365
|
432
|
|
|
@@ -375,6 +442,7 @@ func (this *NewDialysisApiController) SavePatient() {
|
375
|
442
|
}
|
376
|
443
|
|
377
|
444
|
if memberpatient == 1 {
|
|
445
|
+ fmt.Print("进来没有", memberpatient)
|
378
|
446
|
_, errmembercode := service.GetMemberPatientInfo(orgid, phone)
|
379
|
447
|
if errmembercode == gorm.ErrRecordNotFound {
|
380
|
448
|
customer := models.SgjUserCustomer{
|
|
@@ -392,7 +460,10 @@ func (this *NewDialysisApiController) SavePatient() {
|
392
|
460
|
}
|
393
|
461
|
errmembercode := service.CreateMemberPatient(&customer)
|
394
|
462
|
fmt.Print("创建会员病人失败", errmembercode)
|
395
|
|
- patient, errmembercodetwo := service.GetMemberNewPatient(phone, orgid)
|
|
463
|
+ _, errmembercodetwo := service.GetMemberNewPatient(phone, orgid)
|
|
464
|
+ fmt.Print("错误", errmembercodetwo)
|
|
465
|
+ //获取机构的最后一条数据
|
|
466
|
+ memberPatient, errmembercode := service.GetLastMemberPatient(orgid)
|
396
|
467
|
if errmembercodetwo == gorm.ErrRecordNotFound {
|
397
|
468
|
patientsNew := models.XtPatientsNew{
|
398
|
469
|
Name: name,
|
|
@@ -413,9 +484,10 @@ func (this *NewDialysisApiController) SavePatient() {
|
413
|
484
|
MemberPatients: memberpatient,
|
414
|
485
|
BloodPatients: bloodPatient,
|
415
|
486
|
SlowPatients: slowpatient,
|
416
|
|
- BloodId: patient.ID,
|
|
487
|
+ MemberId: memberPatient.ID,
|
417
|
488
|
}
|
418
|
489
|
err = service.CreateNewPatient(&patientsNew)
|
|
490
|
+ fmt.Print("报错-----------------------", err)
|
419
|
491
|
if err != nil {
|
420
|
492
|
this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
421
|
493
|
return
|