Browse Source

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

csx 3 years ago
parent
commit
0dadfb9422
4 changed files with 52 additions and 38 deletions
  1. 3 3
      conf/app.conf
  2. 4 2
      controllers/sg/gdyb_controller.go
  3. 20 18
      controllers/sg/his_api_controller.go
  4. 25 15
      service/gdyb_service.go

+ 3 - 3
conf/app.conf View File

@@ -44,7 +44,7 @@ appsecret="61ee2e6268497d5aa9de0b0187c39aea"
44 44
 
45 45
 
46 46
 [prod]
47
-org_id = 9919
47
+org_id = 10026
48 48
 mobile_token_expiration_second = 86400
49 49
 httpdomain = https://api.xt.kuyicloud.com
50 50
 sso_domain = https://sso.kuyicloud.com
@@ -53,8 +53,8 @@ front_end_domain = "https://xt.kuyicloud.com/#"
53 53
 #url  = "http://192.168.1.228:17001/szsi-portal/transData"
54 54
 url = "http://192.168.1.88:6666/szsi-portal/transData"
55 55
 gdyb_url = "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/"
56
-gdyb_paasid = "sg03_prd"
57
-#gdyb_paasid = "jm_sc_yjyy"
56
+#gdyb_paasid = "sg03_prd"
57
+gdyb_paasid = "jm_sc_yjyy"
58 58
 
59 59
 readmysqlhost = shengws1.mysql.rds.aliyuncs.com
60 60
 readmysqlport = 3306

+ 4 - 2
controllers/sg/gdyb_controller.go View File

@@ -76,7 +76,9 @@ func (c *GdybController) PostOne() {
76 76
 	secret_key := c.GetString("secret_key")
77 77
 	id_card_type, _ := c.GetInt64("id_card_type")
78 78
 	card_sn := c.GetString("card_sn")
79
-	result := service.Gdyb1101(certNo, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, id_card_type, card_sn)
79
+	certificates := c.GetString("certificates")
80
+
81
+	result := service.Gdyb1101(certNo, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, id_card_type, card_sn, certificates)
80 82
 	var dat map[string]interface{}
81 83
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
82 84
 
@@ -324,7 +326,7 @@ func (c *GdybController) PostEight() {
324 326
 	preselfpay_amt, _ := c.GetFloat("preselfpay_amt")
325 327
 	inscp_scp_amt, _ := c.GetFloat("inscp_scp_amt")
326 328
 
327
-	result, srcRequest := service.Gdyb2207(psnNo, mdtrtId, chrgBchno, certNo, insutype, total, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, med_type, id_card_type, fulamt_ownpay_amt, overlmt_selfpay, preselfpay_amt, inscp_scp_amt)
329
+	result, srcRequest := service.Gdyb2207(psnNo, mdtrtId, chrgBchno, certNo, insutype, total, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, med_type, id_card_type, fulamt_ownpay_amt, overlmt_selfpay, preselfpay_amt, inscp_scp_amt, 1)
328 330
 	var dat map[string]interface{}
329 331
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
330 332
 		fmt.Println(dat)

+ 20 - 18
controllers/sg/his_api_controller.go View File

@@ -79,7 +79,7 @@ func HisManagerApiRegistRouters() {
79 79
 func (c *HisApiController) TestGetBasBaseInfo() {
80 80
 	DllDef := syscall.MustLoadDLL("SSCard.dll")
81 81
 	defer syscall.FreeLibrary(DllDef)
82
-	Iinit:= DllDef.MustFindProc("Init")
82
+	Iinit := DllDef.MustFindProc("Init")
83 83
 	readCard := DllDef.MustFindProc("ReadCardBas")
84 84
 	ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
85 85
 	if ret != 0 {
@@ -101,13 +101,12 @@ func (c *HisApiController) TestGetBasBaseInfo() {
101 101
 		return
102 102
 	}
103 103
 
104
-
105 104
 	str := make([]byte, 1024)
106 105
 	str1 := make([]byte, 1024)
107
-	cdat:=len(str)
108
-	cdat1:=len(str1)
109
-	p:= *((*int32)(unsafe.Pointer(&str[0])))
110
-	p1:= *((*int32)(unsafe.Pointer(&str1[0])))
106
+	cdat := len(str)
107
+	cdat1 := len(str1)
108
+	p := *((*int32)(unsafe.Pointer(&str[0])))
109
+	p1 := *((*int32)(unsafe.Pointer(&str1[0])))
111 110
 	ret2, _, err2 := readCard.Call(uintptr(p), uintptr(cdat), uintptr(p1), uintptr(cdat1))
112 111
 	fmt.Println(" Add(4,5)的结果为:", ret2)
113 112
 	str11 := prttostr(uintptr(p))
@@ -126,17 +125,16 @@ func (c *HisApiController) TestGetBasBaseInfo() {
126 125
 
127 126
 func prttostr(vcode uintptr) string {
128 127
 	var vbyte []byte
129
-	for i:=0;i<10;i++{
130
-	   sbyte:=*((*byte)(unsafe.Pointer(vcode)))
131
-	   if sbyte==0{
132
-		  break
133
-	   }
134
-	   vbyte=append(vbyte,sbyte)
135
-	   vcode += 1
128
+	for i := 0; i < 10; i++ {
129
+		sbyte := *((*byte)(unsafe.Pointer(vcode)))
130
+		if sbyte == 0 {
131
+			break
132
+		}
133
+		vbyte = append(vbyte, sbyte)
134
+		vcode += 1
136 135
 	}
137 136
 	return string(vbyte)
138
- }
139
-
137
+}
140 138
 
141 139
 //func (c *HisApiController) TestPay() {
142 140
 //	DllDef2 := syscall.MustLoadDLL("SSSE32.dll")
@@ -1010,7 +1008,7 @@ func (c *HisApiController) GetRegisterInfo() {
1010 1008
 	config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
1011 1009
 
1012 1010
 	if config.IsOpen == 1 {
1013
-		api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + patient.IdCardNo + "&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
1011
+		api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + patient.IdCardNo + "&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&certificates=" + strconv.FormatInt(certificates, 10)
1014 1012
 		resp, requestErr := http.Get(api)
1015 1013
 		if requestErr != nil {
1016 1014
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -1086,7 +1084,7 @@ func (c *HisApiController) GetRegisterInfo() {
1086 1084
 			timeFormat := tempTime.Format("20060102150405")
1087 1085
 			chrgBchno := rand.Intn(100000) + 10000
1088 1086
 			ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
1089
-			//count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
1087
+			count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
1090 1088
 			department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
1091 1089
 			doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
1092 1090
 
@@ -1126,6 +1124,10 @@ func (c *HisApiController) GetRegisterInfo() {
1126 1124
 			if is310 == 1 {
1127 1125
 				insutype = "310"
1128 1126
 			}
1127
+			if count == 1 {
1128
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
1129
+				return
1130
+			}
1129 1131
 			api := "http://127.0.0.1:9532/" + "gdyb/two?cert_no=" + IdCardNo + "&insutype=" +
1130 1132
 				insutype + "&psn_no=" + res.Output.Baseinfo.PsnNo +
1131 1133
 				"&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&ipt_otp_no=" + ipt_otp_no +
@@ -1610,7 +1612,7 @@ func (c *HisApiController) GetUploadInfo() {
1610 1612
 
1611 1613
 				}
1612 1614
 
1613
-				result, src_resquest := service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(patientPrescription.RegisterType, 10), his.IdCardType, 0, 0, 0, 0)
1615
+				result, src_resquest := service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(patientPrescription.RegisterType, 10), his.IdCardType, 0, 0, 0, 0, his.IdType)
1614 1616
 				var dat map[string]interface{}
1615 1617
 				if err := json.Unmarshal([]byte(result), &dat); err == nil {
1616 1618
 					fmt.Println(dat)

+ 25 - 15
service/gdyb_service.go View File

@@ -87,7 +87,7 @@ func Gdyb1201(certNo string, org_name string, doctor string, fixmedins_code stri
87 87
 }
88 88
 
89 89
 // 人员基本信息
90
-func Gdyb1101(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, card_sn string) string {
90
+func Gdyb1101(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, card_sn string, certificates string) string {
91 91
 	//生成签名
92 92
 	nonce := GetRandomString(32)
93 93
 	timestamp := time.Now().Unix()
@@ -98,15 +98,22 @@ func Gdyb1101(certNo string, org_name string, doctor string, fixmedins_code stri
98 98
 	inputData := make(map[string]interface{})
99 99
 	inputMessage["infno"] = "1101" // 交易编码
100 100
 
101
-	if id_card_type == 1 {
102
-		inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
103
-		inputData["card_sn"] = card_sn      // 卡识别码
101
+	if certificates == "6" {
102
+		inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
104 103
 		inputData["certno"] = certNo        // 证件号码
104
+
105 105
 	} else {
106
-		inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
107
-		inputData["card_sn"] = ""           // 卡识别码
108
-		inputData["certno"] = certNo        // 证件号码
106
+		if id_card_type == 1 {
107
+			inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
108
+			inputData["card_sn"] = card_sn      // 卡识别码
109
+			inputData["certno"] = certNo        // 证件号码
110
+		} else {
111
+			inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
112
+			inputData["card_sn"] = ""           // 卡识别码
113
+			inputData["certno"] = certNo        // 证件号码
114
+		}
109 115
 	}
116
+
110 117
 	inputData["psn_cert_type"] = "1"    // 人员证件类型
111 118
 	inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
112 119
 	inputData["begntime"] = ""          // 开始时间
@@ -919,7 +926,7 @@ func Gdyb2206(psnNo string, mdtrtId string, chrgBchno string, certNo string, ins
919 926
 }
920 927
 
921 928
 //  门诊结算
922
-func Gdyb2207(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string, total string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, med_type string, id_card_type int64, fulamt_ownpay_amt float64, overlmt_selfpay float64, preselfpay_amt float64, inscp_scp_amt float64) (string, string) {
929
+func Gdyb2207(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string, total string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, med_type string, id_card_type int64, fulamt_ownpay_amt float64, overlmt_selfpay float64, preselfpay_amt float64, inscp_scp_amt float64, certificates int64) (string, string) {
923 930
 	// 生成签名
924 931
 	nonce := GetRandomString(32)
925 932
 	timestamp := time.Now().Unix()
@@ -930,15 +937,18 @@ func Gdyb2207(psnNo string, mdtrtId string, chrgBchno string, certNo string, ins
930 937
 	input := make(map[string]interface{})
931 938
 	inputData := make(map[string]interface{})
932 939
 	inputMessage["infno"] = "2207" // 交易编码
933
-
934
-	inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
935
-
936
-	if id_card_type == 1 {
937
-		inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
940
+	inputData["psn_no"] = psnNo    // 人员编号 (来自1101接口返回)
941
+	if certificates == 6 {
942
+		inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
938 943
 		inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
939 944
 	} else {
940
-		inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
941
-		inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
945
+		if id_card_type == 1 {
946
+			inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
947
+			inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
948
+		} else {
949
+			inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
950
+			inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
951
+		}
942 952
 	}
943 953
 
944 954
 	inputData["med_type"] = med_type    // 医疗类别 11 普通门诊  12 门诊挂号