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
 
44
 
45
 
45
 
46
 [prod]
46
 [prod]
47
-org_id = 9919
47
+org_id = 10026
48
 mobile_token_expiration_second = 86400
48
 mobile_token_expiration_second = 86400
49
 httpdomain = https://api.xt.kuyicloud.com
49
 httpdomain = https://api.xt.kuyicloud.com
50
 sso_domain = https://sso.kuyicloud.com
50
 sso_domain = https://sso.kuyicloud.com
53
 #url  = "http://192.168.1.228:17001/szsi-portal/transData"
53
 #url  = "http://192.168.1.228:17001/szsi-portal/transData"
54
 url = "http://192.168.1.88:6666/szsi-portal/transData"
54
 url = "http://192.168.1.88:6666/szsi-portal/transData"
55
 gdyb_url = "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/"
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
 readmysqlhost = shengws1.mysql.rds.aliyuncs.com
59
 readmysqlhost = shengws1.mysql.rds.aliyuncs.com
60
 readmysqlport = 3306
60
 readmysqlport = 3306

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

76
 	secret_key := c.GetString("secret_key")
76
 	secret_key := c.GetString("secret_key")
77
 	id_card_type, _ := c.GetInt64("id_card_type")
77
 	id_card_type, _ := c.GetInt64("id_card_type")
78
 	card_sn := c.GetString("card_sn")
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
 	var dat map[string]interface{}
82
 	var dat map[string]interface{}
81
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
83
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
82
 
84
 
324
 	preselfpay_amt, _ := c.GetFloat("preselfpay_amt")
326
 	preselfpay_amt, _ := c.GetFloat("preselfpay_amt")
325
 	inscp_scp_amt, _ := c.GetFloat("inscp_scp_amt")
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
 	var dat map[string]interface{}
330
 	var dat map[string]interface{}
329
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
331
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
330
 		fmt.Println(dat)
332
 		fmt.Println(dat)

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

79
 func (c *HisApiController) TestGetBasBaseInfo() {
79
 func (c *HisApiController) TestGetBasBaseInfo() {
80
 	DllDef := syscall.MustLoadDLL("SSCard.dll")
80
 	DllDef := syscall.MustLoadDLL("SSCard.dll")
81
 	defer syscall.FreeLibrary(DllDef)
81
 	defer syscall.FreeLibrary(DllDef)
82
-	Iinit:= DllDef.MustFindProc("Init")
82
+	Iinit := DllDef.MustFindProc("Init")
83
 	readCard := DllDef.MustFindProc("ReadCardBas")
83
 	readCard := DllDef.MustFindProc("ReadCardBas")
84
 	ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
84
 	ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
85
 	if ret != 0 {
85
 	if ret != 0 {
101
 		return
101
 		return
102
 	}
102
 	}
103
 
103
 
104
-
105
 	str := make([]byte, 1024)
104
 	str := make([]byte, 1024)
106
 	str1 := make([]byte, 1024)
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
 	ret2, _, err2 := readCard.Call(uintptr(p), uintptr(cdat), uintptr(p1), uintptr(cdat1))
110
 	ret2, _, err2 := readCard.Call(uintptr(p), uintptr(cdat), uintptr(p1), uintptr(cdat1))
112
 	fmt.Println(" Add(4,5)的结果为:", ret2)
111
 	fmt.Println(" Add(4,5)的结果为:", ret2)
113
 	str11 := prttostr(uintptr(p))
112
 	str11 := prttostr(uintptr(p))
126
 
125
 
127
 func prttostr(vcode uintptr) string {
126
 func prttostr(vcode uintptr) string {
128
 	var vbyte []byte
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
 	return string(vbyte)
136
 	return string(vbyte)
138
- }
139
-
137
+}
140
 
138
 
141
 //func (c *HisApiController) TestPay() {
139
 //func (c *HisApiController) TestPay() {
142
 //	DllDef2 := syscall.MustLoadDLL("SSSE32.dll")
140
 //	DllDef2 := syscall.MustLoadDLL("SSSE32.dll")
1010
 	config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
1008
 	config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
1011
 
1009
 
1012
 	if config.IsOpen == 1 {
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
 		resp, requestErr := http.Get(api)
1012
 		resp, requestErr := http.Get(api)
1015
 		if requestErr != nil {
1013
 		if requestErr != nil {
1016
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1014
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1086
 			timeFormat := tempTime.Format("20060102150405")
1084
 			timeFormat := tempTime.Format("20060102150405")
1087
 			chrgBchno := rand.Intn(100000) + 10000
1085
 			chrgBchno := rand.Intn(100000) + 10000
1088
 			ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
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
 			department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
1088
 			department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
1091
 			doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
1089
 			doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
1092
 
1090
 
1126
 			if is310 == 1 {
1124
 			if is310 == 1 {
1127
 				insutype = "310"
1125
 				insutype = "310"
1128
 			}
1126
 			}
1127
+			if count == 1 {
1128
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
1129
+				return
1130
+			}
1129
 			api := "http://127.0.0.1:9532/" + "gdyb/two?cert_no=" + IdCardNo + "&insutype=" +
1131
 			api := "http://127.0.0.1:9532/" + "gdyb/two?cert_no=" + IdCardNo + "&insutype=" +
1130
 				insutype + "&psn_no=" + res.Output.Baseinfo.PsnNo +
1132
 				insutype + "&psn_no=" + res.Output.Baseinfo.PsnNo +
1131
 				"&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&ipt_otp_no=" + ipt_otp_no +
1133
 				"&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&ipt_otp_no=" + ipt_otp_no +
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
 				var dat map[string]interface{}
1616
 				var dat map[string]interface{}
1615
 				if err := json.Unmarshal([]byte(result), &dat); err == nil {
1617
 				if err := json.Unmarshal([]byte(result), &dat); err == nil {
1616
 					fmt.Println(dat)
1618
 					fmt.Println(dat)

+ 25 - 15
service/gdyb_service.go View File

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
 	nonce := GetRandomString(32)
92
 	nonce := GetRandomString(32)
93
 	timestamp := time.Now().Unix()
93
 	timestamp := time.Now().Unix()
98
 	inputData := make(map[string]interface{})
98
 	inputData := make(map[string]interface{})
99
 	inputMessage["infno"] = "1101" // 交易编码
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
 		inputData["certno"] = certNo        // 证件号码
103
 		inputData["certno"] = certNo        // 证件号码
104
+
105
 	} else {
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
 	inputData["psn_cert_type"] = "1"    // 人员证件类型
117
 	inputData["psn_cert_type"] = "1"    // 人员证件类型
111
 	inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
118
 	inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
112
 	inputData["begntime"] = ""          // 开始时间
119
 	inputData["begntime"] = ""          // 开始时间
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
 	nonce := GetRandomString(32)
931
 	nonce := GetRandomString(32)
925
 	timestamp := time.Now().Unix()
932
 	timestamp := time.Now().Unix()
930
 	input := make(map[string]interface{})
937
 	input := make(map[string]interface{})
931
 	inputData := make(map[string]interface{})
938
 	inputData := make(map[string]interface{})
932
 	inputMessage["infno"] = "2207" // 交易编码
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
 		inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
943
 		inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
939
 	} else {
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
 	inputData["med_type"] = med_type    // 医疗类别 11 普通门诊  12 门诊挂号
954
 	inputData["med_type"] = med_type    // 医疗类别 11 普通门诊  12 门诊挂号