Sfoglia il codice sorgente

Merge branch 'master' of http://git.shengws.com/csx/gdyb

csx 2 anni fa
parent
commit
6c8b52275c

+ 1 - 1
conf/app.conf Vedi File

@@ -45,7 +45,7 @@ appsecret="61ee2e6268497d5aa9de0b0187c39aea"
45 45
 
46 46
 
47 47
 [prod]
48
-org_id = 10188
48
+org_id = 10217
49 49
 mobile_token_expiration_second = 86400
50 50
 httpdomain = https://api.xt.kuyicloud.com
51 51
 sso_domain = https://sso.kuyicloud.com

+ 90 - 1
controllers/js/jsyb_controller.go Vedi File

@@ -663,6 +663,24 @@ type ELeData struct {
663 663
 	Message string `json:"message"`
664 664
 }
665 665
 
666
+type ELeCertData struct {
667
+	Data struct {
668
+		Extra       string `json:"extra"`
669
+		IDNo        string `json:"idNo"`
670
+		IDType      string `json:"idType"`
671
+		EcToken     string `json:"ecToken"`
672
+		InsuOrg     string `json:"insuOrg"`
673
+		UserName    string `json:"userName"`
674
+		EcIndexNo   string `json:"ecIndexNo"`
675
+		Gender      string `json:"gender"`
676
+		Birthday    string `json:"birthday"`
677
+		Nationality string `json:"nationality"`
678
+		Email       string `json:"email"`
679
+	} `json:"data"`
680
+	Code    int    `json:"code"`
681
+	Message string `json:"message"`
682
+}
683
+
666 684
 func (c *JSybController) ReadCard() {
667 685
 	fixmedins_code := c.GetString("fixmedins_code")
668 686
 	secret_key := c.GetString("secret_key")
@@ -721,7 +739,7 @@ func (c *JSybController) ReadCard() {
721 739
 
722 740
 		}
723 741
 		break
724
-	case "3": //电子凭证
742
+	case "3": //电子社保卡
725 743
 		_, pBusiCardInfo := c.GetELeInfo(fixmedins_code, operator_id, operator)
726 744
 		//fmt.Println(pCardInfo)
727 745
 		fmt.Println(pBusiCardInfo)
@@ -756,6 +774,41 @@ func (c *JSybController) ReadCard() {
756 774
 
757 775
 		}
758 776
 		break
777
+	case "4": //电子凭证
778
+		pCardInfo, pBusiCardInfo := c.GetELeCertInfo(fixmedins_code, operator_id, operator)
779
+		fmt.Println(pCardInfo)
780
+		fmt.Println(pBusiCardInfo)
781
+		pBusiCardInfo = Remove0000(pBusiCardInfo)
782
+		pCardInfo = Remove0000(pCardInfo)
783
+		var ele ELeCertData
784
+		err := json.Unmarshal([]byte(pBusiCardInfo), &ele)
785
+		if err != nil {
786
+			utils.ErrorLog("解析失败:%v", err)
787
+		}
788
+		token := ele.Data.EcToken
789
+		if len(token) > 0 {
790
+			result, _ := service.Jsyb1101ForEleCert(org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, url, ak, token, cainfo)
791
+			var dat map[string]interface{}
792
+			if err := json.Unmarshal([]byte(result), &dat); err == nil {
793
+				fmt.Println(dat)
794
+			} else {
795
+				fmt.Println(err)
796
+			}
797
+			c.ServeSuccessJSON(map[string]interface{}{
798
+				"status":         "0",
799
+				"card_info":      pCardInfo,
800
+				"busi_card_info": pBusiCardInfo,
801
+				"token":          token,
802
+				"result":         dat,
803
+				"type":           "4",
804
+			})
805
+		} else {
806
+			c.ServeSuccessJSON(map[string]interface{}{
807
+				"status": "-1",
808
+			})
809
+
810
+		}
811
+		break
759 812
 
760 813
 	}
761 814
 
@@ -855,6 +908,42 @@ func (c *JSybController) GetELeInfo(code string, operator_id string, operator_na
855 908
 	return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
856 909
 }
857 910
 
911
+func (c *JSybController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
912
+	DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
913
+	readCard := DllDef.MustFindProc("EcQuery")
914
+	fmt.Println(readCard)
915
+	fmt.Println("!!!!!")
916
+	pCardInfo := make([]byte, 8192)
917
+	pBusiCardInfo := make([]byte, 8192)
918
+
919
+	data := make(map[string]interface{})
920
+	//pData := make(map[string]interface{})
921
+
922
+	inputData := make(map[string]interface{})
923
+	inputData["orgId"] = code
924
+	inputData["businessType"] = "01101"
925
+	inputData["operatorId"] = operator_id
926
+	inputData["operatorName"] = operator_name
927
+	inputData["officeId"] = "001"
928
+	inputData["officeName"] = "血透室"
929
+	//
930
+	data["data"] = inputData
931
+	data["transType"] = "ec.query"
932
+	data["orgId"] = code
933
+	bytesData, _ := json.Marshal(data)
934
+	pCardInfo = bytesData
935
+	ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
936
+	fmt.Println(ret2)
937
+	//fmt.Println(DeleteExtraSpace(string(bytesData)))
938
+	//fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
939
+	fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
940
+	fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
941
+	if ret2 != 0 {
942
+		return "", ""
943
+	}
944
+	return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
945
+}
946
+
858 947
 func IntPtr(n int) uintptr {
859 948
 	return uintptr(n)
860 949
 }

+ 196 - 0
controllers/sg/his_api_controller.go Vedi File

@@ -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
 }

+ 32 - 0
service/jsyb_service.go Vedi File

@@ -229,6 +229,38 @@ func Jsyb1101B(org_name string, doctor string, fixmedins_code string, insuplc_ad
229 229
 	return HttpRequest(request_url, access_key, secret_key, timestamp, string(bytesData)), inputLog
230 230
 }
231 231
 
232
+func Jsyb1101ForEleCert(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, request_url string, access_key string, Token string, cainfo string) (string, string) {
233
+	timestamp := time.Now().Unix()
234
+	//生成输入报文
235
+	inputMessage := SetJSInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
236
+
237
+	input := make(map[string]interface{})
238
+	inputData := make(map[string]interface{})
239
+	inputMessage["infno"] = "1101" // 交易编码
240
+
241
+	inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
242
+	inputData["card_sn"] = ""           // 卡识别码
243
+	inputData["certno"] = ""            // 证件号码
244
+	inputData["psn_cert_type"] = "01"   // 人员证件类型
245
+
246
+	inputData["mdtrt_cert_no"] = id_card_no + "|" + Token // 就诊凭证编号
247
+	inputData["begntime"] = ""                            // 开始时间
248
+	inputData["psn_name"] = ""                            // 人员姓名
249
+	input["data"] = inputData
250
+	inputMessage["input"] = input //交易输入
251
+
252
+	var inputLog string
253
+	bytesData, _ := json.Marshal(inputMessage)
254
+	inputLog = string(bytesData)
255
+	fmt.Println(string(bytesData))
256
+	if err != nil {
257
+		fmt.Println(err.Error())
258
+		return err.Error(), ""
259
+	}
260
+	request_url = request_url + "1101"
261
+	return HttpRequest(request_url, access_key, secret_key, timestamp, string(bytesData)), inputLog
262
+}
263
+
232 264
 // 门诊挂号
233 265
 func Jsyb2201(psnNo string, insutype string, certNo string, org_name string, opera string, ipt_otp_no string, dept string, fixmedins_code string, dept_code string, doctor_id string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, doctor_name string, request_url string, access_key string, verify_number string, cainfo string) (string, string) {
234 266
 	fmt.Println(opera)