|
@@ -2893,121 +2893,96 @@ type ELeData struct {
|
2893
|
2893
|
func (c *ZHHisApiController) ReadCard() {
|
2894
|
2894
|
id_card_type, _ := c.GetInt64("id_card_type")
|
2895
|
2895
|
admin_user_id, _ := c.GetInt64("admin_user_id")
|
2896
|
|
- certificates, _ := c.GetInt64("certificates")
|
|
2896
|
+ //certificates, _ := c.GetInt64("certificates")
|
2897
|
2897
|
fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
|
2898
|
2898
|
roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
|
2899
|
2899
|
miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
|
2900
|
2900
|
|
2901
|
|
- switch id_card_type {
|
2902
|
|
- case 1:
|
2903
|
|
- if initFlag == 0 {
|
2904
|
|
- c.TestGetBasBaseInit()
|
2905
|
|
- }
|
2906
|
|
- basStr := c.GetBasBaseInfo(miConfig.Code, miConfig.MdtrtareaAdmvs, roles.UserName, strconv.FormatInt(roles.ID, 10), miConfig.OrgName)
|
2907
|
|
- if len(basStr) == 0 {
|
2908
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
|
2909
|
|
- return
|
2910
|
|
- }
|
2911
|
|
- fmt.Println(basStr)
|
2912
|
|
- bas := strings.Split(basStr, "|")
|
2913
|
|
- basNumber := bas[1]
|
2914
|
|
- fmt.Println(basNumber)
|
2915
|
|
- card_sn := bas[3]
|
2916
|
|
- fmt.Println(card_sn)
|
2917
|
|
- result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
|
2918
|
|
- var dat map[string]interface{}
|
2919
|
|
- if err := json.Unmarshal([]byte(result), &dat); err == nil {
|
2920
|
|
- fmt.Println(dat)
|
2921
|
|
- } else {
|
2922
|
|
- fmt.Println(err)
|
2923
|
|
- }
|
|
2901
|
+ var api string
|
|
2902
|
+ api = "http://172.16.13.254:9532/" + "nmyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
|
|
2903
|
+ "&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
|
|
2904
|
+ fmt.Println(api)
|
2924
|
2905
|
|
2925
|
|
- userJSONBytes, _ := json.Marshal(dat)
|
2926
|
|
- var res ResultTwo
|
2927
|
|
- if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
2928
|
|
- utils.ErrorLog("解析失败:%v", err)
|
2929
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
2930
|
|
- return
|
2931
|
|
- }
|
|
2906
|
+ resp, requestErr := http.Get(api)
|
|
2907
|
+ if requestErr != nil {
|
|
2908
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
2909
|
+ return
|
|
2910
|
+ }
|
2932
|
2911
|
|
2933
|
|
- if res.Infcode == 0 {
|
|
2912
|
+ body, ioErr := ioutil.ReadAll(resp.Body)
|
|
2913
|
+ if ioErr != nil {
|
|
2914
|
+ utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
|
|
2915
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
2916
|
+ return
|
|
2917
|
+ }
|
|
2918
|
+ var respJSON map[string]interface{}
|
|
2919
|
+ if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
|
|
2920
|
+ utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
|
2921
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
2922
|
+ return
|
|
2923
|
+ }
|
|
2924
|
+ var status string
|
|
2925
|
+ status = respJSON["data"].(map[string]interface{})["status"].(string)
|
|
2926
|
+ card_type := respJSON["data"].(map[string]interface{})["type"].(string)
|
|
2927
|
+ //console.log()
|
|
2928
|
+ fmt.Println("type===")
|
2934
|
2929
|
|
2935
|
|
- var insutypes []string
|
2936
|
|
- var insutype string
|
2937
|
|
- var is390 int = 0
|
2938
|
|
- var is310 int = 0
|
2939
|
|
- for _, item := range res.Output.Iinfo {
|
2940
|
|
- if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
|
2941
|
|
- insutypes = append(insutypes, item.Insutype)
|
2942
|
|
- }
|
2943
|
|
- }
|
2944
|
|
- if len(insutypes) == 1 {
|
2945
|
|
- insutype = insutypes[0]
|
2946
|
|
- } else {
|
2947
|
|
- for _, i := range insutypes {
|
2948
|
|
- if i == "390" {
|
2949
|
|
- is390 = 1
|
2950
|
|
- }
|
|
2930
|
+ fmt.Println(card_type)
|
2951
|
2931
|
|
2952
|
|
- if i == "310" {
|
2953
|
|
- is310 = 1
|
2954
|
|
- }
|
2955
|
|
- }
|
2956
|
|
- }
|
2957
|
|
- if is390 == 1 {
|
2958
|
|
- insutype = "390"
|
2959
|
|
- }
|
2960
|
|
- if is310 == 1 {
|
2961
|
|
- insutype = "310"
|
2962
|
|
- }
|
2963
|
|
- if len(insutypes) == 0 {
|
2964
|
|
- insutype = "310"
|
2965
|
|
- }
|
|
2932
|
+ var token string
|
|
2933
|
+ var res ResultTwo //1101结果
|
|
2934
|
+ var res10265 ResultTwo10265 //1101结果
|
|
2935
|
+ var card_info string //卡信息
|
|
2936
|
+ var busi_card_info string
|
2966
|
2937
|
|
2967
|
|
- patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
|
2968
|
|
- if err == gorm.ErrRecordNotFound {
|
2969
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
|
2970
|
|
- return
|
2971
|
|
- } else if err != nil {
|
2972
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
2973
|
|
- return
|
|
2938
|
+ card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
|
|
2939
|
+ busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
|
2974
|
2940
|
|
2975
|
|
- } else {
|
2976
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
2977
|
|
- "patient": patient,
|
2978
|
|
- "number": basNumber,
|
2979
|
|
- "info": res,
|
2980
|
|
- "insutype": insutype,
|
2981
|
|
- })
|
|
2941
|
+ if status == "0" { //读卡成功
|
|
2942
|
+ if card_type == "1" {
|
|
2943
|
+
|
|
2944
|
+ respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
|
|
2945
|
+ result, _ := json.Marshal(respJSON)
|
|
2946
|
+
|
|
2947
|
+ if err := json.Unmarshal([]byte(result), &res10265); err != nil {
|
|
2948
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
2949
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
2950
|
+ return
|
2982
|
2951
|
}
|
|
2952
|
+ res.ErrMsg = res10265.ErrMsg
|
|
2953
|
+ infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
|
|
2954
|
+ res.Infcode = infocode
|
|
2955
|
+ res.Output = res10265.Output
|
|
2956
|
+ res.InfRefmsgid = res10265.InfRefmsgid
|
|
2957
|
+
|
2983
|
2958
|
} else {
|
2984
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
|
2985
|
|
- return
|
2986
|
|
- }
|
2987
|
|
- break
|
2988
|
|
- case 2:
|
2989
|
|
- SFZStr := c.GetSFZBaseInfo()
|
2990
|
|
- id_card_str := strings.Split(SFZStr, "^")
|
2991
|
|
- id_card_number := id_card_str[0]
|
2992
|
|
- card_sn := ""
|
2993
|
|
- result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
|
2994
|
|
- var dat map[string]interface{}
|
2995
|
|
- if err := json.Unmarshal([]byte(result), &dat); err == nil {
|
2996
|
|
- fmt.Println(dat)
|
2997
|
|
- } else {
|
2998
|
|
- fmt.Println(err)
|
2999
|
|
- }
|
|
2959
|
+ //var card_info string //卡信息
|
|
2960
|
+ //var busi_card_info string
|
|
2961
|
+
|
|
2962
|
+ token = respJSON["data"].(map[string]interface{})["token"].(string)
|
|
2963
|
+ //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
|
|
2964
|
+
|
|
2965
|
+ //fmt.Println(card_info)
|
|
2966
|
+ //fmt.Println(busi_card_info)
|
|
2967
|
+
|
|
2968
|
+ respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
|
|
2969
|
+ result, _ := json.Marshal(respJSON)
|
|
2970
|
+
|
|
2971
|
+ if err := json.Unmarshal([]byte(result), &res10265); err != nil {
|
|
2972
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
2973
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
2974
|
+ return
|
|
2975
|
+ }
|
|
2976
|
+ res.ErrMsg = res10265.ErrMsg
|
|
2977
|
+ infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
|
|
2978
|
+ res.Infcode = infocode
|
|
2979
|
+ res.Output = res10265.Output
|
|
2980
|
+ res.InfRefmsgid = res10265.InfRefmsgid
|
3000
|
2981
|
|
3001
|
|
- userJSONBytes, _ := json.Marshal(dat)
|
3002
|
|
- var res ResultTwo
|
3003
|
|
- if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
3004
|
|
- utils.ErrorLog("解析失败:%v", err)
|
3005
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
3006
|
|
- return
|
3007
|
2982
|
}
|
3008
|
2983
|
|
3009
|
2984
|
if res.Infcode == 0 {
|
3010
|
|
- patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
|
|
2985
|
+ patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
|
3011
|
2986
|
if err == gorm.ErrRecordNotFound {
|
3012
|
2987
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
|
3013
|
2988
|
return
|
|
@@ -3016,71 +2991,72 @@ func (c *ZHHisApiController) ReadCard() {
|
3016
|
2991
|
return
|
3017
|
2992
|
|
3018
|
2993
|
} else {
|
3019
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
3020
|
|
- "patient": patient,
|
3021
|
|
- "number": id_card_number,
|
3022
|
|
- "info": res,
|
3023
|
|
- })
|
3024
|
|
- }
|
3025
|
|
- } else {
|
3026
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
|
3027
|
|
- return
|
3028
|
|
- }
|
3029
|
|
-
|
3030
|
|
- break
|
3031
|
|
- case 4:
|
3032
|
|
- _, pBusiCardInfo := c.GetELeInfo(miConfig.Code, strconv.FormatInt(roles.ID, 10), roles.UserName)
|
3033
|
|
-
|
3034
|
|
- var ele ELeData
|
3035
|
|
- err := json.Unmarshal([]byte(pBusiCardInfo), &ele)
|
3036
|
|
- if err != nil {
|
3037
|
|
- utils.ErrorLog("解析失败:%v", err)
|
3038
|
|
- }
|
3039
|
|
- token := ele.Data.EcToken
|
3040
|
|
- fmt.Println(token)
|
3041
|
|
- if len(token) > 0 {
|
3042
|
|
- result := service.Gdyb1101ForEleCert("", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "")
|
3043
|
|
- var dat map[string]interface{}
|
3044
|
|
- if err := json.Unmarshal([]byte(result), &dat); err == nil {
|
3045
|
|
- fmt.Println(dat)
|
3046
|
|
- } else {
|
3047
|
|
- fmt.Println(err)
|
3048
|
|
- }
|
3049
|
|
- userJSONBytes, _ := json.Marshal(dat)
|
3050
|
|
- var res ResultTwo
|
3051
|
|
- if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
3052
|
|
- utils.ErrorLog("解析失败:%v", err)
|
3053
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
3054
|
|
- return
|
3055
|
|
- }
|
3056
|
|
-
|
3057
|
|
- if res.Infcode == 0 {
|
3058
|
|
- patient, err := service.GetPatientByNumber(ele.Data.IdNo, c.GetAdminUserInfo().CurrentOrgId)
|
3059
|
|
- if err == gorm.ErrRecordNotFound {
|
3060
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
|
3061
|
|
- return
|
3062
|
|
- } else if err != nil {
|
3063
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
3064
|
|
- return
|
3065
|
2994
|
|
|
2995
|
+ if card_type == "1" {
|
|
2996
|
+ bas := strings.Split(card_info, "|")
|
|
2997
|
+ basNumber := bas[2]
|
|
2998
|
+ Iinfos, _ := json.Marshal(res.Output.Iinfo)
|
|
2999
|
+ Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
|
|
3000
|
+ infoStr := string(Iinfos)
|
|
3001
|
+ idetinfoStr := string(Idetinfos)
|
|
3002
|
+ psn := &models.HisPsn{
|
|
3003
|
+ PsnNo: res.Output.Baseinfo.PsnNo,
|
|
3004
|
+ Age: res.Output.Baseinfo.Age,
|
|
3005
|
+ PatientId: patient.ID,
|
|
3006
|
+ Certno: res.Output.Baseinfo.Certno,
|
|
3007
|
+ Brdy: res.Output.Baseinfo.Brdy,
|
|
3008
|
+ Gend: res.Output.Baseinfo.Gend,
|
|
3009
|
+ Naty: res.Output.Baseinfo.Naty,
|
|
3010
|
+ PsnCertType: res.Output.Baseinfo.PsnCertType,
|
|
3011
|
+ PsnName: res.Output.Baseinfo.PsnName,
|
|
3012
|
+ Idetinfo: idetinfoStr,
|
|
3013
|
+ Insuinfo: infoStr,
|
|
3014
|
+ UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
|
|
3015
|
+ CardInfo: card_info,
|
|
3016
|
+ VerifyNumber: busi_card_info,
|
|
3017
|
+ }
|
|
3018
|
+ service.CreateHisPsn(psn)
|
|
3019
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
3020
|
+ "patient": patient,
|
|
3021
|
+ "number": basNumber,
|
|
3022
|
+ })
|
3066
|
3023
|
} else {
|
|
3024
|
+ Iinfos, _ := json.Marshal(res.Output.Iinfo)
|
|
3025
|
+ Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
|
|
3026
|
+ infoStr := string(Iinfos)
|
|
3027
|
+ idetinfoStr := string(Idetinfos)
|
|
3028
|
+ psn := &models.HisPsn{
|
|
3029
|
+ PsnNo: res.Output.Baseinfo.PsnNo,
|
|
3030
|
+ Age: res.Output.Baseinfo.Age,
|
|
3031
|
+ PatientId: patient.ID,
|
|
3032
|
+ Certno: res.Output.Baseinfo.Certno,
|
|
3033
|
+ Brdy: res.Output.Baseinfo.Brdy,
|
|
3034
|
+ Gend: res.Output.Baseinfo.Gend,
|
|
3035
|
+ Naty: res.Output.Baseinfo.Naty,
|
|
3036
|
+ PsnCertType: res.Output.Baseinfo.PsnCertType,
|
|
3037
|
+ PsnName: res.Output.Baseinfo.PsnName,
|
|
3038
|
+ Idetinfo: idetinfoStr,
|
|
3039
|
+ Insuinfo: infoStr,
|
|
3040
|
+ UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
|
|
3041
|
+ CardInfo: card_info,
|
|
3042
|
+ VerifyNumber: token,
|
|
3043
|
+ }
|
|
3044
|
+ service.CreateHisPsn(psn)
|
3067
|
3045
|
c.ServeSuccessJSON(map[string]interface{}{
|
3068
|
3046
|
"patient": patient,
|
3069
|
3047
|
"number": token,
|
3070
|
|
- "info": res,
|
3071
|
3048
|
})
|
3072
|
3049
|
}
|
3073
|
|
- } else {
|
3074
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
|
3075
|
|
- return
|
3076
|
3050
|
}
|
3077
|
3051
|
} else {
|
3078
|
3052
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
|
3079
|
3053
|
return
|
3080
|
3054
|
}
|
3081
|
|
- break
|
3082
|
|
- }
|
|
3055
|
+ } else { //读卡失败
|
|
3056
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
|
|
3057
|
+ return
|
3083
|
3058
|
|
|
3059
|
+ }
|
3084
|
3060
|
}
|
3085
|
3061
|
|
3086
|
3062
|
var initFlag int64 = 0
|