|
@@ -90,9 +90,9 @@ func StrPtr(s string) uintptr {
|
90
|
90
|
}
|
91
|
91
|
|
92
|
92
|
type ResultTwo struct {
|
93
|
|
- ErrMsg interface{} `json:"err_msg"`
|
94
|
|
- InfRefmsgid string `json:"inf_refmsgid"`
|
95
|
|
- Infcode int64 `json:"infcode"`
|
|
93
|
+ ErrMsg string `json:"err_msg"`
|
|
94
|
+ InfRefmsgid string `json:"inf_refmsgid"`
|
|
95
|
+ Infcode int64 `json:"infcode"`
|
96
|
96
|
Output struct {
|
97
|
97
|
Baseinfo struct {
|
98
|
98
|
Age float64 `json:"age"`
|
|
@@ -125,7 +125,7 @@ type ResultTwo struct {
|
125
|
125
|
}
|
126
|
126
|
type ResultThree struct {
|
127
|
127
|
Cainfo interface{} `json:"cainfo"`
|
128
|
|
- ErrMsg interface{} `json:"err_msg"`
|
|
128
|
+ ErrMsg string `json:"err_msg"`
|
129
|
129
|
InfRefmsgid string `json:"inf_refmsgid"`
|
130
|
130
|
Infcode int64 `json:"infcode"`
|
131
|
131
|
Output struct {
|
|
@@ -178,7 +178,7 @@ type ResultFive struct {
|
178
|
178
|
}
|
179
|
179
|
type ResultSix struct {
|
180
|
180
|
Cainfo interface{} `json:"cainfo"`
|
181
|
|
- ErrMsg interface{} `json:"err_msg"`
|
|
181
|
+ ErrMsg string `json:"err_msg"`
|
182
|
182
|
InfRefmsgid string `json:"inf_refmsgid"`
|
183
|
183
|
Infcode int64 `json:"infcode"`
|
184
|
184
|
Output struct {
|
|
@@ -400,15 +400,10 @@ func (c *HisApiController) GetRegisterInfo() {
|
400
|
400
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
|
401
|
401
|
return
|
402
|
402
|
}
|
403
|
|
-
|
404
|
|
- //org, _ := service.GetOrgById(adminInfo.CurrentOrgId)
|
405
|
403
|
config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
|
406
|
|
-
|
407
|
404
|
if config.IsOpen == 1 {
|
408
|
|
-
|
409
|
405
|
api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + patient.IdCardNo + "&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
|
410
|
406
|
resp, requestErr := http.Get(api)
|
411
|
|
-
|
412
|
407
|
if requestErr != nil {
|
413
|
408
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
414
|
409
|
return
|
|
@@ -441,7 +436,7 @@ func (c *HisApiController) GetRegisterInfo() {
|
441
|
436
|
infoStr := string(Iinfos)
|
442
|
437
|
idetinfoStr := string(Idetinfos)
|
443
|
438
|
|
444
|
|
- if res.Infcode == -1 {
|
|
439
|
+ if res.Infcode == 0 {
|
445
|
440
|
his := models.VMHisPatient{
|
446
|
441
|
Name: name,
|
447
|
442
|
Gender: gender,
|
|
@@ -475,11 +470,6 @@ func (c *HisApiController) GetRegisterInfo() {
|
475
|
470
|
IsReturn: 1,
|
476
|
471
|
}
|
477
|
472
|
|
478
|
|
- if res.Output.Iinfo == nil || len(res.Output.Iinfo) == 0 {
|
479
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterOneException)
|
480
|
|
- return
|
481
|
|
- }
|
482
|
|
-
|
483
|
473
|
timestamp := time.Now().Unix()
|
484
|
474
|
tempTime := time.Unix(timestamp, 0)
|
485
|
475
|
timeFormat := tempTime.Format("20060102150405")
|
|
@@ -522,6 +512,19 @@ func (c *HisApiController) GetRegisterInfo() {
|
522
|
512
|
return
|
523
|
513
|
}
|
524
|
514
|
if res.Infcode == -1 {
|
|
515
|
+ adminUser := c.GetAdminUserInfo()
|
|
516
|
+ errlog := &models.HisOrderError{
|
|
517
|
+ UserOrgId: adminUser.CurrentOrgId,
|
|
518
|
+ Ctime: time.Now().Unix(),
|
|
519
|
+ Mtime: time.Now().Unix(),
|
|
520
|
+ ErrMsg: res.ErrMsg,
|
|
521
|
+ Status: 1,
|
|
522
|
+ PatientId: id,
|
|
523
|
+ RecordTime: recordDateTime,
|
|
524
|
+ Stage: 2,
|
|
525
|
+ }
|
|
526
|
+ service.CreateErrMsgLog(errlog)
|
|
527
|
+
|
525
|
528
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterTwoException)
|
526
|
529
|
return
|
527
|
530
|
}
|
|
@@ -532,57 +535,83 @@ func (c *HisApiController) GetRegisterInfo() {
|
532
|
535
|
his.IdCardNo = patient.IdCardNo
|
533
|
536
|
his.PhoneNumber = patient.Phone
|
534
|
537
|
his.UserOrgId = adminInfo.CurrentOrgId
|
535
|
|
- his.Status = 1
|
536
|
538
|
his.Ctime = time.Now().Unix()
|
537
|
539
|
his.Mtime = time.Now().Unix()
|
538
|
|
- err := service.CreateHisPatientTwo(&his)
|
539
|
540
|
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
|
541
|
|
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 {
|
|
542
|
+ api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
|
|
543
|
+ "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
|
|
544
|
+ "&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 +
|
|
545
|
+ "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
|
|
546
|
+ resp2, requestErr2 := http.Get(api2)
|
|
547
|
+ if requestErr2 != nil {
|
581
|
548
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
582
|
549
|
return
|
583
|
550
|
}
|
|
551
|
+ body2, ioErr2 := ioutil.ReadAll(resp2.Body)
|
|
552
|
+ if ioErr2 != nil {
|
|
553
|
+ utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
|
|
554
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
555
|
+ return
|
|
556
|
+ }
|
|
557
|
+ var respJSON2 map[string]interface{}
|
|
558
|
+ if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
|
|
559
|
+ utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
|
560
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
561
|
+ return
|
|
562
|
+ }
|
|
563
|
+ respJSON2 = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
|
|
564
|
+ userJSONBytes2, _ := json.Marshal(respJSON2)
|
|
565
|
+ fmt.Println(respJSON2)
|
|
566
|
+ fmt.Println(userJSONBytes2)
|
|
567
|
+
|
|
568
|
+ var res2 ResultSix
|
|
569
|
+ if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
|
|
570
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
571
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
572
|
+ return
|
|
573
|
+ }
|
|
574
|
+ if res2.Infcode == -1 {
|
|
575
|
+ adminUser := c.GetAdminUserInfo()
|
|
576
|
+ errlog := &models.HisOrderError{
|
|
577
|
+ UserOrgId: adminUser.CurrentOrgId,
|
|
578
|
+ Ctime: time.Now().Unix(),
|
|
579
|
+ Mtime: time.Now().Unix(),
|
|
580
|
+ ErrMsg: res2.ErrMsg,
|
|
581
|
+ Status: 1,
|
|
582
|
+ PatientId: id,
|
|
583
|
+ RecordTime: recordDateTime,
|
|
584
|
+ Stage: 3,
|
|
585
|
+ }
|
|
586
|
+ service.CreateErrMsgLog(errlog)
|
|
587
|
+
|
|
588
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
|
|
589
|
+ return
|
|
590
|
+ }
|
|
591
|
+ his.Status = 1
|
|
592
|
+ service.CreateHisPatientTwo(&his)
|
|
593
|
+
|
|
594
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
595
|
+ "his_info": his,
|
|
596
|
+ })
|
|
597
|
+
|
|
598
|
+ } else {
|
|
599
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
|
|
600
|
+ return
|
584
|
601
|
}
|
585
|
602
|
} else {
|
|
603
|
+ adminUser := c.GetAdminUserInfo()
|
|
604
|
+ errlog := &models.HisOrderError{
|
|
605
|
+ UserOrgId: adminUser.CurrentOrgId,
|
|
606
|
+ Ctime: time.Now().Unix(),
|
|
607
|
+ Mtime: time.Now().Unix(),
|
|
608
|
+ ErrMsg: res.ErrMsg,
|
|
609
|
+ Status: 1,
|
|
610
|
+ PatientId: id,
|
|
611
|
+ RecordTime: recordDateTime,
|
|
612
|
+ Stage: 1,
|
|
613
|
+ }
|
|
614
|
+ service.CreateErrMsgLog(errlog)
|
586
|
615
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
|
587
|
616
|
return
|
588
|
617
|
}
|
|
@@ -632,7 +661,6 @@ func (c *HisApiController) GetRegisterInfo() {
|
632
|
661
|
func (c *HisApiController) GetUploadInfo() {
|
633
|
662
|
id, _ := c.GetInt64("id")
|
634
|
663
|
record_time := c.GetString("record_time")
|
635
|
|
-
|
636
|
664
|
pay_way, _ := c.GetInt64("pay_way")
|
637
|
665
|
pay_price, _ := c.GetFloat("pay_price")
|
638
|
666
|
pay_card_no := c.GetString("pay_card_no")
|
|
@@ -642,10 +670,8 @@ func (c *HisApiController) GetUploadInfo() {
|
642
|
670
|
found_price, _ := c.GetFloat("found_price")
|
643
|
671
|
medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
|
644
|
672
|
private_price, _ := c.GetFloat("private_price")
|
645
|
|
-
|
646
|
673
|
timeLayout := "2006-01-02"
|
647
|
674
|
loc, _ := time.LoadLocation("Local")
|
648
|
|
-
|
649
|
675
|
theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
|
650
|
676
|
if err != nil {
|
651
|
677
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
@@ -654,7 +680,6 @@ func (c *HisApiController) GetUploadInfo() {
|
654
|
680
|
recordDateTime := theTime.Unix()
|
655
|
681
|
adminUser := c.GetAdminUserInfo()
|
656
|
682
|
prescriptions, _ := service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
|
657
|
|
-
|
658
|
683
|
his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
|
659
|
684
|
|
660
|
685
|
timestamp := time.Now().Unix()
|
|
@@ -663,11 +688,8 @@ func (c *HisApiController) GetUploadInfo() {
|
663
|
688
|
chrgBchno := rand.Intn(100000) + 10000
|
664
|
689
|
chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
|
665
|
690
|
miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
|
666
|
|
-
|
667
|
|
- //org, _ := service.GetOrgById(adminUser.CurrentOrgId)
|
668
|
691
|
patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
|
669
|
692
|
department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
|
670
|
|
-
|
671
|
693
|
strconv.FormatInt(his.PatientId, 10)
|
672
|
694
|
client := &http.Client{}
|
673
|
695
|
data := make(map[string]interface{})
|
|
@@ -678,39 +700,18 @@ func (c *HisApiController) GetUploadInfo() {
|
678
|
700
|
data["org_name"] = miConfig.OrgName
|
679
|
701
|
data["doctor"] = patientPrescription.Doctor
|
680
|
702
|
data["doctor_id"] = strconv.FormatInt(patientPrescription.DoctorId, 10)
|
681
|
|
-
|
682
|
703
|
data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
|
683
|
|
-
|
684
|
704
|
data["fixmedins_code"] = miConfig.Code
|
685
|
705
|
data["dept_code"] = department.Number
|
686
|
706
|
data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
|
687
|
707
|
data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
|
688
|
708
|
data["secret_key"] = miConfig.SecretKey
|
689
|
|
-
|
690
|
|
- fmt.Println(his.PsnNo)
|
691
|
|
- fmt.Println(his.Number)
|
692
|
|
-
|
693
|
|
- fmt.Println(miConfig.OrgName)
|
694
|
|
-
|
695
|
|
- fmt.Println(chrg_bchno)
|
696
|
|
- fmt.Println(patientPrescription.Doctor)
|
697
|
|
- fmt.Println(miConfig.Code)
|
698
|
|
- fmt.Println(department.Number)
|
699
|
|
- fmt.Println(strconv.FormatInt(patientPrescription.Departments, 10))
|
700
|
|
-
|
701
|
|
- fmt.Println(miConfig.InsuplcAdmdvs)
|
702
|
|
- fmt.Println(miConfig.MdtrtareaAdmvs)
|
703
|
|
- fmt.Println(miConfig.SecretKey)
|
704
|
|
-
|
705
|
709
|
var ids []int64
|
706
|
|
- //var idsTwo []int64
|
707
|
|
- //
|
|
710
|
+
|
708
|
711
|
for _, item := range prescriptions {
|
709
|
712
|
ids = append(ids, item.ID)
|
710
|
713
|
}
|
711
|
|
-
|
712
|
714
|
config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
|
713
|
|
-
|
714
|
715
|
if config.IsOpen == 1 { //对接了医保,走医保流程
|
715
|
716
|
bytesData, _ := json.Marshal(data)
|
716
|
717
|
req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
|
|
@@ -768,7 +769,7 @@ func (c *HisApiController) GetUploadInfo() {
|
768
|
769
|
}
|
769
|
770
|
err = service.CreateOrder(order)
|
770
|
771
|
if err != nil {
|
771
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
|
|
772
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
|
772
|
773
|
return
|
773
|
774
|
}
|
774
|
775
|
|
|
@@ -823,138 +824,165 @@ func (c *HisApiController) GetUploadInfo() {
|
823
|
824
|
Type: types,
|
824
|
825
|
}
|
825
|
826
|
service.CreateOrderInfo(info)
|
826
|
|
- }
|
827
|
|
- service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
|
828
|
|
- service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
|
829
|
|
- var total float64
|
830
|
|
- for _, item := range prescriptions {
|
831
|
|
- if item.Type == 1 { //药品
|
832
|
|
- for _, subItem := range item.HisDoctorAdviceInfo {
|
833
|
|
- total = total + (subItem.Price * subItem.PrescribingNumber)
|
|
827
|
+ service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
|
|
828
|
+ service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
|
|
829
|
+
|
|
830
|
+ var total float64
|
|
831
|
+ for _, item := range prescriptions {
|
|
832
|
+ if item.Type == 1 { //药品
|
|
833
|
+ for _, subItem := range item.HisDoctorAdviceInfo {
|
|
834
|
+ total = total + (subItem.Price * subItem.PrescribingNumber)
|
|
835
|
+ }
|
834
|
836
|
}
|
835
|
|
- }
|
836
|
|
- if item.Type == 2 { //项目
|
837
|
|
- for _, subItem := range item.HisPrescriptionProject {
|
838
|
|
- total = total + (subItem.Price * float64(subItem.Count))
|
|
837
|
+ if item.Type == 2 { //项目
|
|
838
|
+ for _, subItem := range item.HisPrescriptionProject {
|
|
839
|
+ total = total + (subItem.Price * float64(subItem.Count))
|
|
840
|
+ }
|
839
|
841
|
}
|
840
|
842
|
}
|
841
|
|
- }
|
842
|
|
- //org, _ := service.GetOrgById(adminUser.CurrentOrgId)
|
843
|
|
- patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
|
844
|
|
- allTotal := fmt.Sprintf("%.2f", total)
|
845
|
|
- if res.Infcode == 0 {
|
846
|
|
- var rf []*ResultFive
|
847
|
|
- json.Unmarshal([]byte(his.Iinfo), &rf)
|
848
|
|
- psn_no := his.PsnNo
|
849
|
|
- mdtrt_id := his.Number
|
850
|
|
- chrg_bchno := chrg_bchno
|
851
|
|
- cert_no := his.Certno
|
852
|
|
- insutype := rf[0].Insutype
|
853
|
|
- api := "http://127.0.0.1:9532/" + "gdyb/eight?cert_no=" + cert_no + "&insutype=" +
|
854
|
|
- insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
|
855
|
|
- "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
|
856
|
|
- resp, requestErr := http.Get(api)
|
|
843
|
+ allTotal := fmt.Sprintf("%.2f", total)
|
|
844
|
+ if res.Infcode == 0 {
|
|
845
|
+ var rf []*ResultFive
|
|
846
|
+ json.Unmarshal([]byte(his.Iinfo), &rf)
|
|
847
|
+ psn_no := his.PsnNo
|
|
848
|
+ mdtrt_id := his.Number
|
|
849
|
+ chrg_bchno := chrg_bchno
|
|
850
|
+ cert_no := his.Certno
|
|
851
|
+ insutype := rf[0].Insutype
|
|
852
|
+ api := "http://127.0.0.1:9532/" + "gdyb/eight?cert_no=" + cert_no + "&insutype=" +
|
|
853
|
+ insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
|
|
854
|
+ "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
|
|
855
|
+ resp, requestErr := http.Get(api)
|
857
|
856
|
|
858
|
|
- if requestErr != nil {
|
859
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
860
|
|
- return
|
861
|
|
- }
|
862
|
|
- defer resp.Body.Close()
|
863
|
|
- body, ioErr := ioutil.ReadAll(resp.Body)
|
864
|
|
- if ioErr != nil {
|
865
|
|
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
|
866
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
867
|
|
- return
|
868
|
|
- }
|
869
|
|
- var respJSON map[string]interface{}
|
870
|
|
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
|
871
|
|
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
872
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
873
|
|
- return
|
874
|
|
- }
|
875
|
|
- fmt.Println(respJSON)
|
876
|
|
- respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
|
877
|
|
- userJSONBytes, _ := json.Marshal(respJSON)
|
878
|
|
- var res ResultSeven
|
879
|
|
- if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
880
|
|
- utils.ErrorLog("解析失败:%v", err)
|
881
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
882
|
|
- return
|
883
|
|
- }
|
884
|
|
- if res.Infcode == -1 {
|
|
857
|
+ if requestErr != nil {
|
|
858
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
859
|
+ return
|
|
860
|
+ }
|
|
861
|
+ defer resp.Body.Close()
|
|
862
|
+ body, ioErr := ioutil.ReadAll(resp.Body)
|
|
863
|
+ if ioErr != nil {
|
|
864
|
+ utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
|
|
865
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
866
|
+ return
|
|
867
|
+ }
|
|
868
|
+ var respJSON map[string]interface{}
|
|
869
|
+ if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
|
|
870
|
+ utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
|
871
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
872
|
+ return
|
|
873
|
+ }
|
|
874
|
+ fmt.Println(respJSON)
|
|
875
|
+ respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
|
|
876
|
+ userJSONBytes, _ := json.Marshal(respJSON)
|
|
877
|
+ var res ResultSeven
|
|
878
|
+ if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
|
879
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
880
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
881
|
+ return
|
|
882
|
+ }
|
|
883
|
+ if res.Infcode == -1 {
|
|
884
|
+ errlog := &models.HisOrderError{
|
|
885
|
+ UserOrgId: adminUser.CurrentOrgId,
|
|
886
|
+ Ctime: time.Now().Unix(),
|
|
887
|
+ Mtime: time.Now().Unix(),
|
|
888
|
+ Number: chrg_bchno,
|
|
889
|
+ ErrMsg: res.ErrMsg,
|
|
890
|
+ Status: 1,
|
|
891
|
+ PatientId: id,
|
|
892
|
+ RecordTime: recordDateTime,
|
|
893
|
+ Stage: 7,
|
|
894
|
+ }
|
|
895
|
+ service.CreateErrMsgLog(errlog)
|
|
896
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
|
|
897
|
+ return
|
|
898
|
+ } else {
|
|
899
|
+ order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
|
|
900
|
+ order.OrderStatus = 2
|
|
901
|
+ order.MdtrtId = res.Output.Setlinfo.MdtrtID
|
|
902
|
+ order.SetlId = res.Output.Setlinfo.SetlID
|
|
903
|
+ order.PsnNo = res.Output.Setlinfo.PsnNo
|
|
904
|
+ order.PsnName = res.Output.Setlinfo.PsnName
|
|
905
|
+ order.PsnCertType = res.Output.Setlinfo.PsnCertType
|
|
906
|
+ order.Certno = res.Output.Setlinfo.Certno
|
|
907
|
+ order.Gend = res.Output.Setlinfo.Gend
|
|
908
|
+ order.Naty = res.Output.Setlinfo.Naty
|
|
909
|
+ order.Age = res.Output.Setlinfo.Age
|
|
910
|
+ order.Insutype = res.Output.Setlinfo.Insutype
|
|
911
|
+ order.PsnType = res.Output.Setlinfo.PsnType
|
|
912
|
+ order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
|
|
913
|
+ order.SetlTime = res.Output.Setlinfo.SetlTime
|
|
914
|
+ order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
|
|
915
|
+ order.MedType = res.Output.Setlinfo.MedType
|
|
916
|
+ order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
|
|
917
|
+ order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
|
|
918
|
+ order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
|
|
919
|
+ order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
|
|
920
|
+ order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
|
|
921
|
+ order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
|
|
922
|
+ order.HifpPay = res.Output.Setlinfo.HifpPay
|
|
923
|
+ order.CvlservPay = res.Output.Setlinfo.CvlservPay
|
|
924
|
+ order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
|
|
925
|
+ order.HifesPay = res.Output.Setlinfo.HifesPay
|
|
926
|
+ order.HifobPay = res.Output.Setlinfo.HifobPay
|
|
927
|
+ order.MafPay = res.Output.Setlinfo.MafPay
|
|
928
|
+ order.OthPay = res.Output.Setlinfo.OthPay
|
|
929
|
+ order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
|
|
930
|
+ order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
|
|
931
|
+ order.AcctPay = res.Output.Setlinfo.AcctPay
|
|
932
|
+ order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
|
|
933
|
+ order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
|
|
934
|
+ order.Balc = res.Output.Setlinfo.Balc
|
|
935
|
+ order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
|
|
936
|
+ order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
|
|
937
|
+ order.ClrOptins = res.Output.Setlinfo.ClrOptins
|
|
938
|
+ order.ClrWay = res.Output.Setlinfo.ClrWay
|
|
939
|
+ setlDetail, _ := json.Marshal(res.Output.Setldetail)
|
|
940
|
+ detailStr := string(setlDetail)
|
|
941
|
+ order.SetlDetail = detailStr
|
|
942
|
+ err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
|
|
943
|
+ err = service.UpDateOrder(order)
|
|
944
|
+ if err == nil {
|
|
945
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
946
|
+ "msg": "结算成功",
|
|
947
|
+ })
|
|
948
|
+ } else {
|
|
949
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
|
|
950
|
+ return
|
|
951
|
+ }
|
|
952
|
+ }
|
|
953
|
+ } else {
|
|
954
|
+ adminUser := c.GetAdminUserInfo()
|
885
|
955
|
errlog := &models.HisOrderError{
|
886
|
956
|
UserOrgId: adminUser.CurrentOrgId,
|
887
|
957
|
Ctime: time.Now().Unix(),
|
888
|
958
|
Mtime: time.Now().Unix(),
|
889
|
|
- Number: chrg_bchno,
|
890
|
959
|
ErrMsg: res.ErrMsg,
|
891
|
960
|
Status: 1,
|
892
|
961
|
PatientId: id,
|
893
|
962
|
RecordTime: recordDateTime,
|
894
|
|
- Stage: 7,
|
|
963
|
+ Stage: 5,
|
895
|
964
|
}
|
896
|
|
-
|
897
|
965
|
service.CreateErrMsgLog(errlog)
|
898
|
966
|
|
899
|
|
- } else {
|
900
|
|
- order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
|
901
|
|
- order.OrderStatus = 2
|
902
|
|
- order.MdtrtId = res.Output.Setlinfo.MdtrtID
|
903
|
|
- order.SetlId = res.Output.Setlinfo.SetlID
|
904
|
|
- order.PsnNo = res.Output.Setlinfo.PsnNo
|
905
|
|
- order.PsnName = res.Output.Setlinfo.PsnName
|
906
|
|
- order.PsnCertType = res.Output.Setlinfo.PsnCertType
|
907
|
|
- order.Certno = res.Output.Setlinfo.Certno
|
908
|
|
- order.Gend = res.Output.Setlinfo.Gend
|
909
|
|
- order.Naty = res.Output.Setlinfo.Naty
|
910
|
|
- order.Age = res.Output.Setlinfo.Age
|
911
|
|
- order.Insutype = res.Output.Setlinfo.Insutype
|
912
|
|
- order.PsnType = res.Output.Setlinfo.PsnType
|
913
|
|
- order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
|
914
|
|
- order.SetlTime = res.Output.Setlinfo.SetlTime
|
915
|
|
- order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
|
916
|
|
- order.MedType = res.Output.Setlinfo.MedType
|
917
|
|
- order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
|
918
|
|
- order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
|
919
|
|
- order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
|
920
|
|
- order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
|
921
|
|
- order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
|
922
|
|
- order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
|
923
|
|
- order.HifpPay = res.Output.Setlinfo.HifpPay
|
924
|
|
- order.CvlservPay = res.Output.Setlinfo.CvlservPay
|
925
|
|
- order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
|
926
|
|
- order.HifesPay = res.Output.Setlinfo.HifesPay
|
927
|
|
- order.HifobPay = res.Output.Setlinfo.HifobPay
|
928
|
|
- order.MafPay = res.Output.Setlinfo.MafPay
|
929
|
|
- order.OthPay = res.Output.Setlinfo.OthPay
|
930
|
|
- order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
|
931
|
|
- order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
|
932
|
|
- order.AcctPay = res.Output.Setlinfo.AcctPay
|
933
|
|
- order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
|
934
|
|
- order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
|
935
|
|
- order.Balc = res.Output.Setlinfo.Balc
|
936
|
|
- order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
|
937
|
|
- order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
|
938
|
|
- order.ClrOptins = res.Output.Setlinfo.ClrOptins
|
939
|
|
- order.ClrWay = res.Output.Setlinfo.ClrWay
|
940
|
|
- setlDetail, _ := json.Marshal(res.Output.Setldetail)
|
941
|
|
- detailStr := string(setlDetail)
|
942
|
|
- order.SetlDetail = detailStr
|
943
|
|
- err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
|
944
|
|
- err = service.UpDateOrder(order)
|
945
|
|
- if err == nil {
|
946
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
947
|
|
- "msg": "结算成功",
|
948
|
|
- })
|
949
|
|
- }
|
|
967
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
|
|
968
|
+ return
|
950
|
969
|
}
|
951
|
|
- } else {
|
952
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
|
953
|
|
- return
|
954
|
970
|
}
|
955
|
|
-
|
956
|
971
|
} else {
|
957
|
|
-
|
|
972
|
+ adminUser := c.GetAdminUserInfo()
|
|
973
|
+ errlog := &models.HisOrderError{
|
|
974
|
+ UserOrgId: adminUser.CurrentOrgId,
|
|
975
|
+ Ctime: time.Now().Unix(),
|
|
976
|
+ Mtime: time.Now().Unix(),
|
|
977
|
+ ErrMsg: res.ErrMsg,
|
|
978
|
+ Status: 1,
|
|
979
|
+ PatientId: id,
|
|
980
|
+ RecordTime: recordDateTime,
|
|
981
|
+ Stage: 4,
|
|
982
|
+ }
|
|
983
|
+ service.CreateErrMsgLog(errlog)
|
|
984
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
|
|
985
|
+ return
|
958
|
986
|
}
|
959
|
987
|
|
960
|
988
|
} else {
|
|
@@ -1001,7 +1029,7 @@ func (c *HisApiController) GetUploadInfo() {
|
1001
|
1029
|
}
|
1002
|
1030
|
err = service.CreateOrder(order)
|
1003
|
1031
|
if err != nil {
|
1004
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
|
|
1032
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
|
1005
|
1033
|
return
|
1006
|
1034
|
}
|
1007
|
1035
|
|
|
@@ -1114,6 +1142,9 @@ func (c *HisApiController) GetUploadInfo() {
|
1114
|
1142
|
c.ServeSuccessJSON(map[string]interface{}{
|
1115
|
1143
|
"msg": "结算成功",
|
1116
|
1144
|
})
|
|
1145
|
+ } else {
|
|
1146
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
|
|
1147
|
+ return
|
1117
|
1148
|
}
|
1118
|
1149
|
}
|
1119
|
1150
|
}
|
|
@@ -1124,10 +1155,8 @@ func (c *HisApiController) Refund() {
|
1124
|
1155
|
number := c.GetString("number")
|
1125
|
1156
|
record_time := c.GetString("record_time")
|
1126
|
1157
|
patient_id, _ := c.GetInt64("patient_id")
|
1127
|
|
-
|
1128
|
1158
|
timeLayout := "2006-01-02"
|
1129
|
1159
|
loc, _ := time.LoadLocation("Local")
|
1130
|
|
-
|
1131
|
1160
|
adminUser := c.GetAdminUserInfo()
|
1132
|
1161
|
theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
|
1133
|
1162
|
fmt.Println(err)
|
|
@@ -1136,13 +1165,12 @@ func (c *HisApiController) Refund() {
|
1136
|
1165
|
return
|
1137
|
1166
|
}
|
1138
|
1167
|
recordDateTime := theTime.Unix()
|
1139
|
|
-
|
1140
|
1168
|
his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
|
1141
|
1169
|
patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
|
1142
|
1170
|
order, _ := service.GetHisOrderByID(order_id)
|
1143
|
|
-
|
1144
|
1171
|
miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
|
1145
|
1172
|
config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
|
|
1173
|
+
|
1146
|
1174
|
if config.IsOpen == 1 { //对接了医保,走医保流程
|
1147
|
1175
|
api := "http://127.0.0.1:9532/" + "gdyb/nine?psn_no=" + his.PsnNo +
|
1148
|
1176
|
"&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&setl_id=" + order.SetlId + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
|