package service import ( "bytes" "encoding/json" "fmt" "gdyb/models" "github.com/astaxie/beego" "io/ioutil" "net/http" "strconv" "time" ) // 人员基本信息 func Gdyb4201A(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, struct4201A models.Struct4201A) (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{}) inputDatas := make([]map[string]interface{}, 0) inputMessage["infno"] = "4201A" // 交易编码 for _, item := range struct4201A.Fopfd { inputData := make(map[string]interface{}) inputData["fixmedins_mdtrt_id"] = item.FixmedinsMdtrtID inputData["med_type"] = item.MedType inputData["bkkp_sn"] = item.BkkpSn inputData["fee_ocur_time"] = item.FeeOcurTime inputData["fixmedins_code"] = item.FixmedinsCode inputData["fixmedins_name"] = item.FixmedinsName inputData["cnt"] = item.Cnt inputData["pric"] = item.Pric inputData["det_item_fee_sumamt"] = item.DetItemFeeSumamt inputData["med_list_codg"] = item.MedListCodg inputData["medins_list_name"] = item.MedinsListName inputData["medins_list_code"] = item.MedinsListCodg inputData["med_chrgitm_type"] = item.MedChrgitmType inputData["prodname"] = item.Prodname inputData["bilg_dept_codg"] = item.BilgDeptCodg inputData["bilg_dept_name"] = item.BilgDeptName inputData["bilg_dr_code"] = item.BilgDrCode inputData["bilg_dr_name"] = item.BilgDrName 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"] = item.Memo inputData["fulamt_ownpay_amt"] = "" inputData["overlmt_selfpay"] = "" inputData["preselfpay_amt"] = "" inputData["inscp_amt"] = "" inputDatas = append(inputDatas, inputData) } input["fsiOwnpayPatnFeeListDDTO"] = inputDatas 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 + "4201A" } //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"] = "0" 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 index, 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"] = index // 收费批次号 feedetailInfo["diag_code"] = item.DiagCode // 病种编码 feedetailInfo["diag_name"] = item.DiagName // 处方号 feedetailInfo["diag_dept"] = "" feedetailInfo["diag_dr_code"] = "" feedetailInfo["diag_dr_name"] = "" feedetailInfo["diag_time"] = "" feedetailInfo["vali_flag"] = "1" feedetail = append(feedetail, feedetailInfo) } input["ownPayPatnDiagListD"] = feedetail input["ownPayPatnMdtrtD"] = 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 + "4202" } //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(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, fixmedins_mdtrt_id 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"] = fixmedins_mdtrt_id // 开始时间 inputData["fixmedins_code"] = fixmedins_code // 开始时间 inputData["cplt_flag"] = "1" // 人员姓名 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 + "4203" } //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(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, struct4202 models.Struct4202, struct4201A models.Struct4201A) (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"] = 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["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) for index, item := range struct4202.ODiagListD { diagInfo := make(map[string]interface{}) diagInfo["diag_type"] = item.DiagType // 就诊 ID(来自2201接口返回) diagInfo["diag_srt_no"] = index // 收费批次号 diagInfo["diag_code"] = item.DiagCode // 病种编码 diagInfo["diag_name"] = item.DiagName // 处方号 diagInfo["diag_dept"] = "血透" diagInfo["diag_dr_code"] = item.DiagDrCode diagInfo["diag_dr_name"] = item.DiagDrName diagInfo["diag_time"] = item.DiagTime diagInfo["vali_flag"] = "1" diagInfos = append(diagInfos, diagInfo) } inputData["diseinfo"] = diagInfos feedetail := make([]map[string]interface{}, 0) for _, item := range struct4201A.Fopfd { inputData := make(map[string]interface{}) inputData["fixmedins_mdtrt_id"] = item.FixmedinsMdtrtID inputData["med_type"] = item.MedType inputData["bkkp_sn"] = item.BkkpSn inputData["fee_ocur_time"] = item.FeeOcurTime inputData["fixmedins_code"] = item.FixmedinsCode inputData["fixmedins_name"] = item.FixmedinsName inputData["cnt"] = item.Cnt inputData["pric"] = item.Pric inputData["det_item_fee_sumamt"] = item.DetItemFeeSumamt inputData["medins_list_name"] = item.MedinsListName inputData["medins_list_code"] = item.MedinsListCodg inputData["med_chrgitm_type"] = item.MedChrgitmType inputData["prodname"] = item.Prodname inputData["bilg_dept_codg"] = item.BilgDeptCodg inputData["bilg_dept_name"] = item.BilgDeptName inputData["bilg_dr_code"] = item.BilgDrCode inputData["bilg_dr_name"] = item.BilgDrName 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"] = item.Memo inputData["fulamt_ownpay_amt"] = "" inputData["overlmt_selfpay"] = "" inputData["preselfpay_amt"] = "" inputData["inscp_amt"] = "" inputData["rxno"] = "" feedetail = append(feedetail, inputData) } 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 + "4205" } //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(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key 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(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, struct4207 models.Struct4207) (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"] = struct4207.FixmedinsMdtrtID // 开始时间 inputData["fixmedins_code"] = struct4207.FixmedinsCode // 人员姓名 inputData["page_num"] = struct4207.PageNum // 人员姓名 inputData["page_size"] = struct4207.PageSize // 人员姓名 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 + "4207" } //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(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, struct4208 models.Struct4208) (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"] = struct4208.PsnCertType // 开始时间 inputData["certno"] = struct4208.Certno // 人员姓名 inputData["psn_name"] = struct4208.PsnName // 人员姓名 inputData["begintime"] = struct4208.Begntime // 人员姓名 inputData["endtime"] = struct4208.Endtime // 人员姓名 inputData["med_type"] = struct4208.MedType // 人员姓名 inputData["medfee_sumamt"] = struct4208.MedfeeSumamt // 人员姓名 inputData["elec_billno_code"] = struct4208.ElecBillnoCode // 人员姓名 inputData["page_num"] = struct4208.PageNum // 人员姓名 inputData["page_size"] = struct4208.PageSize // 人员姓名 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(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, struct4209 models.Struct4209) (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"] = struct4209.FixmedinsMdtrtID // 开始时间 inputData["fixmedins_code"] = struct4209.FixmedinsCode // 人员姓名 inputData["page_num"] = struct4209.PageNum // 人员姓名 inputData["page_size"] = struct4209.PageSize // 人员姓名 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 }