|
@@ -13,7 +13,9 @@ import (
|
13
|
13
|
"mime/multipart"
|
14
|
14
|
"net/http"
|
15
|
15
|
"os"
|
|
16
|
+ "path/filepath"
|
16
|
17
|
"strconv"
|
|
18
|
+ "strings"
|
17
|
19
|
"time"
|
18
|
20
|
_ "unsafe"
|
19
|
21
|
)
|
|
@@ -38,7 +40,7 @@ func Gdyb1101(certNo string, org_name string, doctor string, fixmedins_code stri
|
38
|
40
|
inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
|
39
|
41
|
inputData["card_sn"] = "" // 卡识别码
|
40
|
42
|
inputData["begntime"] = "" // 开始时间
|
41
|
|
- inputData["psn_cert_type"] = "" // 人员证件类型
|
|
43
|
+ inputData["psn_cert_type"] = "1" // 人员证件类型
|
42
|
44
|
inputData["certno"] = certNo // 证件号码
|
43
|
45
|
inputData["psn_name"] = "" // 人员姓名
|
44
|
46
|
input["data"] = inputData
|
|
@@ -798,23 +800,31 @@ func Gdyb3201(baseParams models.BaseParams, businessParams models.BusinessParams
|
798
|
800
|
return str
|
799
|
801
|
}
|
800
|
802
|
|
|
803
|
+type Params struct {
|
|
804
|
+ FileName string `json:"file_name"` //产品ID
|
|
805
|
+ In []byte `json:"in"` //
|
|
806
|
+ FixmedinsCode string `json:"fixmedins_code"` //调用环境生产为1 沙盒2
|
|
807
|
+}
|
|
808
|
+
|
|
809
|
+//文件上传
|
801
|
810
|
//文件上传
|
802
|
811
|
func Gdyb9101(baseParams models.BaseParams, file_name string, file_byte []byte) string {
|
803
|
812
|
|
804
|
|
- //http.Post(strinUrl,"multipart/form-data",bytes.NewReader(file_byte))
|
805
|
|
-
|
806
|
813
|
// 生成签名
|
807
|
814
|
nonce := GetRandomString(32)
|
808
|
815
|
timestamp := time.Now().Unix()
|
809
|
816
|
signature := setSignature(timestamp, nonce, baseParams.SecretKey)
|
810
|
817
|
|
811
|
|
- // 生成输入报文
|
|
818
|
+ buf := new(bytes.Buffer)
|
|
819
|
+ buf.ReadFrom(strings.NewReader(string(file_byte)))
|
|
820
|
+
|
812
|
821
|
inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
|
813
|
822
|
input := make(map[string]interface{})
|
814
|
823
|
inputData := make(map[string]interface{})
|
|
824
|
+
|
815
|
825
|
inputMessage["infno"] = "9101" // 交易编码
|
816
|
826
|
inputData["file_name"] = file_name //文件名
|
817
|
|
- inputData["in"] = file_byte //文件数据
|
|
827
|
+ inputData["in"] = bytes.NewBuffer(file_byte).Bytes() //文件数据
|
818
|
828
|
inputData["fixmedins_code"] = baseParams.FixmedinsCode //编码
|
819
|
829
|
|
820
|
830
|
input["fsUploadIn"] = inputData
|
|
@@ -857,6 +867,59 @@ func Gdyb9101(baseParams models.BaseParams, file_name string, file_byte []byte)
|
857
|
867
|
return str
|
858
|
868
|
}
|
859
|
869
|
|
|
870
|
+func Gdyb9102(baseParams models.BaseParams, file_name string, file_qury_no string) string {
|
|
871
|
+
|
|
872
|
+ // 生成签名
|
|
873
|
+ nonce := GetRandomString(32)
|
|
874
|
+ timestamp := time.Now().Unix()
|
|
875
|
+ signature := setSignature(timestamp, nonce, baseParams.SecretKey)
|
|
876
|
+ inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
|
|
877
|
+ input := make(map[string]interface{})
|
|
878
|
+ inputData := make(map[string]interface{})
|
|
879
|
+ inputMessage["infno"] = "9102" // 交易编码
|
|
880
|
+ inputData["file_name"] = file_name //文件名
|
|
881
|
+ inputData["file_qury_no"] = "fsi/H44022900158/" + file_qury_no //文件数据
|
|
882
|
+ inputData["fixmedins_code"] = baseParams.FixmedinsCode //编码
|
|
883
|
+ input["fsDownloadIn"] = inputData
|
|
884
|
+ inputMessage["input"] = input //交易输入
|
|
885
|
+
|
|
886
|
+ bytesData, err := json.Marshal(inputMessage)
|
|
887
|
+ fmt.Println(string(bytesData))
|
|
888
|
+ if err != nil {
|
|
889
|
+ fmt.Println(err.Error())
|
|
890
|
+ return err.Error()
|
|
891
|
+ }
|
|
892
|
+ reader := bytes.NewReader(bytesData)
|
|
893
|
+
|
|
894
|
+ url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9102"
|
|
895
|
+ request, err := http.NewRequest("POST", url, reader)
|
|
896
|
+ if err != nil {
|
|
897
|
+ fmt.Println(err.Error())
|
|
898
|
+ return err.Error()
|
|
899
|
+ }
|
|
900
|
+
|
|
901
|
+ request.Header.Set("Content-Type", "application/json;charset=UTF-8")
|
|
902
|
+ request.Header.Set("x-tif-paasid", "test_hosp")
|
|
903
|
+ request.Header.Set("x-tif-signature", signature)
|
|
904
|
+ request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
|
|
905
|
+ request.Header.Set("x-tif-nonce", nonce)
|
|
906
|
+
|
|
907
|
+ client := http.Client{}
|
|
908
|
+ resp, err := client.Do(request)
|
|
909
|
+ if err != nil {
|
|
910
|
+ fmt.Println(err.Error())
|
|
911
|
+ return err.Error()
|
|
912
|
+ }
|
|
913
|
+ respBytes, err := ioutil.ReadAll(resp.Body)
|
|
914
|
+ if err != nil {
|
|
915
|
+ fmt.Println(err.Error())
|
|
916
|
+ return err.Error()
|
|
917
|
+ }
|
|
918
|
+ str := string(respBytes)
|
|
919
|
+ fmt.Println(str)
|
|
920
|
+ return str
|
|
921
|
+}
|
|
922
|
+
|
860
|
923
|
func Gdyb3202(baseParams models.BaseParams, businessParams models.BusinessParams) string {
|
861
|
924
|
// 生成签名
|
862
|
925
|
nonce := GetRandomString(32)
|
|
@@ -867,15 +930,15 @@ func Gdyb3202(baseParams models.BaseParams, businessParams models.BusinessParams
|
867
|
930
|
inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
|
868
|
931
|
input := make(map[string]interface{})
|
869
|
932
|
inputData := make(map[string]interface{})
|
870
|
|
- inputMessage["infno"] = "3202" // 交易编码
|
871
|
|
- inputData["file_qury_no"] = businessParams.FileQuryNo // 险种
|
872
|
|
- inputData["setl_optins"] = baseParams.OrgName // 结算经办机构
|
873
|
|
- inputData["stmt_begndate"] = businessParams.StmtBegndate // 对帐开始时间
|
874
|
|
- inputData["stmt_enddate"] = businessParams.StmtEnddate //对帐结束时间
|
875
|
|
- inputData["medfee_sumamt"] = businessParams.MedfeeSumamt //医疗费总额
|
876
|
|
- inputData["fund_pay_sumamt"] = businessParams.FundPaySumamt //基金支付总额
|
877
|
|
- inputData["cash_payamt"] = businessParams.CashPayamt //现金支付金额
|
878
|
|
- inputData["fixmedins_setl_cnt"] = businessParams.FixmedinsSetlCnt //定点医药机构结算笔数
|
|
933
|
+ inputMessage["infno"] = "3202" // 交易编码
|
|
934
|
+ inputData["file_qury_no"] = "fsi/H44022900158/" + businessParams.FileQuryNo // 险种
|
|
935
|
+ inputData["setl_optins"] = baseParams.OrgName // 结算经办机构
|
|
936
|
+ inputData["stmt_begndate"] = businessParams.StmtBegndate // 对帐开始时间
|
|
937
|
+ inputData["stmt_enddate"] = businessParams.StmtEnddate //对帐结束时间
|
|
938
|
+ inputData["medfee_sumamt"] = businessParams.MedfeeSumamt //医疗费总额
|
|
939
|
+ inputData["fund_pay_sumamt"] = businessParams.FundPaySumamt //基金支付总额
|
|
940
|
+ inputData["cash_payamt"] = businessParams.CashPayamt //现金支付金额
|
|
941
|
+ inputData["fixmedins_setl_cnt"] = businessParams.FixmedinsSetlCnt //定点医药机构结算笔数
|
879
|
942
|
|
880
|
943
|
input["data"] = inputData
|
881
|
944
|
inputMessage["input"] = input //交易输入
|
|
@@ -1261,3 +1324,31 @@ func postFile(filename string, target_url string) (*http.Response, error) {
|
1261
|
1324
|
// fmt.Println(str)
|
1262
|
1325
|
// return str
|
1263
|
1326
|
//}
|
|
1327
|
+
|
|
1328
|
+func newfileUploadRequest(uri string, params map[string]string, paramName, path string) (*http.Request, error) {
|
|
1329
|
+ file, err := os.Open(path)
|
|
1330
|
+ if err != nil {
|
|
1331
|
+ return nil, err
|
|
1332
|
+ }
|
|
1333
|
+ defer file.Close()
|
|
1334
|
+
|
|
1335
|
+ body := &bytes.Buffer{}
|
|
1336
|
+ writer := multipart.NewWriter(body)
|
|
1337
|
+ part, err := writer.CreateFormFile(paramName, filepath.Base(path))
|
|
1338
|
+ if err != nil {
|
|
1339
|
+ return nil, err
|
|
1340
|
+ }
|
|
1341
|
+ _, err = io.Copy(part, file)
|
|
1342
|
+
|
|
1343
|
+ for key, val := range params {
|
|
1344
|
+ _ = writer.WriteField(key, val)
|
|
1345
|
+ }
|
|
1346
|
+ err = writer.Close()
|
|
1347
|
+ if err != nil {
|
|
1348
|
+ return nil, err
|
|
1349
|
+ }
|
|
1350
|
+
|
|
1351
|
+ req, err := http.NewRequest("POST", uri, body)
|
|
1352
|
+ req.Header.Set("Content-Type", writer.FormDataContentType())
|
|
1353
|
+ return req, err
|
|
1354
|
+}
|