|
@@ -648,6 +648,170 @@ func (c *HisApiController) ReadCard() {
|
648
|
648
|
|
649
|
649
|
break
|
650
|
650
|
case 3:
|
|
651
|
+ if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
|
|
652
|
+ var api string
|
|
653
|
+ if miConfig.MdtrtareaAdmvs == "320921" {
|
|
654
|
+ api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
|
|
655
|
+ "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "operator_id=" + strconv.FormatInt(admin_user_id, 10) + "operator=" + roles.UserName
|
|
656
|
+
|
|
657
|
+ } else {
|
|
658
|
+ api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
|
|
659
|
+ "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
|
|
660
|
+ }
|
|
661
|
+
|
|
662
|
+ resp, requestErr := http.Get(api)
|
|
663
|
+ if requestErr != nil {
|
|
664
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
665
|
+ return
|
|
666
|
+ }
|
|
667
|
+
|
|
668
|
+ body, ioErr := ioutil.ReadAll(resp.Body)
|
|
669
|
+ if ioErr != nil {
|
|
670
|
+ utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
|
|
671
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
672
|
+ return
|
|
673
|
+ }
|
|
674
|
+ var respJSON map[string]interface{}
|
|
675
|
+ if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
|
|
676
|
+ utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
|
677
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
678
|
+ return
|
|
679
|
+ }
|
|
680
|
+ var status string
|
|
681
|
+ status = respJSON["data"].(map[string]interface{})["status"].(string)
|
|
682
|
+ card_type := respJSON["data"].(map[string]interface{})["type"].(string)
|
|
683
|
+
|
|
684
|
+ var token string
|
|
685
|
+ var res ResultTwo //1101结果
|
|
686
|
+ var res10265 ResultTwo10265 //1101结果
|
|
687
|
+ var card_info string //卡信息
|
|
688
|
+ var busi_card_info string
|
|
689
|
+
|
|
690
|
+ card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
|
|
691
|
+ busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
|
|
692
|
+
|
|
693
|
+ if status == "0" { //读卡成功
|
|
694
|
+ if card_type == "1" {
|
|
695
|
+
|
|
696
|
+ respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
|
|
697
|
+ result, _ := json.Marshal(respJSON)
|
|
698
|
+
|
|
699
|
+ if err := json.Unmarshal([]byte(result), &res10265); err != nil {
|
|
700
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
701
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
702
|
+ return
|
|
703
|
+ }
|
|
704
|
+ res.ErrMsg = res10265.ErrMsg
|
|
705
|
+ infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
|
|
706
|
+ res.Infcode = infocode
|
|
707
|
+ res.Output = res10265.Output
|
|
708
|
+ res.InfRefmsgid = res10265.InfRefmsgid
|
|
709
|
+
|
|
710
|
+ } else {
|
|
711
|
+ //var card_info string //卡信息
|
|
712
|
+ //var busi_card_info string
|
|
713
|
+
|
|
714
|
+ token = respJSON["data"].(map[string]interface{})["token"].(string)
|
|
715
|
+ //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
|
|
716
|
+
|
|
717
|
+ //fmt.Println(card_info)
|
|
718
|
+ //fmt.Println(busi_card_info)
|
|
719
|
+
|
|
720
|
+ respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
|
|
721
|
+ result, _ := json.Marshal(respJSON)
|
|
722
|
+
|
|
723
|
+ if err := json.Unmarshal([]byte(result), &res10265); err != nil {
|
|
724
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
725
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
726
|
+ return
|
|
727
|
+ }
|
|
728
|
+ res.ErrMsg = res10265.ErrMsg
|
|
729
|
+ infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
|
|
730
|
+ res.Infcode = infocode
|
|
731
|
+ res.Output = res10265.Output
|
|
732
|
+ res.InfRefmsgid = res10265.InfRefmsgid
|
|
733
|
+
|
|
734
|
+ }
|
|
735
|
+
|
|
736
|
+ if res.Infcode == 0 {
|
|
737
|
+ patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
|
|
738
|
+ if err == gorm.ErrRecordNotFound {
|
|
739
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
|
|
740
|
+ return
|
|
741
|
+ } else if err != nil {
|
|
742
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
743
|
+ return
|
|
744
|
+
|
|
745
|
+ } else {
|
|
746
|
+
|
|
747
|
+ if card_type == "1" {
|
|
748
|
+ bas := strings.Split(card_info, "|")
|
|
749
|
+ basNumber := bas[2]
|
|
750
|
+ Iinfos, _ := json.Marshal(res.Output.Iinfo)
|
|
751
|
+ Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
|
|
752
|
+ infoStr := string(Iinfos)
|
|
753
|
+ idetinfoStr := string(Idetinfos)
|
|
754
|
+ psn := &models.HisPsn{
|
|
755
|
+ PsnNo: res.Output.Baseinfo.PsnNo,
|
|
756
|
+ Age: res.Output.Baseinfo.Age,
|
|
757
|
+ PatientId: patient.ID,
|
|
758
|
+ Certno: res.Output.Baseinfo.Certno,
|
|
759
|
+ Brdy: res.Output.Baseinfo.Brdy,
|
|
760
|
+ Gend: res.Output.Baseinfo.Gend,
|
|
761
|
+ Naty: res.Output.Baseinfo.Naty,
|
|
762
|
+ PsnCertType: res.Output.Baseinfo.PsnCertType,
|
|
763
|
+ PsnName: res.Output.Baseinfo.PsnName,
|
|
764
|
+ Idetinfo: idetinfoStr,
|
|
765
|
+ Insuinfo: infoStr,
|
|
766
|
+ UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
|
|
767
|
+ CardInfo: card_info,
|
|
768
|
+ VerifyNumber: busi_card_info,
|
|
769
|
+ }
|
|
770
|
+ service.CreateHisPsn(psn)
|
|
771
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
772
|
+ "patient": patient,
|
|
773
|
+ "number": basNumber,
|
|
774
|
+ })
|
|
775
|
+ } else {
|
|
776
|
+ Iinfos, _ := json.Marshal(res.Output.Iinfo)
|
|
777
|
+ Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
|
|
778
|
+ infoStr := string(Iinfos)
|
|
779
|
+ idetinfoStr := string(Idetinfos)
|
|
780
|
+ psn := &models.HisPsn{
|
|
781
|
+ PsnNo: res.Output.Baseinfo.PsnNo,
|
|
782
|
+ Age: res.Output.Baseinfo.Age,
|
|
783
|
+ PatientId: patient.ID,
|
|
784
|
+ Certno: res.Output.Baseinfo.Certno,
|
|
785
|
+ Brdy: res.Output.Baseinfo.Brdy,
|
|
786
|
+ Gend: res.Output.Baseinfo.Gend,
|
|
787
|
+ Naty: res.Output.Baseinfo.Naty,
|
|
788
|
+ PsnCertType: res.Output.Baseinfo.PsnCertType,
|
|
789
|
+ PsnName: res.Output.Baseinfo.PsnName,
|
|
790
|
+ Idetinfo: idetinfoStr,
|
|
791
|
+ Insuinfo: infoStr,
|
|
792
|
+ UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
|
|
793
|
+ CardInfo: card_info,
|
|
794
|
+ VerifyNumber: token,
|
|
795
|
+ }
|
|
796
|
+ service.CreateHisPsn(psn)
|
|
797
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
798
|
+ "patient": patient,
|
|
799
|
+ "number": token,
|
|
800
|
+ })
|
|
801
|
+ }
|
|
802
|
+ }
|
|
803
|
+ } else {
|
|
804
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
|
|
805
|
+ return
|
|
806
|
+ }
|
|
807
|
+ } else { //读卡失败
|
|
808
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
|
|
809
|
+ return
|
|
810
|
+
|
|
811
|
+ }
|
|
812
|
+
|
|
813
|
+ }
|
|
814
|
+
|
651
|
815
|
break
|
652
|
816
|
}
|
653
|
817
|
|