|
@@ -31,7 +31,6 @@ type HisApiController struct {
|
31
|
31
|
|
32
|
32
|
func HisManagerApiRegistRouters() {
|
33
|
33
|
|
34
|
|
-
|
35
|
34
|
beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
|
36
|
35
|
beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
|
37
|
36
|
beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
|
|
@@ -361,7 +360,6 @@ type Custom struct {
|
361
|
360
|
func (c *HisApiController) GetRegisterInfo() {
|
362
|
361
|
id, _ := c.GetInt64("id")
|
363
|
362
|
record_time := c.GetString("record_time")
|
364
|
|
-
|
365
|
363
|
name := c.GetString("name")
|
366
|
364
|
gender, _ := c.GetInt64("gender")
|
367
|
365
|
age, _ := c.GetInt64("age")
|
|
@@ -443,119 +441,65 @@ func (c *HisApiController) GetRegisterInfo() {
|
443
|
441
|
infoStr := string(Iinfos)
|
444
|
442
|
idetinfoStr := string(Idetinfos)
|
445
|
443
|
|
446
|
|
- his := models.VMHisPatient{
|
447
|
|
- PsnNo: res.Output.Baseinfo.PsnNo,
|
448
|
|
- PsnCertType: res.Output.Baseinfo.PsnCertType,
|
449
|
|
- Certno: res.Output.Baseinfo.Certno,
|
450
|
|
- PsnName: res.Output.Baseinfo.PsnName,
|
451
|
|
- Gend: res.Output.Baseinfo.Gend,
|
452
|
|
- Naty: res.Output.Baseinfo.Naty,
|
453
|
|
- Brdy: res.Output.Baseinfo.Brdy,
|
454
|
|
- Age: res.Output.Baseinfo.Age,
|
455
|
|
- Iinfo: infoStr,
|
456
|
|
- Idetinfo: idetinfoStr,
|
457
|
|
- PatientId: patient.ID,
|
458
|
|
- RecordDate: theTime.Unix(),
|
459
|
|
- UserOrgId: adminInfo.CurrentOrgId,
|
460
|
|
- AdminUserId: adminInfo.AdminUser.Id,
|
461
|
|
- IsReturn: 1,
|
462
|
|
- }
|
463
|
|
- fmt.Println(his)
|
464
|
|
-
|
465
|
|
- lastPatient, _ := service.GetLastPatient(adminInfo.CurrentOrgId)
|
466
|
|
- timeStr := time.Now().Format("2006-01-02")
|
467
|
|
- timeArr := strings.Split(timeStr, "-")
|
468
|
|
- var str = timeArr[0] + timeArr[1] + timeArr[2] + strconv.FormatInt(lastPatient.ID, 10)
|
469
|
|
-
|
470
|
|
- hisPatient := models.HisPatient{
|
471
|
|
- Number: str,
|
472
|
|
- }
|
473
|
|
- err = service.UpdateHisPatient(lastPatient.ID, hisPatient)
|
474
|
|
-
|
475
|
|
- if res.Output.Iinfo == nil || len(res.Output.Iinfo) == 0 {
|
476
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterOneException)
|
477
|
|
- return
|
478
|
|
- }
|
479
|
|
-
|
480
|
|
- timestamp := time.Now().Unix()
|
481
|
|
- tempTime := time.Unix(timestamp, 0)
|
482
|
|
- timeFormat := tempTime.Format("20060102150405")
|
483
|
|
- chrgBchno := rand.Intn(100000) + 10000
|
484
|
|
- ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
|
485
|
|
-
|
486
|
|
- count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
|
487
|
|
-
|
488
|
|
- department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
|
489
|
|
-
|
490
|
|
- //department_id := strconv.FormatInt(department.ID, 10)
|
491
|
|
- doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
|
492
|
|
-
|
493
|
|
- if count <= 0 {
|
494
|
|
- api := "http://127.0.0.1:9532/" + "gdyb/two?cert_no=" + patient.IdCardNo + "&insutype=" +
|
495
|
|
- res.Output.Iinfo[0].Insutype + "&psn_no=" + res.Output.Baseinfo.PsnNo +
|
496
|
|
- "&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&ipt_otp_no=" + ipt_otp_no +
|
497
|
|
- "&dept=" + department.Name + "&fixmedins_code=" + miConfig.Code + "&dept_code=" + department.Number + "&doctor_id=" + doctor_id + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
|
498
|
|
- resp, requestErr := http.Get(api)
|
499
|
|
- if requestErr != nil {
|
500
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
501
|
|
- return
|
502
|
|
- }
|
503
|
|
- defer resp.Body.Close()
|
504
|
|
- body, ioErr := ioutil.ReadAll(resp.Body)
|
505
|
|
- if ioErr != nil {
|
506
|
|
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
|
507
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
508
|
|
- return
|
509
|
|
- }
|
510
|
|
- var respJSON map[string]interface{}
|
511
|
|
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
|
512
|
|
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
513
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
514
|
|
- return
|
|
444
|
+ if res.Infcode == -1 {
|
|
445
|
+ his := models.VMHisPatient{
|
|
446
|
+ Name: name,
|
|
447
|
+ Gender: gender,
|
|
448
|
+ Birthday: birthUnix,
|
|
449
|
+ MedicalTreatmentType: medical_care,
|
|
450
|
+ IdType: certificates,
|
|
451
|
+ IdCardNo: id_card,
|
|
452
|
+ BalanceAccountsType: settlementValue,
|
|
453
|
+ SocialType: social_type,
|
|
454
|
+ MedicalInsuranceNumber: medical_insurance_card,
|
|
455
|
+ RegisterType: register_type,
|
|
456
|
+ RegisterCost: registration_fee,
|
|
457
|
+ TreatmentCost: medical_expenses,
|
|
458
|
+ Status: 1,
|
|
459
|
+ Ctime: time.Now().Unix(),
|
|
460
|
+ Mtime: time.Now().Unix(),
|
|
461
|
+ PsnNo: res.Output.Baseinfo.PsnNo,
|
|
462
|
+ PsnCertType: res.Output.Baseinfo.PsnCertType,
|
|
463
|
+ Certno: res.Output.Baseinfo.Certno,
|
|
464
|
+ PsnName: res.Output.Baseinfo.PsnName,
|
|
465
|
+ Gend: res.Output.Baseinfo.Gend,
|
|
466
|
+ Naty: res.Output.Baseinfo.Naty,
|
|
467
|
+ Brdy: res.Output.Baseinfo.Brdy,
|
|
468
|
+ Age: res.Output.Baseinfo.Age,
|
|
469
|
+ Iinfo: infoStr,
|
|
470
|
+ Idetinfo: idetinfoStr,
|
|
471
|
+ PatientId: patient.ID,
|
|
472
|
+ RecordDate: theTime.Unix(),
|
|
473
|
+ UserOrgId: adminInfo.CurrentOrgId,
|
|
474
|
+ AdminUserId: adminInfo.AdminUser.Id,
|
|
475
|
+ IsReturn: 1,
|
515
|
476
|
}
|
516
|
477
|
|
517
|
|
- respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
|
518
|
|
- userJSONBytes, _ := json.Marshal(respJSON)
|
519
|
|
- var res ResultThree
|
520
|
|
- if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
521
|
|
- utils.ErrorLog("解析失败:%v", err)
|
522
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
523
|
|
- return
|
524
|
|
- }
|
525
|
|
- if res.Infcode == -1 {
|
526
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterTwoException)
|
|
478
|
+ if res.Output.Iinfo == nil || len(res.Output.Iinfo) == 0 {
|
|
479
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterOneException)
|
527
|
480
|
return
|
528
|
481
|
}
|
529
|
|
- fmt.Println("000!!!!!!")
|
530
|
|
- fmt.Println(res)
|
531
|
|
- fmt.Println(res.Output.Data.MdtrtID)
|
532
|
|
- fmt.Println(res.Output.Data.PsnNo)
|
533
|
|
- fmt.Println(res.Output.Data.IptOtpNo)
|
534
|
|
-
|
535
|
|
- his.Number = res.Output.Data.MdtrtID
|
536
|
|
- his.PsnNo = res.Output.Data.PsnNo
|
537
|
|
- his.IptOtpNo = res.Output.Data.IptOtpNo
|
538
|
|
- his.IdCardNo = patient.IdCardNo
|
539
|
|
- his.PhoneNumber = patient.Phone
|
540
|
|
- his.UserOrgId = adminInfo.CurrentOrgId
|
541
|
|
- his.Status = 1
|
542
|
|
- his.Ctime = time.Now().Unix()
|
543
|
|
- his.Mtime = time.Now().Unix()
|
544
|
|
- err := service.CreateHisPatientTwo(&his)
|
545
|
|
-
|
546
|
|
- diagnosisConfig, _ := service.FindDiagnoseById(patientPrescription.Diagnosis)
|
547
|
|
-
|
548
|
|
- if err == nil {
|
549
|
|
- api := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
|
550
|
|
- "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
|
551
|
|
- "&diag=" + diagnosisConfig.ClassName + "&org_name=" + miConfig.OrgName + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&doctor_id=" + strconv.FormatInt(patientPrescription.DoctorId, 10) + "&fixmedins_code=" + miConfig.Code + "&diag_code=" + diagnosisConfig.CountryCode +
|
552
|
|
- "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
|
|
482
|
+
|
|
483
|
+ timestamp := time.Now().Unix()
|
|
484
|
+ tempTime := time.Unix(timestamp, 0)
|
|
485
|
+ timeFormat := tempTime.Format("20060102150405")
|
|
486
|
+ chrgBchno := rand.Intn(100000) + 10000
|
|
487
|
+ ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
|
|
488
|
+ count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
|
|
489
|
+ department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
|
|
490
|
+ doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
|
|
491
|
+
|
|
492
|
+ if count <= 0 {
|
|
493
|
+ api := "http://127.0.0.1:9532/" + "gdyb/two?cert_no=" + patient.IdCardNo + "&insutype=" +
|
|
494
|
+ res.Output.Iinfo[0].Insutype + "&psn_no=" + res.Output.Baseinfo.PsnNo +
|
|
495
|
+ "&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&ipt_otp_no=" + ipt_otp_no +
|
|
496
|
+ "&dept=" + department.Name + "&fixmedins_code=" + miConfig.Code + "&dept_code=" + department.Number + "&doctor_id=" + doctor_id + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
|
553
|
497
|
resp, requestErr := http.Get(api)
|
554
|
498
|
if requestErr != nil {
|
555
|
499
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
556
|
500
|
return
|
557
|
501
|
}
|
558
|
|
-
|
|
502
|
+ defer resp.Body.Close()
|
559
|
503
|
body, ioErr := ioutil.ReadAll(resp.Body)
|
560
|
504
|
if ioErr != nil {
|
561
|
505
|
utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
|
|
@@ -571,10 +515,7 @@ func (c *HisApiController) GetRegisterInfo() {
|
571
|
515
|
|
572
|
516
|
respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
|
573
|
517
|
userJSONBytes, _ := json.Marshal(respJSON)
|
574
|
|
- fmt.Println(respJSON)
|
575
|
|
- fmt.Println(userJSONBytes)
|
576
|
|
-
|
577
|
|
- var res ResultSix
|
|
518
|
+ var res ResultThree
|
578
|
519
|
if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
579
|
520
|
utils.ErrorLog("解析失败:%v", err)
|
580
|
521
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
@@ -585,15 +526,66 @@ func (c *HisApiController) GetRegisterInfo() {
|
585
|
526
|
return
|
586
|
527
|
}
|
587
|
528
|
|
588
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
589
|
|
- "his_info": his,
|
590
|
|
- })
|
591
|
|
- } else {
|
592
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
593
|
|
- return
|
|
529
|
+ his.Number = res.Output.Data.MdtrtID
|
|
530
|
+ his.PsnNo = res.Output.Data.PsnNo
|
|
531
|
+ his.IptOtpNo = res.Output.Data.IptOtpNo
|
|
532
|
+ his.IdCardNo = patient.IdCardNo
|
|
533
|
+ his.PhoneNumber = patient.Phone
|
|
534
|
+ his.UserOrgId = adminInfo.CurrentOrgId
|
|
535
|
+ his.Status = 1
|
|
536
|
+ his.Ctime = time.Now().Unix()
|
|
537
|
+ his.Mtime = time.Now().Unix()
|
|
538
|
+ err := service.CreateHisPatientTwo(&his)
|
|
539
|
+ diagnosisConfig, _ := service.FindDiagnoseById(patientPrescription.Diagnosis)
|
|
540
|
+ if err == nil {
|
|
541
|
+ api := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
|
|
542
|
+ "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
|
|
543
|
+ "&diag=" + diagnosisConfig.ClassName + "&org_name=" + miConfig.OrgName + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&doctor_id=" + strconv.FormatInt(patientPrescription.DoctorId, 10) + "&fixmedins_code=" + miConfig.Code + "&diag_code=" + diagnosisConfig.CountryCode +
|
|
544
|
+ "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
|
|
545
|
+ resp, requestErr := http.Get(api)
|
|
546
|
+ if requestErr != nil {
|
|
547
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
548
|
+ return
|
|
549
|
+ }
|
|
550
|
+ body, ioErr := ioutil.ReadAll(resp.Body)
|
|
551
|
+ if ioErr != nil {
|
|
552
|
+ utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
|
|
553
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
554
|
+ return
|
|
555
|
+ }
|
|
556
|
+ var respJSON map[string]interface{}
|
|
557
|
+ if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
|
|
558
|
+ utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
|
559
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
560
|
+ return
|
|
561
|
+ }
|
|
562
|
+ respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
|
|
563
|
+ userJSONBytes, _ := json.Marshal(respJSON)
|
|
564
|
+ fmt.Println(respJSON)
|
|
565
|
+ fmt.Println(userJSONBytes)
|
|
566
|
+
|
|
567
|
+ var res ResultSix
|
|
568
|
+ if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
|
569
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
570
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
571
|
+ return
|
|
572
|
+ }
|
|
573
|
+ if res.Infcode == -1 {
|
|
574
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterTwoException)
|
|
575
|
+ return
|
|
576
|
+ }
|
|
577
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
578
|
+ "his_info": his,
|
|
579
|
+ })
|
|
580
|
+ } else {
|
|
581
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
582
|
+ return
|
|
583
|
+ }
|
594
|
584
|
}
|
|
585
|
+ } else {
|
|
586
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
|
|
587
|
+ return
|
595
|
588
|
}
|
596
|
|
-
|
597
|
589
|
} else {
|
598
|
590
|
timeStr := time.Now().Format("2006-01-02")
|
599
|
591
|
timeArr := strings.Split(timeStr, "-")
|