|
@@ -1510,7 +1510,7 @@ func (c *ZHHisApiController) GetZHInHospitalCheck() {
|
1510
|
1510
|
if med_type == 14 {
|
1511
|
1511
|
if insutype == "390" {
|
1512
|
1512
|
|
1513
|
|
- struct2401.MedType = "990502"
|
|
1513
|
+ struct2401.MedType = "9933"
|
1514
|
1514
|
|
1515
|
1515
|
} else if insutype == "310" {
|
1516
|
1516
|
|
|
@@ -3683,148 +3683,288 @@ type ELeData struct {
|
3683
|
3683
|
Message string `json:"message"`
|
3684
|
3684
|
}
|
3685
|
3685
|
|
|
3686
|
+var initFlagTwo int64 = 0
|
|
3687
|
+
|
3686
|
3688
|
func (c *ZHHisApiController) ReadCard() {
|
3687
|
3689
|
id_card_type, _ := c.GetInt64("id_card_type")
|
3688
|
3690
|
admin_user_id, _ := c.GetInt64("admin_user_id")
|
3689
|
3691
|
roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
|
3690
|
3692
|
miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
|
3691
|
3693
|
|
3692
|
|
- if miConfig.MdtrtareaAdmvs == "" {
|
|
3694
|
+ switch id_card_type {
|
|
3695
|
+ case 1: //社保卡
|
|
3696
|
+ if miConfig.MdtrtareaAdmvs == "150499" {
|
|
3697
|
+ var api string
|
|
3698
|
+ api = "http://172.16.13.254:9532/" + "nmyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
|
|
3699
|
+ "&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
|
3693
|
3700
|
|
3694
|
|
- } else {
|
|
3701
|
+ fmt.Println(api)
|
3695
|
3702
|
|
3696
|
|
- }
|
|
3703
|
+ resp, requestErr := http.Get(api)
|
|
3704
|
+ if requestErr != nil {
|
|
3705
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
3706
|
+ return
|
|
3707
|
+ }
|
3697
|
3708
|
|
3698
|
|
- var api string
|
3699
|
|
- api = "http://172.16.13.254:9532/" + "nmyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
|
3700
|
|
- "&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
|
|
3709
|
+ body, ioErr := ioutil.ReadAll(resp.Body)
|
|
3710
|
+ if ioErr != nil {
|
|
3711
|
+ utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
|
|
3712
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
3713
|
+ return
|
|
3714
|
+ }
|
|
3715
|
+ var respJSON map[string]interface{}
|
|
3716
|
+ if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
|
|
3717
|
+ utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
|
3718
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
3719
|
+ return
|
|
3720
|
+ }
|
|
3721
|
+ var status string
|
|
3722
|
+ status = respJSON["data"].(map[string]interface{})["status"].(string)
|
|
3723
|
+ card_type := respJSON["data"].(map[string]interface{})["type"].(string)
|
|
3724
|
+ //console.log()
|
|
3725
|
+ fmt.Println("type===")
|
3701
|
3726
|
|
3702
|
|
- fmt.Println(api)
|
|
3727
|
+ fmt.Println(card_type)
|
3703
|
3728
|
|
3704
|
|
- resp, requestErr := http.Get(api)
|
3705
|
|
- if requestErr != nil {
|
3706
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
3707
|
|
- return
|
3708
|
|
- }
|
|
3729
|
+ var token string
|
|
3730
|
+ var res ResultTwo //1101结果
|
|
3731
|
+ var res10265 ResultTwo10265 //1101结果
|
|
3732
|
+ var card_info string //卡信息
|
|
3733
|
+ var busi_card_info string
|
3709
|
3734
|
|
3710
|
|
- body, ioErr := ioutil.ReadAll(resp.Body)
|
3711
|
|
- if ioErr != nil {
|
3712
|
|
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
|
3713
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
3714
|
|
- return
|
3715
|
|
- }
|
3716
|
|
- var respJSON map[string]interface{}
|
3717
|
|
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
|
3718
|
|
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
3719
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
3720
|
|
- return
|
3721
|
|
- }
|
3722
|
|
- var status string
|
3723
|
|
- status = respJSON["data"].(map[string]interface{})["status"].(string)
|
3724
|
|
- card_type := respJSON["data"].(map[string]interface{})["type"].(string)
|
3725
|
|
- //console.log()
|
3726
|
|
- fmt.Println("type===")
|
|
3735
|
+ card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
|
|
3736
|
+ busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
|
3727
|
3737
|
|
3728
|
|
- fmt.Println(card_type)
|
|
3738
|
+ if status == "0" { //读卡成功
|
|
3739
|
+ if card_type == "1" {
|
3729
|
3740
|
|
3730
|
|
- var token string
|
3731
|
|
- var res ResultTwo //1101结果
|
3732
|
|
- var res10265 ResultTwo10265 //1101结果
|
3733
|
|
- var card_info string //卡信息
|
3734
|
|
- var busi_card_info string
|
|
3741
|
+ respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
|
|
3742
|
+ result, _ := json.Marshal(respJSON)
|
3735
|
3743
|
|
3736
|
|
- card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
|
3737
|
|
- busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
|
|
3744
|
+ if err := json.Unmarshal([]byte(result), &res10265); err != nil {
|
|
3745
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
3746
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
3747
|
+ return
|
|
3748
|
+ }
|
|
3749
|
+ res.ErrMsg = res10265.ErrMsg
|
|
3750
|
+ infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
|
|
3751
|
+ res.Infcode = infocode
|
|
3752
|
+ res.Output = res10265.Output
|
|
3753
|
+ res.InfRefmsgid = res10265.InfRefmsgid
|
3738
|
3754
|
|
3739
|
|
- if status == "0" { //读卡成功
|
3740
|
|
- if card_type == "1" {
|
|
3755
|
+ } else {
|
|
3756
|
+ //var card_info string //卡信息
|
|
3757
|
+ //var busi_card_info string
|
3741
|
3758
|
|
3742
|
|
- respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
|
3743
|
|
- result, _ := json.Marshal(respJSON)
|
|
3759
|
+ token = respJSON["data"].(map[string]interface{})["token"].(string)
|
|
3760
|
+ //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
|
3744
|
3761
|
|
3745
|
|
- if err := json.Unmarshal([]byte(result), &res10265); err != nil {
|
3746
|
|
- utils.ErrorLog("解析失败:%v", err)
|
3747
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
3762
|
+ //fmt.Println(card_info)
|
|
3763
|
+ //fmt.Println(busi_card_info)
|
|
3764
|
+
|
|
3765
|
+ respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
|
|
3766
|
+ result, _ := json.Marshal(respJSON)
|
|
3767
|
+
|
|
3768
|
+ if err := json.Unmarshal([]byte(result), &res10265); err != nil {
|
|
3769
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
3770
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
3771
|
+ return
|
|
3772
|
+ }
|
|
3773
|
+ res.ErrMsg = res10265.ErrMsg
|
|
3774
|
+ infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
|
|
3775
|
+ res.Infcode = infocode
|
|
3776
|
+ res.Output = res10265.Output
|
|
3777
|
+ res.InfRefmsgid = res10265.InfRefmsgid
|
|
3778
|
+
|
|
3779
|
+ }
|
|
3780
|
+
|
|
3781
|
+ if res.Infcode == 0 {
|
|
3782
|
+ var insutypes []string
|
|
3783
|
+ var insutype string
|
|
3784
|
+ var is390 int = 0
|
|
3785
|
+ var is310 int = 0
|
|
3786
|
+ for _, item := range res.Output.Iinfo {
|
|
3787
|
+ if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
|
|
3788
|
+ insutypes = append(insutypes, item.Insutype)
|
|
3789
|
+ }
|
|
3790
|
+ }
|
|
3791
|
+ if len(insutypes) == 1 {
|
|
3792
|
+ insutype = insutypes[0]
|
|
3793
|
+ } else {
|
|
3794
|
+ for _, i := range insutypes {
|
|
3795
|
+ if i == "390" {
|
|
3796
|
+ is390 = 1
|
|
3797
|
+ }
|
|
3798
|
+
|
|
3799
|
+ if i == "310" {
|
|
3800
|
+ is310 = 1
|
|
3801
|
+ }
|
|
3802
|
+ }
|
|
3803
|
+ }
|
|
3804
|
+ if is390 == 1 {
|
|
3805
|
+ insutype = "390"
|
|
3806
|
+ }
|
|
3807
|
+ if is310 == 1 {
|
|
3808
|
+ insutype = "310"
|
|
3809
|
+ }
|
|
3810
|
+ if len(insutypes) == 0 {
|
|
3811
|
+ insutype = "310"
|
|
3812
|
+ }
|
|
3813
|
+
|
|
3814
|
+ patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
|
|
3815
|
+ if err == gorm.ErrRecordNotFound {
|
|
3816
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
|
|
3817
|
+ return
|
|
3818
|
+ } else if err != nil {
|
|
3819
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
3820
|
+ return
|
|
3821
|
+
|
|
3822
|
+ } else {
|
|
3823
|
+
|
|
3824
|
+ if card_type == "1" {
|
|
3825
|
+ bas := strings.Split(card_info, "|")
|
|
3826
|
+ basNumber := bas[2]
|
|
3827
|
+ Iinfos, _ := json.Marshal(res.Output.Iinfo)
|
|
3828
|
+ Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
|
|
3829
|
+ infoStr := string(Iinfos)
|
|
3830
|
+ idetinfoStr := string(Idetinfos)
|
|
3831
|
+ psn := &models.HisPsn{
|
|
3832
|
+ PsnNo: res.Output.Baseinfo.PsnNo,
|
|
3833
|
+ Age: res.Output.Baseinfo.Age,
|
|
3834
|
+ PatientId: patient.ID,
|
|
3835
|
+ Certno: res.Output.Baseinfo.Certno,
|
|
3836
|
+ Brdy: res.Output.Baseinfo.Brdy,
|
|
3837
|
+ Gend: res.Output.Baseinfo.Gend,
|
|
3838
|
+ Naty: res.Output.Baseinfo.Naty,
|
|
3839
|
+ PsnCertType: res.Output.Baseinfo.PsnCertType,
|
|
3840
|
+ PsnName: res.Output.Baseinfo.PsnName,
|
|
3841
|
+ Idetinfo: idetinfoStr,
|
|
3842
|
+ Insuinfo: infoStr,
|
|
3843
|
+ UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
|
|
3844
|
+ CardInfo: card_info,
|
|
3845
|
+ VerifyNumber: busi_card_info,
|
|
3846
|
+ }
|
|
3847
|
+ service.CreateHisPsn(psn)
|
|
3848
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
3849
|
+ "patient": patient,
|
|
3850
|
+ "number": basNumber,
|
|
3851
|
+ "info": res,
|
|
3852
|
+ "insutype": insutype,
|
|
3853
|
+ })
|
|
3854
|
+ } else {
|
|
3855
|
+ Iinfos, _ := json.Marshal(res.Output.Iinfo)
|
|
3856
|
+ Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
|
|
3857
|
+ infoStr := string(Iinfos)
|
|
3858
|
+ idetinfoStr := string(Idetinfos)
|
|
3859
|
+ psn := &models.HisPsn{
|
|
3860
|
+ PsnNo: res.Output.Baseinfo.PsnNo,
|
|
3861
|
+ Age: res.Output.Baseinfo.Age,
|
|
3862
|
+ PatientId: patient.ID,
|
|
3863
|
+ Certno: res.Output.Baseinfo.Certno,
|
|
3864
|
+ Brdy: res.Output.Baseinfo.Brdy,
|
|
3865
|
+ Gend: res.Output.Baseinfo.Gend,
|
|
3866
|
+ Naty: res.Output.Baseinfo.Naty,
|
|
3867
|
+ PsnCertType: res.Output.Baseinfo.PsnCertType,
|
|
3868
|
+ PsnName: res.Output.Baseinfo.PsnName,
|
|
3869
|
+ Idetinfo: idetinfoStr,
|
|
3870
|
+ Insuinfo: infoStr,
|
|
3871
|
+ UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
|
|
3872
|
+ CardInfo: card_info,
|
|
3873
|
+ VerifyNumber: token,
|
|
3874
|
+ }
|
|
3875
|
+ service.CreateHisPsn(psn)
|
|
3876
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
3877
|
+ "patient": patient,
|
|
3878
|
+ "number": token,
|
|
3879
|
+ "info": res,
|
|
3880
|
+ "insutype": insutype,
|
|
3881
|
+ })
|
|
3882
|
+ }
|
|
3883
|
+ }
|
|
3884
|
+ } else {
|
|
3885
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
|
|
3886
|
+ return
|
|
3887
|
+ }
|
|
3888
|
+ } else { //读卡失败
|
|
3889
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
|
3748
|
3890
|
return
|
|
3891
|
+
|
3749
|
3892
|
}
|
3750
|
|
- res.ErrMsg = res10265.ErrMsg
|
3751
|
|
- infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
|
3752
|
|
- res.Infcode = infocode
|
3753
|
|
- res.Output = res10265.Output
|
3754
|
|
- res.InfRefmsgid = res10265.InfRefmsgid
|
3755
|
3893
|
|
3756
|
3894
|
} else {
|
3757
|
|
- //var card_info string //卡信息
|
3758
|
|
- //var busi_card_info string
|
3759
|
3895
|
|
3760
|
|
- token = respJSON["data"].(map[string]interface{})["token"].(string)
|
3761
|
|
- //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
|
|
3896
|
+ if initFlagTwo == 0 {
|
|
3897
|
+ c.TestGetBasBaseInitTwo()
|
|
3898
|
+ }
|
|
3899
|
+ basStr := c.GetBasBaseInfoTwo()
|
|
3900
|
+ if len(basStr) == 0 {
|
|
3901
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
|
|
3902
|
+ return
|
|
3903
|
+ }
|
|
3904
|
+ fmt.Println(basStr)
|
|
3905
|
+ bas := strings.Split(basStr, "|")
|
|
3906
|
+ id_card_no := bas[1]
|
3762
|
3907
|
|
3763
|
|
- //fmt.Println(card_info)
|
3764
|
|
- //fmt.Println(busi_card_info)
|
|
3908
|
+ result, _ := service.ZHGdyb1101B(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "", 1, "")
|
3765
|
3909
|
|
3766
|
|
- respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
|
3767
|
|
- result, _ := json.Marshal(respJSON)
|
|
3910
|
+ //result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
|
|
3911
|
+ var dat map[string]interface{}
|
|
3912
|
+ if err := json.Unmarshal([]byte(result), &dat); err == nil {
|
|
3913
|
+ fmt.Println(dat)
|
|
3914
|
+ } else {
|
|
3915
|
+ fmt.Println(err)
|
|
3916
|
+ }
|
3768
|
3917
|
|
3769
|
|
- if err := json.Unmarshal([]byte(result), &res10265); err != nil {
|
|
3918
|
+ userJSONBytes, _ := json.Marshal(dat)
|
|
3919
|
+ var res ResultTwo
|
|
3920
|
+ if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
3770
|
3921
|
utils.ErrorLog("解析失败:%v", err)
|
3771
|
3922
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
3772
|
3923
|
return
|
3773
|
3924
|
}
|
3774
|
|
- res.ErrMsg = res10265.ErrMsg
|
3775
|
|
- infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
|
3776
|
|
- res.Infcode = infocode
|
3777
|
|
- res.Output = res10265.Output
|
3778
|
|
- res.InfRefmsgid = res10265.InfRefmsgid
|
3779
|
3925
|
|
3780
|
|
- }
|
|
3926
|
+ if res.Infcode == 0 {
|
|
3927
|
+ patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
|
|
3928
|
+ if err == gorm.ErrRecordNotFound {
|
|
3929
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
|
|
3930
|
+ return
|
|
3931
|
+ } else if err != nil {
|
|
3932
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
3933
|
+ return
|
3781
|
3934
|
|
3782
|
|
- if res.Infcode == 0 {
|
3783
|
|
- var insutypes []string
|
3784
|
|
- var insutype string
|
3785
|
|
- var is390 int = 0
|
3786
|
|
- var is310 int = 0
|
3787
|
|
- for _, item := range res.Output.Iinfo {
|
3788
|
|
- if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
|
3789
|
|
- insutypes = append(insutypes, item.Insutype)
|
3790
|
|
- }
|
3791
|
|
- }
|
3792
|
|
- if len(insutypes) == 1 {
|
3793
|
|
- insutype = insutypes[0]
|
3794
|
|
- } else {
|
3795
|
|
- for _, i := range insutypes {
|
3796
|
|
- if i == "390" {
|
3797
|
|
- is390 = 1
|
|
3935
|
+ } else {
|
|
3936
|
+ var insutypes []string
|
|
3937
|
+ var insutype string
|
|
3938
|
+ var is390 int = 0
|
|
3939
|
+ var is310 int = 0
|
|
3940
|
+ for _, item := range res.Output.Iinfo {
|
|
3941
|
+ if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
|
|
3942
|
+ insutypes = append(insutypes, item.Insutype)
|
|
3943
|
+ }
|
3798
|
3944
|
}
|
|
3945
|
+ if len(insutypes) == 1 {
|
|
3946
|
+ insutype = insutypes[0]
|
|
3947
|
+ } else {
|
|
3948
|
+ for _, i := range insutypes {
|
|
3949
|
+ if i == "390" {
|
|
3950
|
+ is390 = 1
|
|
3951
|
+ }
|
3799
|
3952
|
|
3800
|
|
- if i == "310" {
|
3801
|
|
- is310 = 1
|
|
3953
|
+ if i == "310" {
|
|
3954
|
+ is310 = 1
|
|
3955
|
+ }
|
|
3956
|
+ }
|
|
3957
|
+ }
|
|
3958
|
+ if is390 == 1 {
|
|
3959
|
+ insutype = "390"
|
|
3960
|
+ }
|
|
3961
|
+ if is310 == 1 {
|
|
3962
|
+ insutype = "310"
|
|
3963
|
+ }
|
|
3964
|
+ if len(insutypes) == 0 {
|
|
3965
|
+ insutype = "310"
|
3802
|
3966
|
}
|
3803
|
|
- }
|
3804
|
|
- }
|
3805
|
|
- if is390 == 1 {
|
3806
|
|
- insutype = "390"
|
3807
|
|
- }
|
3808
|
|
- if is310 == 1 {
|
3809
|
|
- insutype = "310"
|
3810
|
|
- }
|
3811
|
|
- if len(insutypes) == 0 {
|
3812
|
|
- insutype = "310"
|
3813
|
|
- }
|
3814
|
|
-
|
3815
|
|
- patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
|
3816
|
|
- if err == gorm.ErrRecordNotFound {
|
3817
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
|
3818
|
|
- return
|
3819
|
|
- } else if err != nil {
|
3820
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
3821
|
|
- return
|
3822
|
|
-
|
3823
|
|
- } else {
|
3824
|
3967
|
|
3825
|
|
- if card_type == "1" {
|
3826
|
|
- bas := strings.Split(card_info, "|")
|
3827
|
|
- basNumber := bas[2]
|
3828
|
3968
|
Iinfos, _ := json.Marshal(res.Output.Iinfo)
|
3829
|
3969
|
Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
|
3830
|
3970
|
infoStr := string(Iinfos)
|
|
@@ -3842,17 +3982,85 @@ func (c *ZHHisApiController) ReadCard() {
|
3842
|
3982
|
Idetinfo: idetinfoStr,
|
3843
|
3983
|
Insuinfo: infoStr,
|
3844
|
3984
|
UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
|
3845
|
|
- CardInfo: card_info,
|
3846
|
|
- VerifyNumber: busi_card_info,
|
|
3985
|
+ CardInfo: basStr,
|
|
3986
|
+ VerifyNumber: "",
|
3847
|
3987
|
}
|
3848
|
3988
|
service.CreateHisPsn(psn)
|
3849
|
3989
|
c.ServeSuccessJSON(map[string]interface{}{
|
3850
|
3990
|
"patient": patient,
|
3851
|
|
- "number": basNumber,
|
|
3991
|
+ "number": id_card_no,
|
3852
|
3992
|
"info": res,
|
3853
|
3993
|
"insutype": insutype,
|
3854
|
3994
|
})
|
|
3995
|
+ }
|
|
3996
|
+ } else {
|
|
3997
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
|
|
3998
|
+ return
|
|
3999
|
+ }
|
|
4000
|
+
|
|
4001
|
+ }
|
|
4002
|
+ break
|
|
4003
|
+ case 4: //电子凭证
|
|
4004
|
+ if miConfig.MdtrtareaAdmvs == "150499" {
|
|
4005
|
+
|
|
4006
|
+ } else {
|
|
4007
|
+ if initFlagTwo == 0 {
|
|
4008
|
+ c.TestGetBasBaseInitTwo()
|
|
4009
|
+ }
|
|
4010
|
+ token := c.GetEleBaseInfoTwo()
|
|
4011
|
+ token = Remove0000(token)
|
|
4012
|
+ result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token)
|
|
4013
|
+ saveLog(result2, requestLog2, "1101", "获取人员信息")
|
|
4014
|
+ //
|
|
4015
|
+ var res ResultTwo
|
|
4016
|
+ if err := json.Unmarshal([]byte(result2), &res); err != nil {
|
|
4017
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
4018
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
4019
|
+ return
|
|
4020
|
+ }
|
|
4021
|
+
|
|
4022
|
+ if res.Infcode == 0 {
|
|
4023
|
+ patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
|
|
4024
|
+ if err == gorm.ErrRecordNotFound {
|
|
4025
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
|
|
4026
|
+ return
|
|
4027
|
+ } else if err != nil {
|
|
4028
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
4029
|
+ return
|
|
4030
|
+
|
3855
|
4031
|
} else {
|
|
4032
|
+ var insutypes []string
|
|
4033
|
+ var insutype string
|
|
4034
|
+ var is390 int = 0
|
|
4035
|
+ var is310 int = 0
|
|
4036
|
+ for _, item := range res.Output.Iinfo {
|
|
4037
|
+ if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
|
|
4038
|
+ insutypes = append(insutypes, item.Insutype)
|
|
4039
|
+ }
|
|
4040
|
+ }
|
|
4041
|
+ if len(insutypes) == 1 {
|
|
4042
|
+ insutype = insutypes[0]
|
|
4043
|
+ } else {
|
|
4044
|
+ for _, i := range insutypes {
|
|
4045
|
+ if i == "390" {
|
|
4046
|
+ is390 = 1
|
|
4047
|
+ }
|
|
4048
|
+
|
|
4049
|
+ if i == "310" {
|
|
4050
|
+ is310 = 1
|
|
4051
|
+ }
|
|
4052
|
+ }
|
|
4053
|
+ }
|
|
4054
|
+ if is390 == 1 {
|
|
4055
|
+ insutype = "390"
|
|
4056
|
+ }
|
|
4057
|
+ if is310 == 1 {
|
|
4058
|
+ insutype = "310"
|
|
4059
|
+ }
|
|
4060
|
+ if len(insutypes) == 0 {
|
|
4061
|
+ insutype = "310"
|
|
4062
|
+ }
|
|
4063
|
+
|
3856
|
4064
|
Iinfos, _ := json.Marshal(res.Output.Iinfo)
|
3857
|
4065
|
Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
|
3858
|
4066
|
infoStr := string(Iinfos)
|
|
@@ -3870,7 +4078,7 @@ func (c *ZHHisApiController) ReadCard() {
|
3870
|
4078
|
Idetinfo: idetinfoStr,
|
3871
|
4079
|
Insuinfo: infoStr,
|
3872
|
4080
|
UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
|
3873
|
|
- CardInfo: card_info,
|
|
4081
|
+ CardInfo: "",
|
3874
|
4082
|
VerifyNumber: token,
|
3875
|
4083
|
}
|
3876
|
4084
|
service.CreateHisPsn(psn)
|
|
@@ -3881,16 +4089,75 @@ func (c *ZHHisApiController) ReadCard() {
|
3881
|
4089
|
"insutype": insutype,
|
3882
|
4090
|
})
|
3883
|
4091
|
}
|
|
4092
|
+ } else {
|
|
4093
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
|
|
4094
|
+ return
|
3884
|
4095
|
}
|
3885
|
|
- } else {
|
3886
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
|
3887
|
|
- return
|
|
4096
|
+
|
3888
|
4097
|
}
|
3889
|
|
- } else { //读卡失败
|
3890
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
|
|
4098
|
+ break
|
|
4099
|
+ }
|
|
4100
|
+}
|
|
4101
|
+func (c *ZHHisApiController) GetEleBaseInfoTwo() string {
|
|
4102
|
+ DllDef := syscall.MustLoadDLL("SSCard.dll")
|
|
4103
|
+ readCard := DllDef.MustFindProc("GetQRBase")
|
|
4104
|
+ fmt.Println(readCard)
|
|
4105
|
+
|
|
4106
|
+ if readCard == nil {
|
|
4107
|
+ fmt.Println("readcard is nil")
|
|
4108
|
+ readCard = DllDef.MustFindProc("GetQRBase")
|
|
4109
|
+ }
|
|
4110
|
+ str := make([]byte, 1024)
|
|
4111
|
+ str1 := make([]byte, 1024)
|
|
4112
|
+ ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
|
|
4113
|
+ fmt.Println(ret2)
|
|
4114
|
+ fmt.Println(string(str1))
|
|
4115
|
+ fmt.Println(string(str))
|
|
4116
|
+ fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
|
|
4117
|
+ fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
|
|
4118
|
+ if ret2 != 0 {
|
|
4119
|
+ return ""
|
|
4120
|
+ }
|
|
4121
|
+ return string(str)
|
|
4122
|
+}
|
|
4123
|
+
|
|
4124
|
+func (c *ZHHisApiController) TestGetBasBaseInitTwo() {
|
|
4125
|
+ DllDef := syscall.MustLoadDLL("SSCard.dll")
|
|
4126
|
+ Iinit := DllDef.MustFindProc("Init")
|
|
4127
|
+ miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
|
|
4128
|
+
|
|
4129
|
+ ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.MdtrtareaAdmvs))
|
|
4130
|
+ if ret != 0 {
|
|
4131
|
+ fmt.Println("SSCard的报错原因:", err)
|
|
4132
|
+ fmt.Println("SSCard的运算结果为:", ret)
|
|
4133
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
|
3891
|
4134
|
return
|
|
4135
|
+ }
|
|
4136
|
+
|
|
4137
|
+ result := int(ret)
|
|
4138
|
+ fmt.Println("SSCard的运算结果为1:", result)
|
|
4139
|
+ initFlagTwo = 1
|
|
4140
|
+ return
|
|
4141
|
+}
|
3892
|
4142
|
|
|
4143
|
+func (c *ZHHisApiController) GetBasBaseInfoTwo() string {
|
|
4144
|
+ DllDef := syscall.MustLoadDLL("SSCard.dll")
|
|
4145
|
+ readCard := DllDef.MustFindProc("ReadCardBas")
|
|
4146
|
+ if readCard == nil {
|
|
4147
|
+ fmt.Println("readcard is nil")
|
|
4148
|
+ readCard = DllDef.MustFindProc("ReadCardBas")
|
|
4149
|
+ }
|
|
4150
|
+ str := make([]byte, 1024)
|
|
4151
|
+ str1 := make([]byte, 1024)
|
|
4152
|
+ ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
|
|
4153
|
+ fmt.Println(string(str1))
|
|
4154
|
+ fmt.Println(string(str))
|
|
4155
|
+ fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
|
|
4156
|
+ fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
|
|
4157
|
+ if ret2 != 0 {
|
|
4158
|
+ return ""
|
3893
|
4159
|
}
|
|
4160
|
+ return string(str)
|
3894
|
4161
|
}
|
3895
|
4162
|
|
3896
|
4163
|
var initFlag int64 = 0
|