package service import ( "bytes" "encoding/json" "fmt" "gdyb/models" "github.com/astaxie/beego" "io/ioutil" "net/http" "strconv" "time" ) // 人员基本信息 func Gdyb4201A(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, psn_name string) (string, string) { //生成签名 nonce := GetRandomString(32) timestamp := time.Now().Unix() signature := setSignature(timestamp, nonce, secret_key) //生成输入报文 inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs) input := make(map[string]interface{}) inputData := make(map[string]interface{}) inputMessage["infno"] = "4201A" // 交易编码 inputData["fixmedins_mdtrt_id"] = "" inputData["med_type"] = "" inputData["bkkp_sn"] = "" inputData["fee_ocur_time"] = "" inputData["fixmedins_code"] = "" inputData["fixmedins_name"] = "" inputData["cnt"] = "" inputData["pric"] = "" inputData["det_item_fee_sumamt"] = "" inputData["med_list_codg"] = "" inputData["medins_list_name"] = "" inputData["medins_list_code"] = "" inputData["med_chrgitm_type"] = "" inputData["prodname"] = "" inputData["bilg_dept_codg"] = "" inputData["bilg_dept_name"] = "" inputData["bilg_dr_code"] = "" inputData["bilg_dr_name"] = "" inputData["acord_dept_codg"] = "" inputData["acord_dept_name"] = "" inputData["acord_dr_code"] = "" inputData["acord_dr_name"] = "" inputData["tcmdrug_used_way"] = "" inputData["etip_flag"] = "" inputData["etip_hosp_code"] = "" inputData["dscg_tkdrug_flag"] = "" inputData["sin_dos_dscr"] = "" inputData["used_frqu_dscr"] = "" inputData["prd_days"] = "" inputData["medc_way_dscr"] = "" inputData["memo"] = "" inputData["fulamt_ownpay_amt"] = "" inputData["overlmt_selfpay"] = "" inputData["preselfpay_amt"] = "" inputData["inscp_amt"] = "" input["data"] = inputData inputMessage["input"] = input //交易输入 var inputLog string bytesData, err := json.Marshal(inputMessage) inputLog = string(bytesData) fmt.Println(string(bytesData)) if err != nil { fmt.Println(err.Error()) return err.Error(), "" } reader := bytes.NewReader(bytesData) gdyb_url := beego.AppConfig.String("gdyb_url") gdyb_paasid := beego.AppConfig.String("gdyb_paasid") var url string if fixmedins_code == "H15049901371" { url = gdyb_url } else { url = gdyb_url + "1101" } //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101" request, err := http.NewRequest("POST", url, reader) if err != nil { fmt.Println(err.Error()) return err.Error(), "" } request.Header.Set("Content-Type", "application/json;charset=UTF-8") request.Header.Set("x-tif-paasid", gdyb_paasid) request.Header.Set("x-tif-signature", signature) request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10)) request.Header.Set("x-tif-nonce", nonce) client := http.Client{} resp, err := client.Do(request) if err != nil { fmt.Println(err.Error()) return err.Error(), "" } respBytes, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err.Error()) return err.Error(), "" } fmt.Println(string(respBytes)) str := string(respBytes) return str, inputLog } func Gdyb4202(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, struct4202 models.Struct4202) (string, string) { //生成签名 nonce := GetRandomString(32) timestamp := time.Now().Unix() signature := setSignature(timestamp, nonce, secret_key) //生成输入报文 inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs) input := make(map[string]interface{}) inputData := make(map[string]interface{}) inputMessage["infno"] = "4202" // 交易编码 feedetail := make([]map[string]interface{}, 0) inputData["fixmedins_mdtrt_id"] = struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID inputData["fixmedins_code"] = struct4202.OwnPayPatnMdtrtD.FixmedinsCode inputData["fixmedins_name"] = struct4202.OwnPayPatnMdtrtD.FixmedinsName inputData["psn_cert_type"] = struct4202.OwnPayPatnMdtrtD.PsnCertType inputData["certno"] = struct4202.OwnPayPatnMdtrtD.Certno inputData["psn_name"] = struct4202.OwnPayPatnMdtrtD.PsnName inputData["gend"] = "" inputData["naty"] = "" inputData["brdy"] = "" inputData["age"] = "" inputData["coner_name"] = "" inputData["tel"] = "" inputData["addr"] = "" inputData["begntime"] = struct4202.OwnPayPatnMdtrtD.Begntime inputData["endtime"] = "" inputData["med_type"] = struct4202.OwnPayPatnMdtrtD.MedType inputData["ipt_otp_no"] = "" inputData["medrcdno"] = "" inputData["chfpdr_code"] = "" inputData["adm_dept_dscr"] = "" inputData["adm_dept_codg"] = "" inputData["adm_dept_name"] = "" inputData["adm_bed"] = "" inputData["wardarea_bed"] = "" inputData["traf_dept_flag"] = "" inputData["dscg_maindiag_code"] = "" inputData["dscg_dept_codg"] = "" inputData["dscg_dept_name"] = "" inputData["dscg_bed"] = "" inputData["dscg_way"] = "" inputData["main_cond_dscr"] = "" inputData["dise_no"] = "" inputData["dise_name"] = "" inputData["oprn_oprt_code"] = "" inputData["oprn_oprt_name"] = "" inputData["otp_diag_info"] = "" inputData["inhosp_stas"] = "" inputData["die_date"] = "" inputData["ipt_days"] = "" inputData["fpsc_no"] = "" inputData["matn_type"] = "" inputData["birctrl_type"] = "" inputData["latechb_flag"] = "" inputData["geso_val"] = "" inputData["fetts"] = "" inputData["fetus_cnt"] = "" inputData["pret_flag"] = "" inputData["prey_time"] = "" inputData["birctrl_matn_date"] = "" inputData["cop_flag"] = "" inputData["vali_flag"] = "1" inputData["memo"] = "" inputData["opter_id"] = "" inputData["opter_name"] = "" inputData["opt_time"] = "" inputData["chfpdr_name"] = "" inputData["dscg_maindiag_name"] = "" inputData["medfee_sumamt"] = struct4202.OwnPayPatnMdtrtD.MedfeeSumamt inputData["elec_bill_code"] = "" inputData["elec_billno_code"] = "" inputData["exp_content"] = "" for _, item := range struct4202.ODiagListD { feedetailInfo := make(map[string]interface{}) feedetailInfo["inout_diag_type"] = item.InoutDiagType feedetailInfo["diag_type"] = item.DiagType // 就诊 ID(来自2201接口返回) feedetailInfo["maindiag_flag"] = item.MaindiagFlag // 人员编号 (来自1101接口返回) feedetailInfo["diag_srt_no"] = "" // 收费批次号 feedetailInfo["diag_code"] = "" // 病种编码 feedetailInfo["diag_name"] = "" // 处方号 feedetailInfo["diag_dept"] = "" feedetailInfo["diag_dr_code"] = "" feedetailInfo["diag_dr_name"] = "" feedetailInfo["diag_time"] = "" feedetailInfo["vali_flag"] = "" feedetail = append(feedetail, feedetailInfo) } inputData["ownPayPatnDiagListD"] = feedetail input["data"] = inputData inputMessage["input"] = input //交易输入 var inputLog string bytesData, err := json.Marshal(inputMessage) inputLog = string(bytesData) fmt.Println(string(bytesData)) if err != nil { fmt.Println(err.Error()) return err.Error(), "" } reader := bytes.NewReader(bytesData) gdyb_url := beego.AppConfig.String("gdyb_url") gdyb_paasid := beego.AppConfig.String("gdyb_paasid") var url string if fixmedins_code == "H15049901371" { url = gdyb_url } else { url = gdyb_url + "1101" } //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101" request, err := http.NewRequest("POST", url, reader) if err != nil { fmt.Println(err.Error()) return err.Error(), "" } request.Header.Set("Content-Type", "application/json;charset=UTF-8") request.Header.Set("x-tif-paasid", gdyb_paasid) request.Header.Set("x-tif-signature", signature) request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10)) request.Header.Set("x-tif-nonce", nonce) client := http.Client{} resp, err := client.Do(request) if err != nil { fmt.Println(err.Error()) return err.Error(), "" } respBytes, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err.Error()) return err.Error(), "" } fmt.Println(string(respBytes)) str := string(respBytes) return str, inputLog } func Gdyb4203(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, psn_name string) (string, string) { //生成签名 nonce := GetRandomString(32) timestamp := time.Now().Unix() signature := setSignature(timestamp, nonce, secret_key) //生成输入报文 inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs) //input := make(map[string]interface{}) inputData := make(map[string]interface{}) inputMessage["infno"] = "4203" // 交易编码 inputData["fixmedins_mdtrt_id"] = "" // 开始时间 inputData["fixmedins_code"] = "" // 开始时间 inputData["cplt_flag"] = "" // 人员姓名 inputMessage["input"] = inputData //交易输入 var inputLog string bytesData, err := json.Marshal(inputMessage) inputLog = string(bytesData) fmt.Println(string(bytesData)) if err != nil { fmt.Println(err.Error()) return err.Error(), "" } reader := bytes.NewReader(bytesData) gdyb_url := beego.AppConfig.String("gdyb_url") gdyb_paasid := beego.AppConfig.String("gdyb_paasid") var url string if fixmedins_code == "H15049901371" { url = gdyb_url } else { url = gdyb_url + "1101" } //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101" request, err := http.NewRequest("POST", url, reader) if err != nil { fmt.Println(err.Error()) return err.Error(), "" } request.Header.Set("Content-Type", "application/json;charset=UTF-8") request.Header.Set("x-tif-paasid", gdyb_paasid) request.Header.Set("x-tif-signature", signature) request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10)) request.Header.Set("x-tif-nonce", nonce) client := http.Client{} resp, err := client.Do(request) if err != nil { fmt.Println(err.Error()) return err.Error(), "" } respBytes, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err.Error()) return err.Error(), "" } fmt.Println(string(respBytes)) str := string(respBytes) return str, inputLog } func Gdyb4204(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, psn_name string) (string, string) { //生成签名 nonce := GetRandomString(32) timestamp := time.Now().Unix() signature := setSignature(timestamp, nonce, secret_key) //生成输入报文 inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs) input := make(map[string]interface{}) inputData := make(map[string]interface{}) feedetail := make([]map[string]interface{}, 0) inputMessage["infno"] = "4204" // 交易编码 inputData["fixmedins_mdtrt_id"] = "" inputData["fixmedins_code"] = "" feedetailInfo := make(map[string]interface{}) feedetailInfo["bkkp_sn"] = "" feedetail = append(feedetail, feedetailInfo) input["feedetl"] = feedetail input["feedetail"] = inputData inputMessage["input"] = input //交易输入 var inputLog string bytesData, err := json.Marshal(inputMessage) inputLog = string(bytesData) fmt.Println(string(bytesData)) if err != nil { fmt.Println(err.Error()) return err.Error(), "" } reader := bytes.NewReader(bytesData) gdyb_url := beego.AppConfig.String("gdyb_url") gdyb_paasid := beego.AppConfig.String("gdyb_paasid") var url string if fixmedins_code == "H15049901371" { url = gdyb_url } else { url = gdyb_url + "1101" } //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101" request, err := http.NewRequest("POST", url, reader) if err != nil { fmt.Println(err.Error()) return err.Error(), "" } request.Header.Set("Content-Type", "application/json;charset=UTF-8") request.Header.Set("x-tif-paasid", gdyb_paasid) request.Header.Set("x-tif-signature", signature) request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10)) request.Header.Set("x-tif-nonce", nonce) client := http.Client{} resp, err := client.Do(request) if err != nil { fmt.Println(err.Error()) return err.Error(), "" } respBytes, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err.Error()) return err.Error(), "" } fmt.Println(string(respBytes)) str := string(respBytes) return str, inputLog } func Gdyb4205(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, psn_name string) (string, string) { //生成签名 nonce := GetRandomString(32) timestamp := time.Now().Unix() signature := setSignature(timestamp, nonce, secret_key) //生成输入报文 inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs) input := make(map[string]interface{}) inputData := make(map[string]interface{}) inputMessage["infno"] = "4205" // 交易编码 inputData["fixmedins_mdtrt_id"] = "" inputData["fixmedins_code"] = "" inputData["fixmedins_name"] = "" inputData["psn_cert_type"] = "" inputData["certno"] = "" inputData["psn_name"] = "" inputData["gend"] = "" inputData["naty"] = "" inputData["brdy"] = "" inputData["age"] = "" inputData["coner_name"] = "" inputData["tel"] = "" inputData["addr"] = "" inputData["begntime"] = "" inputData["endtime"] = "" inputData["med_type"] = "" inputData["main_cond_dscr"] = "" inputData["dise_codg"] = "" inputData["dise_name"] = "" inputData["birctrl_type"] = "" inputData["birctrl_matn_date"] = "" inputData["matn_type"] = "" inputData["geso_val"] = "" inputData["elec_bill_code"] = "" inputData["elec_billno_code"] = "" inputData["elec_bill_chkcode"] = "" inputData["exp_content"] = "" diagInfos := make([]map[string]interface{}, 0) diagInfo := make(map[string]interface{}) diagInfo["diag_type"] = "" // 就诊 ID(来自2201接口返回) diagInfo["diag_srt_no"] = "" // 收费批次号 diagInfo["diag_code"] = "" // 病种编码 diagInfo["diag_name"] = "" // 处方号 diagInfo["diag_dept"] = "" diagInfo["diag_dr_code"] = "" diagInfo["diag_dr_name"] = "" diagInfo["diag_time"] = "" diagInfo["vali_flag"] = "" diagInfos = append(diagInfos, diagInfo) inputData["diseinfo"] = diagInfos feedetail := make([]map[string]interface{}, 0) feedetailInfo := make(map[string]interface{}) feedetailInfo["fixmedins_mdtrt_id"] = "" // 就诊 ID(来自2201接口返回) feedetailInfo["med_type"] = "" // 收费批次号 feedetailInfo["bkkp_sn"] = "" // 病种编码 feedetailInfo["fee_ocur_time"] = "" // 处方号 feedetailInfo["fixmedins_code"] = "" feedetailInfo["fixmedins_name"] = "" feedetailInfo["cnt"] = "" feedetailInfo["pric"] = "" feedetailInfo["det_item_fee_sumamt"] = "" feedetailInfo["medins_list_codg"] = "" feedetailInfo["medins_list_name"] = "" feedetailInfo["med_chrgitm_type"] = "" feedetailInfo["prodname"] = "" feedetailInfo["bilg_dept_codg"] = "" feedetailInfo["bilg_dept_name"] = "" feedetailInfo["bilg_dr_code"] = "" feedetailInfo["bilg_dr_name"] = "" feedetailInfo["acord_dept_codg"] = "" feedetailInfo["acord_dept_name"] = "" feedetailInfo["acord_dr_code"] = "" feedetailInfo["acord_dr_name"] = "" feedetailInfo["tcmdrug_used_way"] = "" feedetailInfo["etip_flag"] = "" feedetailInfo["etip_hosp_code"] = "" feedetailInfo["dscg_tkdrug_flag"] = "" feedetailInfo["sin_dos_dscr"] = "" feedetailInfo["used_frqu_dscr"] = "" feedetailInfo["prd_days"] = "" feedetailInfo["medc_way_dscr"] = "" feedetailInfo["memo"] = "" feedetailInfo["fulamt_ownpay_amt"] = "" feedetailInfo["overlmt_selfpay"] = "" feedetailInfo["preselfpay_amt"] = "" feedetailInfo["inscp_amt"] = "" feedetailInfo["rxno"] = "" feedetail = append(feedetail, feedetailInfo) inputData["feedetail"] = feedetail input["data"] = inputData inputMessage["input"] = input //交易输入 var inputLog string bytesData, err := json.Marshal(inputMessage) inputLog = string(bytesData) fmt.Println(string(bytesData)) if err != nil { fmt.Println(err.Error()) return err.Error(), "" } reader := bytes.NewReader(bytesData) gdyb_url := beego.AppConfig.String("gdyb_url") gdyb_paasid := beego.AppConfig.String("gdyb_paasid") var url string if fixmedins_code == "H15049901371" { url = gdyb_url } else { url = gdyb_url + "1101" } //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101" request, err := http.NewRequest("POST", url, reader) if err != nil { fmt.Println(err.Error()) return err.Error(), "" } request.Header.Set("Content-Type", "application/json;charset=UTF-8") request.Header.Set("x-tif-paasid", gdyb_paasid) request.Header.Set("x-tif-signature", signature) request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10)) request.Header.Set("x-tif-nonce", nonce) client := http.Client{} resp, err := client.Do(request) if err != nil { fmt.Println(err.Error()) return err.Error(), "" } respBytes, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err.Error()) return err.Error(), "" } fmt.Println(string(respBytes)) str := string(respBytes) return str, inputLog } func Gdyb4206(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, psn_name string) (string, string) { //生成签名 nonce := GetRandomString(32) timestamp := time.Now().Unix() signature := setSignature(timestamp, nonce, secret_key) //生成输入报文 inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs) input := make(map[string]interface{}) inputData := make(map[string]interface{}) inputMessage["infno"] = "4206" // 交易编码 inputData["fixmedins_mdtrt_id"] = "" // 开始时间 inputData["fixmedins_code"] = "" // 开始时间 input["input"] = inputData // 开始时间 inputMessage["input"] = input //交易输入 var inputLog string bytesData, err := json.Marshal(inputMessage) inputLog = string(bytesData) fmt.Println(string(bytesData)) if err != nil { fmt.Println(err.Error()) return err.Error(), "" } reader := bytes.NewReader(bytesData) gdyb_url := beego.AppConfig.String("gdyb_url") gdyb_paasid := beego.AppConfig.String("gdyb_paasid") var url string if fixmedins_code == "H15049901371" { url = gdyb_url } else { url = gdyb_url + "1101" } //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101" request, err := http.NewRequest("POST", url, reader) if err != nil { fmt.Println(err.Error()) return err.Error(), "" } request.Header.Set("Content-Type", "application/json;charset=UTF-8") request.Header.Set("x-tif-paasid", gdyb_paasid) request.Header.Set("x-tif-signature", signature) request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10)) request.Header.Set("x-tif-nonce", nonce) client := http.Client{} resp, err := client.Do(request) if err != nil { fmt.Println(err.Error()) return err.Error(), "" } respBytes, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err.Error()) return err.Error(), "" } fmt.Println(string(respBytes)) str := string(respBytes) return str, inputLog } func Gdyb4207(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, psn_name string) (string, string) { //生成签名 nonce := GetRandomString(32) timestamp := time.Now().Unix() signature := setSignature(timestamp, nonce, secret_key) //生成输入报文 inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs) input := make(map[string]interface{}) inputData := make(map[string]interface{}) inputMessage["infno"] = "4207" // 交易编码 inputData["fixmedins_mdtrt_id"] = "" // 开始时间 inputData["fixmedins_code"] = "" // 人员姓名 inputData["page_num"] = "" // 人员姓名 inputData["page_size"] = "" // 人员姓名 input["input"] = inputData inputMessage["input"] = input //交易输入 var inputLog string bytesData, err := json.Marshal(inputMessage) inputLog = string(bytesData) fmt.Println(string(bytesData)) if err != nil { fmt.Println(err.Error()) return err.Error(), "" } reader := bytes.NewReader(bytesData) gdyb_url := beego.AppConfig.String("gdyb_url") gdyb_paasid := beego.AppConfig.String("gdyb_paasid") var url string if fixmedins_code == "H15049901371" { url = gdyb_url } else { url = gdyb_url + "1101" } //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101" request, err := http.NewRequest("POST", url, reader) if err != nil { fmt.Println(err.Error()) return err.Error(), "" } request.Header.Set("Content-Type", "application/json;charset=UTF-8") request.Header.Set("x-tif-paasid", gdyb_paasid) request.Header.Set("x-tif-signature", signature) request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10)) request.Header.Set("x-tif-nonce", nonce) client := http.Client{} resp, err := client.Do(request) if err != nil { fmt.Println(err.Error()) return err.Error(), "" } respBytes, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err.Error()) return err.Error(), "" } fmt.Println(string(respBytes)) str := string(respBytes) return str, inputLog } func Gdyb4208(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, psn_name string) (string, string) { //生成签名 nonce := GetRandomString(32) timestamp := time.Now().Unix() signature := setSignature(timestamp, nonce, secret_key) //生成输入报文 inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs) input := make(map[string]interface{}) inputData := make(map[string]interface{}) inputMessage["infno"] = "4208" // 交易编码 inputData["psn_cert_type"] = "" // 开始时间 inputData["certno"] = "" // 人员姓名 inputData["psn_name"] = "" // 人员姓名 inputData["begintime"] = "" // 人员姓名 inputData["endtime"] = "" // 人员姓名 inputData["med_type"] = "" // 人员姓名 inputData["medfee_sumamt"] = "" // 人员姓名 inputData["elec_billno_code"] = "" // 人员姓名 inputData["page_num"] = "" // 人员姓名 inputData["page_size"] = "" // 人员姓名 input["input"] = inputData inputMessage["input"] = input //交易输入 var inputLog string bytesData, err := json.Marshal(inputMessage) inputLog = string(bytesData) fmt.Println(string(bytesData)) if err != nil { fmt.Println(err.Error()) return err.Error(), "" } reader := bytes.NewReader(bytesData) gdyb_url := beego.AppConfig.String("gdyb_url") gdyb_paasid := beego.AppConfig.String("gdyb_paasid") var url string if fixmedins_code == "H15049901371" { url = gdyb_url } else { url = gdyb_url + "1101" } //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101" request, err := http.NewRequest("POST", url, reader) if err != nil { fmt.Println(err.Error()) return err.Error(), "" } request.Header.Set("Content-Type", "application/json;charset=UTF-8") request.Header.Set("x-tif-paasid", gdyb_paasid) request.Header.Set("x-tif-signature", signature) request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10)) request.Header.Set("x-tif-nonce", nonce) client := http.Client{} resp, err := client.Do(request) if err != nil { fmt.Println(err.Error()) return err.Error(), "" } respBytes, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err.Error()) return err.Error(), "" } fmt.Println(string(respBytes)) str := string(respBytes) return str, inputLog } func Gdyb4209(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, psn_name string) (string, string) { //生成签名 nonce := GetRandomString(32) timestamp := time.Now().Unix() signature := setSignature(timestamp, nonce, secret_key) //生成输入报文 inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs) input := make(map[string]interface{}) inputData := make(map[string]interface{}) inputMessage["infno"] = "4209" // 交易编码 inputData["fixmedins_mdtrt_id"] = "" // 开始时间 inputData["fixmedins_code"] = "" // 人员姓名 inputData["page_num"] = "" // 人员姓名 inputData["page_size"] = "" // 人员姓名 input["input"] = inputData inputMessage["input"] = input //交易输入 var inputLog string bytesData, err := json.Marshal(inputMessage) inputLog = string(bytesData) fmt.Println(string(bytesData)) if err != nil { fmt.Println(err.Error()) return err.Error(), "" } reader := bytes.NewReader(bytesData) gdyb_url := beego.AppConfig.String("gdyb_url") gdyb_paasid := beego.AppConfig.String("gdyb_paasid") var url string if fixmedins_code == "H15049901371" { url = gdyb_url } else { url = gdyb_url + "1101" } //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101" request, err := http.NewRequest("POST", url, reader) if err != nil { fmt.Println(err.Error()) return err.Error(), "" } request.Header.Set("Content-Type", "application/json;charset=UTF-8") request.Header.Set("x-tif-paasid", gdyb_paasid) request.Header.Set("x-tif-signature", signature) request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10)) request.Header.Set("x-tif-nonce", nonce) client := http.Client{} resp, err := client.Do(request) if err != nil { fmt.Println(err.Error()) return err.Error(), "" } respBytes, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err.Error()) return err.Error(), "" } fmt.Println(string(respBytes)) str := string(respBytes) return str, inputLog }