|
@@ -836,6 +836,202 @@ func (c *HisApiController) ReadCard() {
|
836
|
836
|
}
|
837
|
837
|
|
838
|
838
|
break
|
|
839
|
+ case 4:
|
|
840
|
+ if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
|
|
841
|
+ var api string
|
|
842
|
+ if miConfig.MdtrtareaAdmvs == "320921" {
|
|
843
|
+ 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 +
|
|
844
|
+ "&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
|
|
845
|
+ fmt.Println(api)
|
|
846
|
+
|
|
847
|
+ } else {
|
|
848
|
+ 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 +
|
|
849
|
+ "&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)
|
|
850
|
+ }
|
|
851
|
+
|
|
852
|
+ resp, requestErr := http.Get(api)
|
|
853
|
+ if requestErr != nil {
|
|
854
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
855
|
+ return
|
|
856
|
+ }
|
|
857
|
+
|
|
858
|
+ body, ioErr := ioutil.ReadAll(resp.Body)
|
|
859
|
+ if ioErr != nil {
|
|
860
|
+ utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
|
|
861
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
862
|
+ return
|
|
863
|
+ }
|
|
864
|
+ var respJSON map[string]interface{}
|
|
865
|
+ if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
|
|
866
|
+ utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
|
867
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
868
|
+ return
|
|
869
|
+ }
|
|
870
|
+ var status string
|
|
871
|
+ status = respJSON["data"].(map[string]interface{})["status"].(string)
|
|
872
|
+ card_type := respJSON["data"].(map[string]interface{})["type"].(string)
|
|
873
|
+
|
|
874
|
+ var token string
|
|
875
|
+ var res ResultTwo //1101结果
|
|
876
|
+ var res10265 ResultTwo10265 //1101结果
|
|
877
|
+ var card_info string //卡信息
|
|
878
|
+ var busi_card_info string
|
|
879
|
+
|
|
880
|
+ card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
|
|
881
|
+ busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
|
|
882
|
+
|
|
883
|
+ if status == "0" { //读卡成功
|
|
884
|
+ if card_type == "1" {
|
|
885
|
+
|
|
886
|
+ respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
|
|
887
|
+ result, _ := json.Marshal(respJSON)
|
|
888
|
+
|
|
889
|
+ if err := json.Unmarshal([]byte(result), &res10265); err != nil {
|
|
890
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
891
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
892
|
+ return
|
|
893
|
+ }
|
|
894
|
+ res.ErrMsg = res10265.ErrMsg
|
|
895
|
+ infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
|
|
896
|
+ res.Infcode = infocode
|
|
897
|
+ res.Output = res10265.Output
|
|
898
|
+ res.InfRefmsgid = res10265.InfRefmsgid
|
|
899
|
+
|
|
900
|
+ } else {
|
|
901
|
+ var card_info string //卡信息
|
|
902
|
+ var busi_card_info string
|
|
903
|
+
|
|
904
|
+ token = respJSON["data"].(map[string]interface{})["token"].(string)
|
|
905
|
+ busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
|
|
906
|
+ card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
|
|
907
|
+
|
|
908
|
+ fmt.Println(card_info)
|
|
909
|
+ fmt.Println(busi_card_info)
|
|
910
|
+
|
|
911
|
+ respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
|
|
912
|
+ result, _ := json.Marshal(respJSON)
|
|
913
|
+
|
|
914
|
+ if err := json.Unmarshal([]byte(result), &res10265); err != nil {
|
|
915
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
916
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
917
|
+ return
|
|
918
|
+ }
|
|
919
|
+ res.ErrMsg = res10265.ErrMsg
|
|
920
|
+ infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
|
|
921
|
+ res.Infcode = infocode
|
|
922
|
+ res.Output = res10265.Output
|
|
923
|
+ res.InfRefmsgid = res10265.InfRefmsgid
|
|
924
|
+
|
|
925
|
+ }
|
|
926
|
+
|
|
927
|
+ if res.Infcode == 0 {
|
|
928
|
+ patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
|
|
929
|
+ if err == gorm.ErrRecordNotFound {
|
|
930
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
|
|
931
|
+ return
|
|
932
|
+ } else if err != nil {
|
|
933
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
934
|
+ return
|
|
935
|
+
|
|
936
|
+ } else {
|
|
937
|
+
|
|
938
|
+ if card_type == "1" {
|
|
939
|
+ bas := strings.Split(card_info, "|")
|
|
940
|
+ basNumber := bas[2]
|
|
941
|
+ Iinfos, _ := json.Marshal(res.Output.Iinfo)
|
|
942
|
+ Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
|
|
943
|
+ infoStr := string(Iinfos)
|
|
944
|
+ idetinfoStr := string(Idetinfos)
|
|
945
|
+ psn := &models.HisPsn{
|
|
946
|
+ PsnNo: res.Output.Baseinfo.PsnNo,
|
|
947
|
+ Age: res.Output.Baseinfo.Age,
|
|
948
|
+ PatientId: patient.ID,
|
|
949
|
+ Certno: res.Output.Baseinfo.Certno,
|
|
950
|
+ Brdy: res.Output.Baseinfo.Brdy,
|
|
951
|
+ Gend: res.Output.Baseinfo.Gend,
|
|
952
|
+ Naty: res.Output.Baseinfo.Naty,
|
|
953
|
+ PsnCertType: res.Output.Baseinfo.PsnCertType,
|
|
954
|
+ PsnName: res.Output.Baseinfo.PsnName,
|
|
955
|
+ Idetinfo: idetinfoStr,
|
|
956
|
+ Insuinfo: infoStr,
|
|
957
|
+ UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
|
|
958
|
+ CardInfo: card_info,
|
|
959
|
+ VerifyNumber: busi_card_info,
|
|
960
|
+ }
|
|
961
|
+ service.CreateHisPsn(psn)
|
|
962
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
963
|
+ "patient": patient,
|
|
964
|
+ "number": basNumber,
|
|
965
|
+ })
|
|
966
|
+ } else if card_type == "4" {
|
|
967
|
+ Iinfos, _ := json.Marshal(res.Output.Iinfo)
|
|
968
|
+ Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
|
|
969
|
+ infoStr := string(Iinfos)
|
|
970
|
+ idetinfoStr := string(Idetinfos)
|
|
971
|
+ psn := &models.HisPsn{
|
|
972
|
+ PsnNo: res.Output.Baseinfo.PsnNo,
|
|
973
|
+ Age: res.Output.Baseinfo.Age,
|
|
974
|
+ PatientId: patient.ID,
|
|
975
|
+ Certno: res.Output.Baseinfo.Certno,
|
|
976
|
+ Brdy: res.Output.Baseinfo.Brdy,
|
|
977
|
+ Gend: res.Output.Baseinfo.Gend,
|
|
978
|
+ Naty: res.Output.Baseinfo.Naty,
|
|
979
|
+ PsnCertType: res.Output.Baseinfo.PsnCertType,
|
|
980
|
+ PsnName: res.Output.Baseinfo.PsnName,
|
|
981
|
+ Idetinfo: idetinfoStr,
|
|
982
|
+ Insuinfo: infoStr,
|
|
983
|
+ UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
|
|
984
|
+ CardInfo: card_info,
|
|
985
|
+ VerifyNumber: token,
|
|
986
|
+ }
|
|
987
|
+ service.CreateHisPsn(psn)
|
|
988
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
989
|
+ "patient": patient,
|
|
990
|
+ "number": token,
|
|
991
|
+ })
|
|
992
|
+
|
|
993
|
+ } else {
|
|
994
|
+ Iinfos, _ := json.Marshal(res.Output.Iinfo)
|
|
995
|
+ Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
|
|
996
|
+ infoStr := string(Iinfos)
|
|
997
|
+ idetinfoStr := string(Idetinfos)
|
|
998
|
+ psn := &models.HisPsn{
|
|
999
|
+ PsnNo: res.Output.Baseinfo.PsnNo,
|
|
1000
|
+ Age: res.Output.Baseinfo.Age,
|
|
1001
|
+ PatientId: patient.ID,
|
|
1002
|
+ Certno: res.Output.Baseinfo.Certno,
|
|
1003
|
+ Brdy: res.Output.Baseinfo.Brdy,
|
|
1004
|
+ Gend: res.Output.Baseinfo.Gend,
|
|
1005
|
+ Naty: res.Output.Baseinfo.Naty,
|
|
1006
|
+ PsnCertType: res.Output.Baseinfo.PsnCertType,
|
|
1007
|
+ PsnName: res.Output.Baseinfo.PsnName,
|
|
1008
|
+ Idetinfo: idetinfoStr,
|
|
1009
|
+ Insuinfo: infoStr,
|
|
1010
|
+ UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
|
|
1011
|
+ CardInfo: card_info,
|
|
1012
|
+ VerifyNumber: token,
|
|
1013
|
+ }
|
|
1014
|
+ service.CreateHisPsn(psn)
|
|
1015
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1016
|
+ "patient": patient,
|
|
1017
|
+ "number": token,
|
|
1018
|
+ })
|
|
1019
|
+ }
|
|
1020
|
+ }
|
|
1021
|
+ } else {
|
|
1022
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
|
|
1023
|
+ return
|
|
1024
|
+ }
|
|
1025
|
+ } else { //读卡失败
|
|
1026
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
|
|
1027
|
+ return
|
|
1028
|
+
|
|
1029
|
+ }
|
|
1030
|
+
|
|
1031
|
+ }
|
|
1032
|
+
|
|
1033
|
+ break
|
|
1034
|
+
|
839
|
1035
|
}
|
840
|
1036
|
|
841
|
1037
|
}
|