package service import ( "bytes" "crypto/sha256" "encoding/hex" "encoding/json" "fmt" "gdyb/models" "github.com/astaxie/beego" "github.com/google/uuid" "io/ioutil" "net/http" "os/exec" "strconv" "time" ) //机构信息 func HeBeiyb1201(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 { // 生成签名 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"] = "1201" // 交易编码 inputData["fixmedins_type"] = "1" inputData["fixmedins_name"] = org_name inputData["fixmedins_code"] = fixmedins_code input["medinsinfo"] = inputData inputMessage["input"] = input //交易输入 bytesData, err := json.Marshal(inputMessage) 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") url := gdyb_url + "1201" 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)) str2 := string(respBytes) return str2 } // 人员基本信息 func HeBeiyb1101(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"] = "1101" // 交易编码 if certificates == "3" { inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型 inputData["certno"] = certNo // 证件号码 inputData["psn_cert_type"] = "" // 人员证件类型 inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号 } else { if id_card_type == 1 { inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型 inputData["card_sn"] = card_sn // 卡识别码 inputData["certno"] = certNo // 证件号码 inputData["psn_cert_type"] = "" // 人员证件类型 inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号 } else { inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型 inputData["card_sn"] = "" // 卡识别码 inputData["certno"] = certNo // 证件号码 inputData["psn_cert_type"] = "" // 人员证件类型 inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号 } } inputData["begntime"] = "" // 开始时间 inputData["psn_name"] = "" // 人员姓名 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 = "http://test.inner.getway.ylbzj.hebei.gov.cn/ebus/mbs_fsi_auth" + "/fsi/api/fsiPsnInfoService/queryPsnInfo" //url = gdyb_url + "/fsi/api/fsiPsnInfoService/queryPsnInfo" } fmt.Println(url) //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 HeBeiyb1101A(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, name 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"] = "1101" // 交易编码 inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型 inputData["card_sn"] = "" // 卡识别码 inputData["certno"] = certNo // 证件号码 inputData["psn_cert_type"] = "1" // 人员证件类型 inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号 inputData["begntime"] = "" // 开始时间 inputData["psn_name"] = name // 人员姓名 input["data"] = inputData inputMessage["input"] = input //交易输入 bytesData, err := json.Marshal(inputMessage) 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_api/prd/hsa/hgs/1101" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101" if insuplc_admdvs == "421300" { var json2 string cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101A", string(bytesData), json2) out, err := cmd.Output() if err != nil { fmt.Println("error:", err.Error()) } fmt.Println(string(out)) return hex.EncodeToString(out) } else { 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 } } // 门诊挂号 func HeBeiyb2201(psnNo string, insutype string, certNo string, org_name string, opera string, ipt_otp_no string, dept string, fixmedins_code string, dept_code string, doctor_id string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, doctor_name string) (string, string) { fmt.Println(opera) // 生成签名 nonce := GetRandomString(32) timestamp := time.Now().Unix() signature := setSignature(timestamp, nonce, secret_key) tempTime := time.Unix(timestamp, 0) timeFormatOne := tempTime.Format("2006-01-02 15:04:05") // 生成输入报文 inputMessage := SetInputMessage(nonce, timestamp, org_name, opera, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs) input := make(map[string]interface{}) inputData := make(map[string]interface{}) inputMessage["infno"] = "2201" // 交易编码 inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回) inputData["insutype"] = insutype // 险种类型(来自1101接口返回) inputData["begntime"] = timeFormatOne // 开始时间 if id_card_type == 1 { inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型 inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号 } else { inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型 inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号 } inputData["ipt_otp_no"] = ipt_otp_no // 住院/门诊号 inputData["atddr_no"] = doctor_id // 医师编码 inputData["dr_name"] = doctor_name // 医师姓名 inputData["dept_code"] = dept_code // 科室编码 inputData["dept_name"] = dept // 科室名称 inputData["caty"] = "A03.06" // 科别 input["data"] = inputData inputMessage["input"] = input //交易输入 var requestLog string bytesData, err := json.Marshal(inputMessage) requestLog = string(bytesData) fmt.Println(string(bytesData)) if err != nil { fmt.Println(err.Error()) return err.Error(), "" } reader := bytes.NewReader(bytesData) //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2201" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2201" 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 + "/fsi/api/outpatientDocInfoService/outpatientRregistration" } if insuplc_admdvs == "421300" { var json2 string cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2201", string(bytesData), json2) out, err := cmd.Output() if err != nil { fmt.Println("error:", err.Error()) } fmt.Println(string(out)) return hex.EncodeToString(out), requestLog } else { 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(), "" } str := string(respBytes) fmt.Println(str) return str, requestLog } //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2201" } func HeBeiyb2201A(psnNo string, insutype string, certNo string, org_name string, opera string, ipt_otp_no string, dept string, fixmedins_code string, dept_code string, doctor_id string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, doctor_name string, record_time string, token string) (string, string) { fmt.Println(opera) // 生成签名 nonce := GetRandomString(32) timestamp := time.Now().Unix() signature := setSignature(timestamp, nonce, secret_key) //tempTime := time.Unix(timestamp, 0) //timeFormatOne := tempTime.Format("2006-01-02 15:04:05") // 生成输入报文 inputMessage := SetInputMessage(nonce, timestamp, org_name, opera, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs) input := make(map[string]interface{}) inputData := make(map[string]interface{}) inputMessage["infno"] = "2201" // 交易编码 inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回) inputData["insutype"] = insutype // 险种类型(来自1101接口返回) inputData["begntime"] = record_time // 开始时间 if id_card_type == 1 { inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型 inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号 } else if id_card_type == 4 { inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型 inputData["mdtrt_cert_no"] = token // 就诊凭证编号 } else { inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型 inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号 } inputData["ipt_otp_no"] = ipt_otp_no // 住院/门诊号 inputData["atddr_no"] = doctor_id // 医师编码 inputData["dr_name"] = doctor_name // 医师姓名 inputData["dept_code"] = dept_code // 科室编码 inputData["dept_name"] = dept // 科室名称 inputData["caty"] = "A03.06" // 科别 input["data"] = inputData inputMessage["input"] = input //交易输入 var requestLog string bytesData, err := json.Marshal(inputMessage) requestLog = string(bytesData) fmt.Println(string(bytesData)) if err != nil { fmt.Println(err.Error()) return err.Error(), "" } reader := bytes.NewReader(bytesData) //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2201" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2201" 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 + "2201" } if insuplc_admdvs == "421300" { var json2 string cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2201", string(bytesData), json2) out, err := cmd.Output() if err != nil { fmt.Println("error:", err.Error()) } fmt.Println(string(out)) return hex.EncodeToString(out), requestLog } else { 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(), "" } str := string(respBytes) fmt.Println(str) return str, requestLog } //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2201" } // 门诊挂号撤销 func HeBeiyb2202(psnNo string, mdtrtId string, ipt_otp_no string, org_name string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, fixmedins_code 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"] = "2202" // 交易编码 inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回) inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回) inputData["ipt_otp_no"] = ipt_otp_no // 住院/门诊号 input["data"] = inputData inputMessage["input"] = input //交易输入 var requestLog string bytesData, err := json.Marshal(inputMessage) fmt.Println(string(bytesData)) requestLog = 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 + "2202" } //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2202" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2202" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2202" if insuplc_admdvs == "421300" { var json2 string cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2202", string(bytesData), json2) out, err := cmd.Output() if err != nil { fmt.Println("error:", err.Error()) } fmt.Println(string(out)) return hex.EncodeToString(out), requestLog } else { 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(), "" } str := string(respBytes) fmt.Println(str) return str, requestLog } } // 门诊就诊信息上传 func HeBeiyb2203(psnNo string, mdtrtId string, doctor string, department string, org_name string, med_type string, doctor_id string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, sick_code string, sick_name string, dept string, config []*models.HisXtDiagnoseConfig, begin_time string) (string, string) { // 生成签名 nonce := GetRandomString(32) timestamp := time.Now().Unix() signature := setSignature(timestamp, nonce, secret_key) //tempTime := time.Unix(timestamp, 0) //timeFormatOne := tempTime.Format("2006-01-02 15:04:05") // 生成输入报文 inputMessage := SetInputMessage(nonce, timestamp, org_name, dept, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs) input := make(map[string]interface{}) inputData := make(map[string]interface{}) diseinfo := make([]map[string]interface{}, 0) if med_type == "1111" || med_type == "1112" { med_type = "11" } inputMessage["infno"] = "2203" // 交易编码 inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回) inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回) inputData["med_type"] = med_type // 医疗类别 16门诊特殊病 inputData["begntime"] = begin_time // 开始时间 //inputData["begntime"] = // 开始时间 inputData["main_cond_dscr"] = "" // 主要病情描述 inputData["dise_codg"] = sick_code // 病种编码 inputData["dise_name"] = sick_name // 病种名称 inputData["birctrl_type"] = "" // 计划生育手术类别 inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期 for index, item := range config { diseinfo_sun := make(map[string]interface{}) diseinfo_sun["diag_type"] = "1" // 诊断类别 diseinfo_sun["diag_srt_no"] = index // 诊断排序号 diseinfo_sun["diag_code"] = item.CountryCode // 诊断代码 diseinfo_sun["diag_name"] = item.ClassName // 诊断名称 diseinfo_sun["diag_dept"] = department // 诊断科室 diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码 diseinfo_sun["dise_dor_name"] = doctor // 诊断医生姓名 diseinfo_sun["diag_time"] = begin_time // 诊断时间 diseinfo_sun["vali_flag"] = "1" // 有效标志 diseinfo = append(diseinfo, diseinfo_sun) } input["diseinfo"] = diseinfo input["mdtrtinfo"] = inputData inputMessage["input"] = input //交易输入 var requestLog string bytesData, err := json.Marshal(inputMessage) fmt.Println(string(bytesData)) requestLog = 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 + "2203" } if insuplc_admdvs == "421300" { var json2 string cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2203", string(bytesData), json2) out, err := cmd.Output() if err != nil { fmt.Println("error:", err.Error()) } fmt.Println(string(out)) return hex.EncodeToString(out), requestLog } else { 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(), "" } str := string(respBytes) fmt.Println(str) return str, requestLog } //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2203" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203" } // 门诊就诊信息上传 func HeBeiyb2203A(psnNo string, mdtrtId string, doctor string, department string, org_name string, med_type string, doctor_id string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, sick_code string, sick_name string, dept string, config []*models.HisXtDiagnoseConfig, begin_time string) (string, string) { // 生成签名 nonce := GetRandomString(32) timestamp := time.Now().Unix() signature := setSignature(timestamp, nonce, secret_key) tempTime := time.Unix(timestamp, 0) timeFormatOne := tempTime.Format("2006-01-02 15:04:05") // 生成输入报文 inputMessage := SetInputMessage(nonce, timestamp, org_name, dept, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs) input := make(map[string]interface{}) inputData := make(map[string]interface{}) diseinfo := make([]map[string]interface{}, 0) if med_type == "1111" || med_type == "1112" { med_type = "11" } inputMessage["infno"] = "2203A" // 交易编码 inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回) inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回) inputData["med_type"] = med_type // 医疗类别 16门诊特殊病 inputData["begntime"] = begin_time // 开始时间 inputData["main_cond_dscr"] = "" // 主要病情描述 inputData["dise_codg"] = sick_code // 病种编码 inputData["dise_name"] = sick_name // 病种名称 inputData["birctrl_type"] = "" // 计划生育手术类别 inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期 inputData["matn_type"] = "" // 生育类别 inputData["geso_val"] = "" // 孕周数 for index, item := range config { diseinfo_sun := make(map[string]interface{}) diseinfo_sun["diag_type"] = "1" // 诊断类别 diseinfo_sun["diag_srt_no"] = index // 诊断排序号 diseinfo_sun["diag_code"] = item.CountryCode // 诊断代码 diseinfo_sun["diag_name"] = item.ClassName // 诊断名称 diseinfo_sun["diag_dept"] = department // 诊断科室 diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码 diseinfo_sun["dise_dor_name"] = doctor // 诊断医生姓名 diseinfo_sun["diag_time"] = timeFormatOne // 诊断时间 diseinfo_sun["vali_flag"] = "1" // 有效标志 diseinfo = append(diseinfo, diseinfo_sun) } input["diseinfo"] = diseinfo input["mdtrtinfo"] = inputData inputMessage["input"] = input //交易输入 var requestLog string bytesData, err := json.Marshal(inputMessage) fmt.Println(string(bytesData)) requestLog = 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 + "2203A" } if insuplc_admdvs == "421300" { var json2 string cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2203A", string(bytesData), json2) out, err := cmd.Output() if err != nil { fmt.Println("error:", err.Error()) } fmt.Println(string(out)) return hex.EncodeToString(out), requestLog } else { 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(), "" } str := string(respBytes) fmt.Println(str) return str, requestLog } //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2203A" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203" } // 门诊费用明细信息上传 func HeBeiyb2204(psnNo string, mdtrtId string, hisPrescription []*models.HisPrescription, chrg_bchno string, org_name string, doctor string, dept string, fixmedins_code string, dept_code string, doctor_id string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, balance_accounts_type string, new_doctor_id int64, diag_code string) (string, string) { // 生成签名 nonce := GetRandomString(32) timestamp := time.Now().Unix() signature := setSignature(timestamp, nonce, secret_key) //tempTime := time.Unix(timestamp, 0) //timeFormat := tempTime.Format("20060102150405") //timeFormatOne := tempTime.Format("2006-01-02 15:04:05") //chrgBchno := rand.Intn(100000) + 10000 var customs []*Custom for _, item := range hisPrescription { role, _ := GetAdminUserInfoByID(item.UserOrgId, new_doctor_id) tm := time.Unix(item.PreTime, 0) if item.Type == 1 { //药品 for _, subItem := range item.HisDoctorAdviceInfo { if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 && subItem.BaseDrugLib.IsUser != 1 { //var randNum int //randNum = rand.Intn(10000) + 1000 role, _ := GetAdminUserInfoByID(item.UserOrgId, new_doctor_id) cus := &Custom{ DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber), Cut: fmt.Sprintf("%.4f", subItem.PrescribingNumber), FeedetlSn: subItem.FeedetlSn, Price: fmt.Sprintf("%.4f", subItem.Price), MedListCodg: subItem.BaseDrugLib.MedicalInsuranceNumber, HospApprFlag: subItem.HospApprFlag, DoctorNumber: role.DoctorNumber, DoctorName: role.UserName, FeeOcurTime: tm.Format("2006-01-02 15:04:05"), } customs = append(customs, cus) } } } if item.Type == 2 { //项目 for _, subItem := range item.HisPrescriptionProject { //var randNum int //randNum = rand.Intn(10000) + 1000 if subItem.Type == 2 { if len(subItem.HisProject.MedicalCode) > 0 { cnt, _ := strconv.ParseFloat(subItem.Count, 64) cus := &Custom{ DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt), Cut: fmt.Sprintf("%.4f", cnt), FeedetlSn: subItem.FeedetlSn, Price: fmt.Sprintf("%.4f", float64(subItem.Price)), MedListCodg: subItem.HisProject.MedicalCode, DoctorNumber: role.DoctorNumber, DoctorName: role.UserName, HospApprFlag: -1, FeeOcurTime: tm.Format("2006-01-02 15:04:05"), } customs = append(customs, cus) } } else if subItem.Type == 3 { if len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 { cnt, _ := strconv.ParseFloat(subItem.Count, 64) cus := &Custom{ DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt), Cut: fmt.Sprintf("%.4f", cnt), FeedetlSn: subItem.FeedetlSn, Price: fmt.Sprintf("%.4f", float64(subItem.Price)), MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber, HospApprFlag: -1, DoctorNumber: role.DoctorNumber, DoctorName: role.UserName, FeeOcurTime: tm.Format("2006-01-02 15:04:05"), } customs = append(customs, cus) } } } } for _, subItem := range item.HisAdditionalCharge { if len(subItem.XtHisAddtionConfig.Code) > 0 { cus := &Custom{ DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*float64(subItem.Count)), Cut: fmt.Sprintf("%.4f", float64(subItem.Count)), FeedetlSn: subItem.FeedetlSn, Price: fmt.Sprintf("%.4f", float64(subItem.Price)), MedListCodg: subItem.XtHisAddtionConfig.Code, HospApprFlag: -1, DoctorNumber: role.DoctorNumber, DoctorName: role.UserName, } customs = append(customs, cus) } } } // 生成输入报文 inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs) input := make(map[string]interface{}) feedetail := make([]map[string]interface{}, 0) inputMessage["infno"] = "2204" // 交易编码 //chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) for _, item := range customs { feedetailInfo := make(map[string]interface{}) feedetailInfo["feedetl_sn"] = item.FeedetlSn feedetailInfo["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回) feedetailInfo["psn_no"] = psnNo // 人员编号 (来自1101接口返回) feedetailInfo["chrg_bchno"] = chrg_bchno // 收费批次号 feedetailInfo["dise_codg"] = diag_code // 病种编码 feedetailInfo["rxno"] = "" // 处方号 feedetailInfo["rx_circ_flag"] = "0" // 外购处方标志 feedetailInfo["fee_ocur_time"] = item.FeeOcurTime // 费用发生时间 feedetailInfo["med_list_codg"] = item.MedListCodg // 医疗目录编码 feedetailInfo["medins_list_codg"] = fixmedins_code // 医药机构目录编码 feedetailInfo["det_item_fee_sumamt"] = item.DetItemFeeSumamt // 明细项目费用总额 feedetailInfo["cnt"] = item.Cut // 数量 feedetailInfo["pric"] = item.Price // 单价 feedetailInfo["sin_dos_dscr"] = "" // 单次剂量描述 feedetailInfo["used_frqu_dscr"] = "" // 使用频次描述 feedetailInfo["prd_days"] = "0" // 周期天数 feedetailInfo["medc_way_dscr"] = "" // 用药途径描述 feedetailInfo["bilg_dept_codg"] = dept_code // 开单科室编码 feedetailInfo["bilg_dept_name"] = dept // 开单科室名称 feedetailInfo["bilg_dr_codg"] = item.DoctorNumber // 开单医生编码 feedetailInfo["bilg_dr_name"] = item.DoctorName // 开单医师姓名 feedetailInfo["acord_dept_codg"] = "" // 受单科室编码 feedetailInfo["acord_dept_name"] = "" // 受单科室名称 feedetailInfo["orders_dr_code"] = item.DoctorNumber // 受单医生编码 feedetailInfo["orders_dr_name"] = item.DoctorName // 受单医生姓名 if balance_accounts_type == "8" { feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志 } else { if item.HospApprFlag != -1 { if item.HospApprFlag == 1 { feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志 } else if item.HospApprFlag == 2 { feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志 } else if item.HospApprFlag == 3 { feedetailInfo["hosp_appr_flag"] = "0" // 医院审批标志 } else { feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志 } } else { feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志 } } //feedetailInfo["tcmdrug_used_way"] = "" // 中药使用方式 feedetailInfo["etip_flag"] = "" // 外检标志 feedetailInfo["etip_hosp_code"] = "" // 外检医院编码 feedetailInfo["dscg_tkdrug_flag"] = "" // 出院带药标志 feedetailInfo["matn_fee_flag"] = "" // 生育费用标志 feedetail = append(feedetail, feedetailInfo) } input["feedetail"] = feedetail inputMessage["input"] = input //交易输入 var requestLog string bytesData, err := json.Marshal(inputMessage) fmt.Println("----------") fmt.Println(string(bytesData)) fmt.Println("----------") requestLog = string(bytesData) if err != nil { fmt.Println(err.Error()) return "", "" } reader := bytes.NewReader(bytesData) gdyb_url := beego.AppConfig.String("gdyb_url") gdyb_paasid := beego.AppConfig.String("gdyb_paasid") //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101" var url string if fixmedins_code == "H15049901371" { url = gdyb_url } else { url = gdyb_url + "2204" } //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2204" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2204" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2204" if insuplc_admdvs == "421300" { var json2 string cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2204", string(bytesData), json2) out, err := cmd.Output() if err != nil { fmt.Println("error:", err.Error()) } fmt.Println(string(out)) return hex.EncodeToString(out), requestLog } else { request, err := http.NewRequest("POST", url, reader) if err != nil { fmt.Println(err.Error()) return "", "" } 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 "", "" } respBytes, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err.Error()) return "", "" } return string(respBytes), requestLog } //var result RequestResult //json.Unmarshal(respBytes, &result) //return &result } // 门诊费用明细信息撤销 func HeBeiyb2205(psnNo string, mdtrtId string, chrgBchno string, org_name string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, fixmedins_code 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"] = "2205" // 交易编码 inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回) inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的) inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回) input["data"] = inputData inputMessage["input"] = input //交易输入 bytesData, err := json.Marshal(inputMessage) fmt.Println(string(bytesData)) var requestLog string requestLog = 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") //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101" //url := gdyb_url + "2205" var url string if fixmedins_code == "H15049901371" { url = gdyb_url } else { url = gdyb_url + "2205" } //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2205" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2205" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2205" if insuplc_admdvs == "421300" { var json2 string cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2205", string(bytesData), json2) out, err := cmd.Output() if err != nil { fmt.Println("error:", err.Error()) } fmt.Println(string(out)) return hex.EncodeToString(out), requestLog } else { request, err := http.NewRequest("POST", url, reader) fmt.Println(err) fmt.Println(request) 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(), "" } str := string(respBytes) fmt.Println(str) return str, requestLog } } // 门诊预结算 //func Gdyb2206(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string, total string, org_name string, doctor string, secret_key string) string { func HeBeiyb2206(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) { // 生成签名 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"] = "2206" // 交易编码 inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回) if certificates == 3 { inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型 inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号 } else { if id_card_type == 1 { inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型 inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号 } else if id_card_type == 4 { inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型 inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号 } else { inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型 inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号 } } if insuplc_admdvs == "421300" { if med_type == "11" || med_type == "1112" || med_type == "1111" { inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号 } else if med_type == "14" { inputData["med_type"] = "14" // 医疗类别 11 普通门诊 12 门诊挂号 } } else { inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号 } inputData["medfee_sumamt"] = total // 医疗费总额 inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算 inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回) inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的) inputData["acct_used_flag"] = "0" // 个人账户使用标志 0否 1是 inputData["insutype"] = insutype // 险种类型 inputData["invono"] = "" // 发票号 input["data"] = inputData inputMessage["input"] = input //交易输入 var requestLog string bytesData, err := json.Marshal(inputMessage) requestLog = 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") //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101" //url := gdyb_url + "2206" var url string if fixmedins_code == "H15049901371" { url = gdyb_url } else { url = gdyb_url + "2206" } //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2206" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2206" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2206" if insuplc_admdvs == "421300" { var json2 string cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2206", string(bytesData), json2) out, err := cmd.Output() if err != nil { fmt.Println("error:", err.Error()) } fmt.Println(string(out)) return hex.EncodeToString(out), requestLog } else { 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(), "" } str := string(respBytes) fmt.Println(str) return str, requestLog } } // 门诊结算 func HeBeiyb2207(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, acct_used_flag string, token 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"] = "2207" // 交易编码 inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回) if certificates == 3 { inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型 inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号 } else { if id_card_type == 1 { inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型 inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号 } else if id_card_type == 4 { inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型 inputData["mdtrt_cert_no"] = token // 就诊凭证编号 } else { inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型 inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号 } } if med_type == "1111" || med_type == "1112" { med_type = "11" } if insuplc_admdvs == "421300" { if med_type == "11" { inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号 } else if med_type == "14" { inputData["med_type"] = "14" // 医疗类别 11 普通门诊 12 门诊挂号 } } else { inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号 } inputData["medfee_sumamt"] = total // 医疗费总额 inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算 inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回) inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的) inputData["acct_used_flag"] = acct_used_flag // 个人账户使用标志 0否 1是 inputData["insutype"] = insutype // 险种类型 inputData["invono"] = "" // 发票号 inputData["fulamt_ownpay_amt"] = fulamt_ownpay_amt // inputData["overlmt_selfpay"] = overlmt_selfpay // inputData["preselfpay_amt"] = preselfpay_amt // inputData["inscp_scp_amt"] = inscp_scp_amt // input["data"] = inputData inputMessage["input"] = input //交易输入 bytesData, err := json.Marshal(inputMessage) 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") //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101" //url := gdyb_url + "2207" var url string if fixmedins_code == "H15049901371" { url = gdyb_url } else { url = gdyb_url + "2207" } //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2207" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207" if insuplc_admdvs == "421300" { var json2 string cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2207", string(bytesData), json2) out, err := cmd.Output() if err != nil { fmt.Println("error:", err.Error()) } mjson, _ := json.Marshal(inputMessage) str2 := string(mjson) fmt.Println(string(out)) return hex.EncodeToString(out), str2 } else { 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(), "" } str := string(respBytes) fmt.Println(str) mjson, _ := json.Marshal(inputMessage) str2 := string(mjson) return str, str2 } } func HeBeiyb2207A(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, acct_used_flag 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"] = "2207A" // 交易编码 inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回) if certificates == 3 { inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型 inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号 } else { if id_card_type == 1 { inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型 inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号 } else { inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型 inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号 } } if med_type == "1111" || med_type == "1112" { med_type = "11" } if insuplc_admdvs == "421300" { if med_type == "11" { inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号 } else if med_type == "14" { inputData["med_type"] = "14" // 医疗类别 11 普通门诊 12 门诊挂号 } } else { inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号 } inputData["medfee_sumamt"] = total // 医疗费总额 inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算 inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回) inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的) inputData["acct_used_flag"] = acct_used_flag // 个人账户使用标志 0否 1是 inputData["insutype"] = insutype // 险种类型 inputData["invono"] = "" // 发票号 inputData["fulamt_ownpay_amt"] = fulamt_ownpay_amt // inputData["overlmt_selfpay"] = overlmt_selfpay // inputData["preselfpay_amt"] = preselfpay_amt // inputData["inscp_scp_amt"] = inscp_scp_amt // input["data"] = inputData inputMessage["input"] = input //交易输入 bytesData, err := json.Marshal(inputMessage) 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") //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101" //url := gdyb_url + "2207" var url string if fixmedins_code == "H15049901371" { url = gdyb_url } else { url = gdyb_url + "2207" } //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2207" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207" if insuplc_admdvs == "421300" { var json2 string cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2207", string(bytesData), json2) out, err := cmd.Output() if err != nil { fmt.Println("error:", err.Error()) } mjson, _ := json.Marshal(inputMessage) str2 := string(mjson) fmt.Println(string(out)) return hex.EncodeToString(out), str2 } else { 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(), "" } str := string(respBytes) fmt.Println(str) mjson, _ := json.Marshal(inputMessage) str2 := string(mjson) return str, str2 } } // 门诊结算撤销 func HeBeiyb2208(psnNo string, mdtrtId string, setlId string, org_name string, doctor string, secret_key string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs 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"] = "2208" // 交易编码 inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回) inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回) inputData["setl_id"] = setlId // 结算 ID input["data"] = inputData inputMessage["input"] = input //交易输入 bytesData, err := json.Marshal(inputMessage) 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") //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101" //url := gdyb_url + "2208" var url string if fixmedins_code == "H15049901371" { url = gdyb_url } else { url = gdyb_url + "2208" } //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2208" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2208" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2208" if insuplc_admdvs == "421300" { var json2 string cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2208", string(bytesData), json2) out, err := cmd.Output() if err != nil { fmt.Println("error:", err.Error()) } mjson, _ := json.Marshal(inputMessage) str2 := string(mjson) fmt.Println(string(out)) return hex.EncodeToString(out), str2 } else { 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(), "" } str := string(respBytes) fmt.Println(str) mjson, _ := json.Marshal(inputMessage) str2 := string(mjson) return str, str2 } } //确认订单 func HeBeiyb6201(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, order models.HisOrder) 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"] = "6201" // 交易编码 inputData["mdtrt_id"] = order.MdtrtId inputData["chrg_bchno"] = order.Number inputData["psn_no"] = order.PsnNo inputData["psn_name"] = order.PsnName inputData["psn_cert_type"] = order.PsnCertType inputData["certno"] = order.Certno inputData["insutype"] = order.Insutype inputData["med_type"] = order.MedType inputData["medfee_sumamt"] = order.MedfeeSumamt inputData["fulamt_ownpay_amt"] = order.FulamtOwnpayAmt inputData["overlmt_selfpay"] = order.OverlmtSelfPay inputData["preselfpay_amt"] = order.PreselfpayAmt inputData["inscp_scp_amt"] = order.InscpScpAmt inputData["act_pay_dedc"] = order.ActPayDedc inputData["hifp_pay"] = order.HifpPay inputData["pool_prop_selfpay"] = order.PoolPropSelfpay inputData["cvlserv_pay"] = order.CvlservPay inputData["hifes_pay"] = order.HifesPay inputData["hifmi_pay"] = order.HifmiPay inputData["hifob_pay"] = order.HifobPay inputData["maf_pay"] = order.MafPay inputData["oth_pay"] = order.OthPay inputData["fund_pay_sumamt"] = order.FundPaySumamt inputData["psn_part_amt"] = order.PsnPartAmt inputData["acct_pay"] = order.AcctPay inputData["psn_cash_pay"] = order.PsnCashPay inputData["hosp_part_amt"] = order.HospPartAmt inputData["acct_mulaid_pay"] = order.AcctMulaidPay input["data"] = inputData inputMessage["input"] = input //交易输入 bytesData, err := json.Marshal(inputMessage) 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") //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101" url := gdyb_url + "6201" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/6201" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/6201" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207" 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() } str := string(respBytes) fmt.Println(str) return str } // 医药机构费用结算对总账 func Gdyb3201( org_name string, doctor string, secret_key string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) string { func HeBeiyb3201(baseParams models.BaseParams, businessParams models.BusinessParams) string { fmt.Println("11222333-----") fmt.Println(baseParams) fmt.Println(businessParams) // 生成签名 nonce := GetRandomString(32) timestamp := time.Now().Unix() signature := setSignature(timestamp, nonce, baseParams.SecretKey) // 生成输入报文 inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs) input := make(map[string]interface{}) inputData := make(map[string]interface{}) inputMessage["infno"] = "3201" // 交易编码 inputData["insutype"] = businessParams.Insutype // 险种 inputData["clr_type"] = businessParams.ClrType // 就诊 ID(来自2201接口返回) inputData["setl_optins"] = businessParams.SetlOptins // 结算经办机构 inputData["stmt_begndate"] = businessParams.StmtBegndate // 对帐开始时间 inputData["stmt_enddate"] = businessParams.StmtEnddate //对帐结束时间 inputData["medfee_sumamt"] = businessParams.MedfeeSumamt //医疗费总额 inputData["fund_pay_sumamt"] = businessParams.FundPaySumamt //基金支付总额 inputData["acct_pay"] = businessParams.AcctPay //个人账户支付金额 inputData["fixmedins_setl_cnt"] = businessParams.FixmedinsSetlCnt //定点医药机构结算笔数 inputData["refd_setl_flag"] = 0 // 就诊 ID(来自2201接口返回) input["data"] = inputData inputMessage["input"] = input //交易输入 bytesData, err := json.Marshal(inputMessage) 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 baseParams.MdtrtareaAdmvs == "150499" { url = gdyb_url } else { url = gdyb_url + "3201" } //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3201" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3201" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3201" 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() } str := string(respBytes) fmt.Println(str) return str } //文件上传 func HeBeiyb9101(baseParams models.BaseParams, file_name string, file_byte []byte) string { // 生成签名 nonce := GetRandomString(32) timestamp := time.Now().Unix() signature := setSignature(timestamp, nonce, baseParams.SecretKey) //buf := new(bytes.Buffer) //buf.ReadFrom(strings.NewReader(string(file_byte))) inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs) input := make(map[string]interface{}) inputData := make(map[string]interface{}) inputMessage["infno"] = "9101" // 交易编码 inputData["file_name"] = file_name //文件名 inputData["in"] = file_byte //文件数据 inputData["fixmedins_code"] = baseParams.FixmedinsCode //编码 input["fsUploadIn"] = inputData inputMessage["input"] = input //交易输入 bytesData, err := json.Marshal(inputMessage) fmt.Println(string(bytesData)) if err != nil { fmt.Println(err.Error()) return err.Error() } reader := bytes.NewReader(bytesData) //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/9101" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9101" gdyb_url := beego.AppConfig.String("gdyb_url") gdyb_paasid := beego.AppConfig.String("gdyb_paasid") //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101" url := gdyb_url + "9101" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9101" 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() } str := string(respBytes) fmt.Println(str) return str } func HeBeiyb9102(baseParams models.BaseParams, file_name string, file_qury_no string) string { // 生成签名 nonce := GetRandomString(32) timestamp := time.Now().Unix() signature := setSignature(timestamp, nonce, baseParams.SecretKey) inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs) input := make(map[string]interface{}) inputData := make(map[string]interface{}) inputMessage["infno"] = "9102" // 交易编码 inputData["file_name"] = file_name //文件名 inputData["file_qury_no"] = file_qury_no //文件数据 inputData["fixmedins_code"] = baseParams.FixmedinsCode //编码 input["fsDownloadIn"] = inputData inputMessage["input"] = input //交易输入 bytesData, err := json.Marshal(inputMessage) 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") //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101" url := gdyb_url + "9102" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/9102" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9102" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9102" 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() } str := string(respBytes) fmt.Println(str) return str } func HeBeiyb3202(baseParams models.BaseParams, businessParams models.BusinessParams) string { // 生成签名 nonce := GetRandomString(32) timestamp := time.Now().Unix() signature := setSignature(timestamp, nonce, baseParams.SecretKey) // 生成输入报文 inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs) input := make(map[string]interface{}) inputData := make(map[string]interface{}) inputMessage["infno"] = "3202" // 交易编码 inputData["file_qury_no"] = businessParams.FileQuryNo // 险种 inputData["setl_optins"] = baseParams.InsuplcAdmdvs // 结算经办机构 inputData["stmt_begndate"] = businessParams.StmtBegndate // 对帐开始时间 inputData["stmt_enddate"] = businessParams.StmtEnddate //对帐结束时间 inputData["medfee_sumamt"] = businessParams.MedfeeSumamt //医疗费总额 inputData["fund_pay_sumamt"] = businessParams.FundPaySumamt //基金支付总额 inputData["cash_payamt"] = businessParams.CashPayamt //现金支付金额 inputData["fixmedins_setl_cnt"] = businessParams.FixmedinsSetlCnt //定点医药机构结算笔数 inputData["clr_type"] = "11" // 就诊 ID(来自2201接口返回) inputData["refd_setl_flag"] = 1 // 就诊 ID(来自2201接口返回) input["data"] = inputData inputMessage["input"] = input //交易输入 bytesData, err := json.Marshal(inputMessage) 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") //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101" url := gdyb_url + "3202" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3202" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3202" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3202" 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() } str := string(respBytes) fmt.Println(str) return str } func HeBeiyb5203(baseParams models.BaseParams, businessParams models.BusinessParams) string { fmt.Println("~~~~~~1") fmt.Println(baseParams) fmt.Println(businessParams) // 生成签名 nonce := GetRandomString(32) timestamp := time.Now().Unix() signature := setSignature(timestamp, nonce, baseParams.SecretKey) fmt.Println("~~~~~~2") // 生成输入报文 inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs) input := make(map[string]interface{}) inputData := make(map[string]interface{}) inputMessage["infno"] = "5203" // 交易编码 inputData["psn_no"] = businessParams.PsnNo inputData["setl_id"] = businessParams.SetlId inputData["mdtrt_id"] = businessParams.MdtrtId input["data"] = inputData inputMessage["input"] = input //交易输入 bytesData, err := json.Marshal(inputMessage) fmt.Println(string(bytesData)) fmt.Println("~~~~~~") fmt.Println("~~~~~~") 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") //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101" //url := gdyb_url + "5203" var url string if baseParams.FixmedinsCode == "H15049901371" { url = gdyb_url } else { url = gdyb_url + "5203" } //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5203" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203" 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() } str := string(respBytes) fmt.Println(str) return str } func HeBeiyb5204(baseParams models.BaseParams, businessParams models.BusinessParams) string { // 生成签名 nonce := GetRandomString(32) timestamp := time.Now().Unix() signature := setSignature(timestamp, nonce, baseParams.SecretKey) // 生成输入报文 inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs) input := make(map[string]interface{}) inputData := make(map[string]interface{}) inputMessage["infno"] = "5204" // 交易编码 inputData["psn_no"] = businessParams.PsnNo inputData["setl_id"] = businessParams.SetlId inputData["mdtrt_id"] = businessParams.MdtrtId input["data"] = inputData inputMessage["input"] = input //交易输入 bytesData, err := json.Marshal(inputMessage) 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") //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101" //url := gdyb_url + "5203" var url string if baseParams.FixmedinsCode == "H15049901371" { url = gdyb_url } else { url = gdyb_url + "5204" } //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5203" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203" 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() } str := string(respBytes) fmt.Println(str) return str } func HeBeiyb2001(baseParams models.BaseParams, psn_no string, insutype string, med_type string) string { if med_type == "1111" || med_type == "1112" { med_type = "11" } // 生成签名 nonce := GetRandomString(32) timestamp := time.Now().Unix() signature := setSignature(timestamp, nonce, baseParams.SecretKey) // 生成输入报文 inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs) input := make(map[string]interface{}) inputData := make(map[string]interface{}) inputMessage["infno"] = "2001" // 交易编码 inputData["psn_no"] = psn_no inputData["insutype"] = insutype inputData["fixmedins_code"] = baseParams.FixmedinsCode inputData["med_type"] = med_type inputData["begntime"] = "2021-01-01 00:00:00" input["data"] = inputData inputMessage["input"] = input //交易输入 bytesData, err := json.Marshal(inputMessage) fmt.Println(string(bytesData)) if err != nil { fmt.Println(err.Error()) return err.Error() } reader := bytes.NewReader(bytesData) //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3301" gdyb_url := beego.AppConfig.String("gdyb_url") gdyb_paasid := beego.AppConfig.String("gdyb_paasid") //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101" url := gdyb_url //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3301" 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() } str := string(respBytes) fmt.Println(str) return str } func HeBeiyb3301(baseParams *models.BaseParams, name string, codg string, list_type_code string, start_time string, ent_time string, list_type string) string { // 生成签名 nonce := GetRandomString(32) timestamp := time.Now().Unix() signature := setSignature(timestamp, nonce, baseParams.SecretKey) // 生成输入报文 inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs) input := make(map[string]interface{}) inputData := make(map[string]interface{}) inputMessage["infno"] = "3301" // 交易编码 inputData["fixmedins_hilist_id"] = codg inputData["fixmedins_hilist_name"] = name inputData["list_type"] = list_type inputData["med_list_codg"] = codg inputData["begndate"] = start_time inputData["enddate"] = ent_time inputData["aprvno"] = "" inputData["dosform"] = "" inputData["exct_cont"] = "" inputData["item_cont"] = "" inputData["prcunt"] = "" inputData["spec"] = "" inputData["pacspec"] = "" inputData["memo"] = "" input["data"] = inputData inputMessage["input"] = input //交易输入 bytesData, err := json.Marshal(inputMessage) fmt.Println(string(bytesData)) if err != nil { fmt.Println(err.Error()) return err.Error() } reader := bytes.NewReader(bytesData) //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3301" // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3301" gdyb_url := beego.AppConfig.String("gdyb_url") gdyb_paasid := beego.AppConfig.String("gdyb_paasid") //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101" url := gdyb_url + "3301" 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() } str := string(respBytes) fmt.Println(str) return str } func HeBeiyb3302(baseParams *models.BaseParams, name string, codg string, list_type_code string) string { // 生成签名 nonce := GetRandomString(32) timestamp := time.Now().Unix() signature := setSignature(timestamp, nonce, baseParams.SecretKey) // 生成输入报文 inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs) input := make(map[string]interface{}) inputData := make(map[string]interface{}) inputMessage["infno"] = "3302" // 交易编码 inputData["fixmedins_code"] = baseParams.FixmedinsCode inputData["fixmedins_hilist_id"] = codg inputData["list_type"] = list_type_code inputData["med_list_codg"] = codg input["data"] = inputData inputMessage["input"] = input //交易输入 bytesData, err := json.Marshal(inputMessage) fmt.Println(string(bytesData)) if err != nil { fmt.Println(err.Error()) return err.Error() } reader := bytes.NewReader(bytesData) //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3302" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3302" gdyb_url := beego.AppConfig.String("gdyb_url") gdyb_paasid := beego.AppConfig.String("gdyb_paasid") //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101" url := gdyb_url + "3302" 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() } str := string(respBytes) fmt.Println(str) return str } func HeBeiyb2505(psnNo string, doctor string, org_name string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, start_time string, end_time 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"] = "2505" inputData["psn_no"] = psnNo inputData["biz_appy_type"] = "03" inputData["begndate"] = start_time inputData["enddate"] = end_time inputData["fixmedins_code"] = fixmedins_code inputData["fixmedins_name"] = org_name inputData["tel"] = "" inputData["addr"] = "" inputData["agnter_name"] = "" inputData["agnter_cert_type"] = "" inputData["agnter_certno"] = "" inputData["agnter_tel"] = "" inputData["agnter_addr"] = "" inputData["agnter_rlts"] = "" inputData["fix_srt_no"] = "" inputData["memo"] = "" input["data"] = inputData inputMessage["input"] = input //交易输入 bytesData, err := json.Marshal(inputMessage) if err != nil { fmt.Println(err.Error()) return err.Error() } reader := bytes.NewReader(bytesData) //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2505" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2505" gdyb_url := beego.AppConfig.String("gdyb_url") gdyb_paasid := beego.AppConfig.String("gdyb_paasid") //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101" url := gdyb_url + "2505" 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() } str := string(respBytes) fmt.Println(str) return str } func HeBeiyb2506(psnNo string, doctor string, org_name string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, trt_dcla_detl_sn 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"] = "2506" inputData["psn_no"] = psnNo inputData["trt_dcla_detl_sn"] = trt_dcla_detl_sn inputData["memo"] = "" input["data"] = inputData inputMessage["input"] = input //交易输入 bytesData, err := json.Marshal(inputMessage) fmt.Println(string(bytesData)) if err != nil { fmt.Println(err.Error()) return err.Error() } reader := bytes.NewReader(bytesData) //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2506" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2506" gdyb_url := beego.AppConfig.String("gdyb_url") gdyb_paasid := beego.AppConfig.String("gdyb_paasid") //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101" url := gdyb_url + "2506" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203" 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() } str := string(respBytes) fmt.Println(str) return str } func HeBeiyb2503(psnNo string, insutype string, org_name string, doctor string, fixmedins_code string, doctor_id string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, sick_name string, sick_code string, start_time string, end_time string, check_time string) string { // 生成签名 nonce := GetRandomString(32) timestamp := time.Now().Unix() signature := setSignature(timestamp, nonce, secret_key) //tempTime := time.Unix(timestamp, 0) //timeFormatOne := tempTime.Format("2006-01-02 15:04:05") //timeFormatTwo := tempTime.Format("2006-01-02") //t := time.Now() //last := time.Date(t.Year(), time.December, 31, 0, 0, 0, 0, time.UTC) //tm := time.Unix(last.Unix(), 0) // 生成输入报文 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"] = "2503" // 交易编码 inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回) inputData["insutype"] = insutype // 险种类型(来自1101接口返回) inputData["opsp_dise_code"] = sick_code // 险种类型(来自1101接口返回) inputData["opsp_dise_name"] = sick_name // 险种类型(来自1101接口返回) inputData["insu_optins"] = insuplc_admdvs // 险种类型(来自1101接口返回) inputData["ide_fixmedins_no"] = fixmedins_code // 险种类型(来自1101接口返回) inputData["ide_fixmedins_name"] = org_name // 险种类型(来自1101接口返回) inputData["hosp_ide_date"] = check_time // 险种类型(来自1101接口返回) inputData["diag_dr_codg"] = doctor_id // 开始时间 inputData["diag_dr_name"] = doctor // 开始时间 inputData["begndate"] = start_time // 医师编码 inputData["tel"] = "" // 医师编码 inputData["addr"] = "" // 医师编码 inputData["enddate"] = end_time // 医师编码 input["data"] = inputData inputMessage["input"] = input //交易输入 bytesData, err := json.Marshal(inputMessage) fmt.Println(string(bytesData)) if err != nil { fmt.Println(err.Error()) return err.Error() } reader := bytes.NewReader(bytesData) //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2503" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2503" gdyb_url := beego.AppConfig.String("gdyb_url") gdyb_paasid := beego.AppConfig.String("gdyb_paasid") //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101" //url := gdyb_url + "2503" var url string if fixmedins_code == "H15049901371" { url = gdyb_url } else { url = gdyb_url + "2503" } 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() } str := string(respBytes) fmt.Println(str) return str } func HeBeiyb2504(psnNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, trt_dcla_detl_sn 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"] = "2504" // 交易编码 inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回) inputData["trt_dcla_detl_sn"] = trt_dcla_detl_sn // 人员编号 (来自1101接口返回) inputData["memo"] = "撤销备案" // 人员编号 (来自1101接口返回) input["data"] = inputData inputMessage["input"] = input //交易输入 bytesData, err := json.Marshal(inputMessage) fmt.Println(string(bytesData)) if err != nil { fmt.Println(err.Error()) return err.Error() } reader := bytes.NewReader(bytesData) //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2504" //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2504" gdyb_url := beego.AppConfig.String("gdyb_url") gdyb_paasid := beego.AppConfig.String("gdyb_paasid") //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101" url := gdyb_url + "2504" 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() } str := string(respBytes) fmt.Println(str) return str } //func Gdyb2503(psnNo string, doctor string, department string, diag string, org_name string, med_type string, doctor_id int64, fixmedins_code string, diag_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, sick_code string, sick_name string) string { // // 生成签名 // nonce := GetRandomString(32) // timestamp := time.Now().Unix() // signature := setSignature(timestamp, nonce, secret_key) // tempTime := time.Unix(timestamp, 0) // timeFormatOne := tempTime.Format("2006-01-02 15:04:05") // // // 生成输入报文 // inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs) // input := make(map[string]interface{}) // inputData := make(map[string]interface{}) // diseinfo := make([]map[string]interface{}, 0) // // inputMessage["infno"] = "2203" // 交易编码 // inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回) // inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回) // inputData["med_type"] = med_type // 医疗类别 16门诊特殊病 // inputData["begntime"] = timeFormatOne // 开始时间 // inputData["main_cond_dscr"] = "" // 主要病情描述 // inputData["dise_codg"] = sick_code // 病种编码 // inputData["dise_name"] = sick_name // 病种名称 // inputData["birctrl_type"] = "" // 计划生育手术类别 // inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期 // // diseinfo_sun := make(map[string]interface{}) // diseinfo_sun["diag_type"] = "1" // 诊断类别 // diseinfo_sun["diag_srt_no"] = "1" // 诊断排序号 // diseinfo_sun["diag_code"] = diag_code // 诊断代码 // diseinfo_sun["diag_name"] = diag // 诊断名称 // diseinfo_sun["diag_dept"] = department // 诊断科室 // diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码 // diseinfo_sun["dise_dor_name"] = doctor // 诊断医生姓名 // diseinfo_sun["diag_time"] = timeFormatOne // 诊断时间 // diseinfo_sun["vali_flag"] = "1" // 有效标志 // // diseinfo = append(diseinfo, diseinfo_sun) // input["diseinfo"] = diseinfo // input["mdtrtinfo"] = inputData // inputMessage["input"] = input //交易输入 // // bytesData, err := json.Marshal(inputMessage) // fmt.Println(string(bytesData)) // if err != nil { // fmt.Println(err.Error()) // return err.Error() // } // reader := bytes.NewReader(bytesData) // // url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2203" // // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203" // 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", "sg03_prd") // 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() // } // str := string(respBytes) // fmt.Println(str) // return str //} func HeBeiyb5301(psnNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string { // 生成签名 nonce := GetRandomString(32) timestamp := time.Now().Unix() signature := setSignature(timestamp, nonce, secret_key) //tempTime := time.Unix(timestamp, 0) //timeFormatOne := tempTime.Format("2006-01-02 15:04:05") //timeFormatTwo := tempTime.Format("2006-01-02") // 生成输入报文 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"] = "5301" // 交易编码 inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回) input["data"] = inputData inputMessage["input"] = input //交易输入 bytesData, err := json.Marshal(inputMessage) fmt.Println(string(bytesData)) if err != nil { fmt.Println(err.Error()) return err.Error() } reader := bytes.NewReader(bytesData) //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301" gdyb_url := beego.AppConfig.String("gdyb_url") gdyb_paasid := beego.AppConfig.String("gdyb_paasid") //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101" url := gdyb_url + "5301" 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() } str := string(respBytes) fmt.Println(str) return str } func HeBeiyb5301Two(psnNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string { // 生成签名 nonce := GetRandomString(32) timestamp := time.Now().Unix() signature := setSignature(timestamp, nonce, secret_key) //tempTime := time.Unix(timestamp, 0) //timeFormatOne := tempTime.Format("2006-01-02 15:04:05") //timeFormatTwo := tempTime.Format("2006-01-02") // 生成输入报文 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"] = "5301" // 交易编码 inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回) input["data"] = inputData inputMessage["input"] = input //交易输入 bytesData, err := json.Marshal(inputMessage) fmt.Println(string(bytesData)) if err != nil { fmt.Println(err.Error()) return err.Error() } reader := bytes.NewReader(bytesData) //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301" gdyb_url := beego.AppConfig.String("gdyb_url") gdyb_paasid := beego.AppConfig.String("gdyb_paasid") //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101" url := gdyb_url 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() } str := string(respBytes) fmt.Println(str) return str } // func HeBeiyb4101(struct4101 Struct4101, secret_key string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, org_id int64) 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{}) if org_id == 10106 || org_id == 10215 || org_id == 10138 || org_id == 9504 { inputMessage["infno"] = "4101A" // 交易编码 } else { inputMessage["infno"] = "4101A" // 交易编码 } year := time.Now().Format("2006") month := time.Now().Format("01") day := time.Now().Format("02") inputData["mdtrt_id"] = struct4101.MdtrtId // 就诊 ID 必填(来自2201接口返回) inputData["setl_id"] = struct4101.SetlId // 结算 ID 必填 inputData["psn_no"] = struct4101.PsnNo // 结算 ID 必填 inputData["fixmedins_name"] = org_name // 定点医药机构名称 必填 inputData["fixmedins_code"] = fixmedins_code // 定点医药机构编码 必填 inputData["hi_setl_lv"] = "" // 医保结算等级 inputData["hi_no"] = struct4101.PsnNo // 医保编号 inputData["medcasno"] = struct4101.PsnNo // 病案号 必填 inputData["dcla_time"] = year + "-" + month + "-" + day // 申报时间 必填 inputData["psn_name"] = struct4101.PsnName // 人员姓名 必填 inputData["gend"] = struct4101.Gend // 性别 必填 inputData["brdy"] = struct4101.Brdy // 出生日期 必填 inputData["age"] = struct4101.Age // 年龄 必填 inputData["ntly"] = struct4101.Ntly // 国籍 必填 inputData["nwb_age"] = "" // 年龄 必填 inputData["naty"] = struct4101.Naty // 民族 必填 if org_id == 10138 { inputData["dscg_way"] = "9" // 民族 必填 inputData["resp_nurs_code"] = "N441623001432" // 民族 必填 } inputData["patn_cert_type"] = struct4101.PatnCertType // 患者证件类别 必填 inputData["certno"] = struct4101.Certno // 证件号码 必填 inputData["prfs"] = struct4101.Prfs // 职业 必填 inputData["curr_addr"] = "" // 现住址 必填 inputData["emp_name"] = "" // 单位名称 必填 inputData["emp_addr"] = "" // 单位地址 必填 inputData["emp_tel"] = "" // 单位电话 必填 inputData["poscode"] = "" // 邮编 必填 inputData["coner_name"] = struct4101.ConerName // 联系人姓名 必填 inputData["patn_rlts"] = struct4101.PatnRlts // 与患者关系 必填 inputData["coner_addr"] = struct4101.ConerAddr // 联系人地址 必填 inputData["coner_tel"] = struct4101.ConerTel // 联系人电话 必填 inputData["hi_type"] = struct4101.HiType // 医保类型 必填 inputData["insuplc"] = struct4101.Insuplc // 参保地 必填 inputData["sp_psn_type"] = "" // 特殊人员类型 必填 inputData["nwb_adm_type"] = "" // 新生儿入院类型 必填 inputData["nwb_bir_wt"] = "" // 新生儿出生体重 必填 inputData["nwb_adm_wt"] = "" // 新生儿入院体重 必填 inputData["opsp_diag_caty"] = "" // 门诊慢特病诊断 必填 inputData["opsp_mdtrt_date"] = "" // 门诊慢特病就诊日期 必填 inputData["ipt_med_type"] = struct4101.IptMedType // 住院医疗类型 必填 inputData["adm_way"] = "2" // 入院途径 必填 inputData["trt_type"] = "1" // 治疗类别 必填 inputData["adm_time"] = struct4101.AdmTime // 入院时间 必填 inputData["adm_caty"] = struct4101.AdmCaty // 入院科别 必填 inputData["refldept_dept"] = "" // 转科科别 必填 inputData["dscg_time"] = struct4101.AdmEndTime // 出院时间 必填 inputData["dscg_caty"] = struct4101.AdmCaty // 出院科别 必填 inputData["act_ipt_days"] = "" // 实际住院天数 必填 inputData["otp_wm_dise"] = "" // 门(急) 诊西医诊断 必填 inputData["wm_dise_code"] = "" // 门(急) 诊中医诊断 必填 inputData["otp_tcm_dise"] = "" // 西医诊断疾病代码 必填 inputData["tcm_dise_code"] = "" // 中医诊断代码 必填 inputData["oprn_oprt_code_cnt"] = "" // 手术操作代码计数 必填 inputData["vent_used_dura"] = "" // 呼吸机使用时长 必填 inputData["pwcry_bfadm_coma_dura"] = "" // 颅脑损伤患者入院前昏迷时长 必填 inputData["pwcry_afadm_coma_dura"] = "" // 颅脑损伤患者入院后昏迷时长 必填 inputData["bld_cat"] = "" // 输血品种 必填 inputData["bld_amt"] = "" // 输血量 必填 inputData["bld_unt"] = "" // 输血计量单位 必填 inputData["spga_nurscare_days"] = "" // 特级护理天数 必填 inputData["lv1_nurscare_days"] = "" // 一级护理天数 必填 inputData["scd_nurscare_days"] = "" // 二级护理天数 必填 inputData["lv3_nurscare_days"] = "" // 三级护理天数 必填 inputData["acp_medins_name"] = "" // 拟接收机构名称 必填 inputData["acp_optins_code"] = "" // 拟接收机构代码 必填 inputData["bill_code"] = struct4101.BillCode // 票据代码 必填 inputData["bill_no"] = struct4101.BillNo // 票据号码 必填 inputData["biz_sn"] = struct4101.BizSn // 业务流水号 必填 inputData["days_rinp_flag_31"] = "" // 出院 31 天内再住院计划标志 必填 inputData["days_rinp_pup_31"] = "" // 出院 31 天内再住院目的 必填 inputData["chfpdr_name"] = struct4101.DoctorName // 主诊医师姓名 必填 inputData["chfpdr_code"] = struct4101.DoctorCode // 主诊医师代码 必填 inputData["setl_begn_date"] = struct4101.SetlBegnDate // 结算开始日期 必填 inputData["setl_end_date"] = struct4101.SetlEndDate // 结算结束日期 必填 inputData["psn_selfpay"] = struct4101.PsnSelfPay // 个人自付 必填 inputData["psn_ownpay"] = struct4101.PsnOwnPay // 个人自费 必填 inputData["acct_pay"] = struct4101.AcctPay // 个人账户支出 必填 inputData["hi_paymtd"] = struct4101.HiPaymtd // 医保支付方式 必填 inputData["hsorg"] = struct4101.Hsorg // 医保机构 必填 inputData["hsorg_opter"] = struct4101.HsorgOpter // 医保机构经办人 必填 inputData["medins_fill_dept"] = struct4101.MedinsFillDept // 医疗机构填报部门 必填 inputData["medins_fill_psn"] = struct4101.MedinsFillPsn // 医疗机构填报人 必填 inputData["psn_cashpay"] = struct4101.PsnCashpay // 医疗机构填报人 必填 payinfo := make([]map[string]interface{}, 0) // 基金支付信息 for _, item := range struct4101.CustomStruct { payinfotemp := make(map[string]interface{}) if item.FundPayType == "310100" || item.FundPayType == "310200" || item.FundPayType == "320100" || item.FundPayType == "330100" || item.FundPayType == "340100" || item.FundPayType == "350100" || item.FundPayType == "370100" || item.FundPayType == "390100" || item.FundPayType == "610100" || item.FundPayType == "640100" || item.FundPayType == "620100" { payinfotemp["fund_pay_type"] = item.FundPayType // 基金支付类型 必填 payinfotemp["fund_payamt"] = item.FundPayamt // 基金支付金额 payinfo = append(payinfo, payinfotemp) } } opspdiseinfo := make([]map[string]interface{}, 0) // 门诊慢特病诊断信息 opspdiseinfotemp := make(map[string]interface{}) opspdiseinfotemp["diag_name"] = struct4101.OpspdiseinfoStruct[len(struct4101.OpspdiseinfoStruct)-1].DiagName // 诊断名称 必填 opspdiseinfotemp["diag_code"] = struct4101.OpspdiseinfoStruct[len(struct4101.OpspdiseinfoStruct)-1].DiagCode // 诊断代码 必填 opspdiseinfotemp["oprn_oprt_name"] = "血液透析" // 手术操作名称 必填 opspdiseinfotemp["oprn_oprt_code"] = "39.9500" // 手术操作代码 必填 opspdiseinfo = append(opspdiseinfo, opspdiseinfotemp) diseinfo := make([]map[string]interface{}, 0) // 住院诊断信息 for _, item := range struct4101.Diseinfo { diseinfotemp := make(map[string]interface{}) diseinfotemp["maindiag_flag"] = item.MaindiagFlag // 手术操作代码 必填 diseinfotemp["diag_type"] = item.DiagType // 诊断类别 必填 diseinfotemp["diag_code"] = item.DiagCode // 诊断代码 必填 diseinfotemp["diag_name"] = item.DiagName // 诊断名称 必填 diseinfotemp["adm_cond_type"] = "3" // 入院病情类型 必填 diseinfo = append(diseinfo, diseinfotemp) } iteminfo := make([]map[string]interface{}, 0) for _, item := range struct4101.IteminfoStruct { iteminfotemp := make(map[string]interface{}) iteminfotemp["med_chrgitm"] = item.MedChrgitm // 医疗收费项目 必填 iteminfotemp["amt"] = item.Amt // 金额 必填 iteminfotemp["claa_sumfee"] = item.ClaaSumfee // 甲类费用合计 必填 iteminfotemp["clab_amt"] = item.ClabAmt // 乙类金额 必填 iteminfotemp["fulamt_ownpay_amt"] = item.FulamtOwnpayAmt // 全自费金额 必填 iteminfotemp["oth_amt"] = item.OthAmt // 其他金额 必填 iteminfo = append(iteminfo, iteminfotemp) } oprninfo := make([]map[string]interface{}, 0) // 手术操作信息 oprninfotemp := make(map[string]interface{}) oprninfotemp["oprn_oprt_type"] = "" // 手术操作类别 必填 oprninfotemp["oprn_oprt_name"] = "" // 手术操作名称 必填 oprninfotemp["oprn_oprt_code"] = "" // 手术操作代码 必填 oprninfotemp["oprn_oprt_date"] = "" // 手术操作日期 必填 oprninfotemp["anst_way"] = "" // 麻醉方式 必填 oprninfotemp["oper_dr_name"] = "" // 术者医师姓名 必填 oprninfotemp["oper_dr_code"] = "" // 术者医师代码 必填 oprninfotemp["anst_dr_name"] = "" // 麻醉医师姓名 必填 oprninfotemp["anst_dr_code"] = "" // 麻醉医师代码 必填 oprninfo = append(oprninfo, oprninfotemp) icuinfo := make([]map[string]interface{}, 0) // 重症监护信息 icuinfotemp := make(map[string]interface{}) icuinfotemp["scs_cutd_ward_type"] = "" // 重症监护病房类型 必填 icuinfotemp["scs_cutd_inpool_time"] = "" // 重症监护进入时间 必填 icuinfotemp["scs_cutd_exit_time"] = "" // 重症监护退出时间 必填 icuinfotemp["scs_cutd_sum_dura"] = "" // 重症监护合计时长 必填 icuinfo = append(icuinfo, icuinfotemp) input["setlinfo"] = inputData input["payinfo"] = payinfo input["opspdiseinfo"] = oprninfo input["diseinfo"] = diseinfo input["iteminfo"] = iteminfo inputMessage["input"] = input //交易输入 bytesData, err := json.Marshal(inputMessage) 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") //url := gdyb_url + "4101" var url string if fixmedins_code == "H15049901371" { url = gdyb_url } else { if org_id == 10106 || org_id == 10215 || org_id == 10138 || org_id == 9504 { url = gdyb_url + "4101A" } else { url = gdyb_url + "4101" } } //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/4101" 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() } str := string(respBytes) fmt.Println(str) return str } func HeBeiyb2601(psnNo string, omsgid string, oinfno string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key 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"] = "2601" // 交易编码 inputData["psn_no"] = psnNo inputData["omsgid"] = omsgid inputData["oinfno"] = oinfno input["data"] = inputData inputMessage["input"] = input //交易输入 bytesData, err := json.Marshal(inputMessage) 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") url := gdyb_url + "2601" 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() } str := string(respBytes) fmt.Println(str) return str } //人员信息版本3 func HeBeiyb1101B(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 int64) 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"] = "1101" // 交易编码 if certificates == 3 { inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型 inputData["certno"] = "01836483" // 证件号码 inputData["psn_cert_type"] = "01" // 人员证件类型 inputData["mdtrt_cert_no"] = "01836483" // 就诊凭证编号 } else { if certificates == 1 { if id_card_type == 1 { inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型 inputData["card_sn"] = "" // 卡识别码 inputData["certno"] = certNo // 证件号码 inputData["psn_cert_type"] = "01" // 人员证件类型 inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号 } else { inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型 inputData["card_sn"] = "" // 卡识别码 inputData["certno"] = certNo // 证件号码 inputData["psn_cert_type"] = "01" // 人员证件类型 inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号 } } else if certificates == 6 { inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型 inputData["card_sn"] = "" // 卡识别码 inputData["certno"] = certNo // 证件号码 inputData["psn_cert_type"] = "17" // 人员证件类型 inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号 } } inputData["begntime"] = "" // 开始时间 inputData["psn_name"] = "" // 人员姓名 input["data"] = inputData inputMessage["input"] = input //交易输入 bytesData, err := json.Marshal(inputMessage) 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") //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101" //url := gdyb_url + "1101" var url string if fixmedins_code == "H15049901371" { url = gdyb_url } else { url = gdyb_url + "1101" } fmt.Println(url) fmt.Println(gdyb_paasid) fmt.Println(secret_key) //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 } func HeBeiyb1101G(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 int64, name string, cardNumber 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"] = "1101" // 交易编码 inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型 inputData["card_sn"] = card_sn // 卡识别码 inputData["certno"] = certNo // 证件号码 inputData["psn_cert_type"] = "01" // 人员证件类型 inputData["mdtrt_cert_no"] = cardNumber // 就诊凭证编号 inputData["begntime"] = "" // 开始时间 inputData["psn_name"] = name // 人员姓名 input["data"] = inputData inputMessage["input"] = input //交易输入 bytesData, err := json.Marshal(inputMessage) 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") //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101" //url := gdyb_url + "1101" var url string if fixmedins_code == "H15049901371" { url = gdyb_url } else { url = gdyb_url + "1101" } fmt.Println(url) fmt.Println(gdyb_paasid) fmt.Println(secret_key) //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 } func HeBeiyb1101ForEleCert(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, token 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"] = "1101" // 交易编码 inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型 inputData["card_sn"] = "" // 卡识别码 inputData["certno"] = "" // 证件号码 inputData["psn_cert_type"] = "01" // 人员证件类型 inputData["mdtrt_cert_no"] = token // 就诊凭证编号 inputData["begntime"] = "" // 开始时间 inputData["psn_name"] = "" // 人员姓名 input["data"] = inputData inputMessage["input"] = input //交易输入 bytesData, err := json.Marshal(inputMessage) 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") //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101" //url := gdyb_url + "1101" var url string if fixmedins_code == "H15049901371" { url = gdyb_url } else { url = gdyb_url + "1101" } fmt.Println(url) fmt.Println(gdyb_paasid) fmt.Println(secret_key) //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, string(bytesData) } func HeBeiyb6101(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"] = "6101" // 交易编码 inputData["orgId"] = fixmedins_code // 就诊凭证类型 inputData["businessType"] = "01101" // 卡识别码 inputData["businessInfo"] = "" // 证件号码 inputData["operateorId"] = "01" // 人员证件类型 inputData["operateornName"] = doctor // 就诊凭证编号 inputData["officeId"] = "01" // 开始时间 inputData["officeName"] = "血透" // 人员姓名 inputData["deviceType"] = "" // 人员姓名 input["InData"] = inputData inputMessage["input"] = input //交易输入 bytesData, err := json.Marshal(inputMessage) 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") //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101" //url := gdyb_url + "1101" var url string if fixmedins_code == "H15049901371" { url = gdyb_url } else { url = gdyb_url + "1101" } fmt.Println(url) fmt.Println(gdyb_paasid) fmt.Println(secret_key) //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, string(bytesData) } //人员信息版本4 func HeBeiyb1101C(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 int64) (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"] = "1101" // 交易编码 if certificates == 3 { inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型 inputData["certno"] = certNo // 证件号码 inputData["psn_cert_type"] = "99" // 人员证件类型 } else { if id_card_type == 1 { inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型 inputData["card_sn"] = "" // 卡识别码 inputData["certno"] = "" // 证件号码 inputData["psn_cert_type"] = "" // 人员证件类型 } else { inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型 inputData["card_sn"] = "" // 卡识别码 inputData["certno"] = certNo // 证件号码 inputData["psn_cert_type"] = "1" // 人员证件类型 } } inputData["mdtrt_cert_no"] = "" // 就诊凭证编号 inputData["begntime"] = "" // 开始时间 inputData["psn_name"] = "" // 人员姓名 input["data"] = inputData inputMessage["input"] = input //交易输入 bytesData, err := json.Marshal(inputMessage) fmt.Println(string(bytesData)) if err != nil { fmt.Println(err.Error()) return err.Error(), "" } var json2 string cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2) out, err := cmd.Output() if err != nil { fmt.Println("error:", err.Error()) } fmt.Println(string(out)) return string(out), string(bytesData) } func HeBeiyb90991(psn_no string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, pwd string, card_number 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"] = "90991" // 交易编码 inputData["fixmedins_code"] = fixmedins_code // 就诊凭证编号 inputData["psn_no"] = psn_no // 开始时间 inputData["card_pwd"] = pwd // 人员姓名 inputData["sscno"] = card_number // 人员姓名 input["data"] = inputData inputMessage["input"] = input //交易输入 bytesData, err := json.Marshal(inputMessage) 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") url := gdyb_url + "90991" 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 } func HeBeiyb90100(psn_no string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key 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"] = "90100" // 交易编码 inputData["psn_no"] = psn_no // 开始时间 input["data"] = inputData inputMessage["input"] = input //交易输入 bytesData, err := json.Marshal(inputMessage) 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") url := gdyb_url + "90100" 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 } func HeBeiyb3260(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, year string, month string, sign string) (string, string) { //生成签名 nonce := GetRandomString(32) timestamp := time.Now().Unix() signature := setSignature(timestamp, nonce, secret_key) //生成输入报文 inputMessage := SetInputMessageTwo(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, sign) input := make(map[string]interface{}) inputData := make(map[string]interface{}) inputMessage["infno"] = "3260" // 交易编码 inputData["trt_year"] = year // 就诊凭证编号 inputData["trt_month"] = month // 开始时间 inputData["startrow"] = "100" // 人员姓名 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 + "3260" } if insuplc_admdvs == "421300" { var json2 string cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2) out, err := cmd.Output() if err != nil { fmt.Println("error:", err.Error()) } fmt.Println(string(out)) return hex.EncodeToString(out), inputLog } else { //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 HeBeiyb3261(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, year string, month string, result3260 models.Result3260) (string, string, string) { // //生成签名 // nonce := GetRandomString(32) // timestamp := time.Now().Unix() // signature := setSignature(timestamp, nonce, secret_key) // // msg_month := time.Unix(1557042972, 0).Format("1") // msg_year := time.Now().Format("2006") // msg_month = time.Now().Format("01") // day := time.Now().Format("02") // // hour := time.Now().Format("15") // min := time.Now().Format("04") // sec := time.Now().Format("05") // // msec := time.Now().Format("000") // // msg_id := fixmedins_code + msg_year + msg_month + day + hour + min + sec + msec + "0" // // //生成输入报文 // inputMessage := SetInputMessageThree(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, msg_id) // input := make(map[string]interface{}) // inputData := make(map[string]interface{}) // inputMessage["infno"] = "3261" // 交易编码 // inputData["trt_year"] = year // 就诊凭证编号 // inputData["trt_month"] = month // 开始时间 // inputData["startrow"] = len(result3260.Output.Data) // 人员姓名 // // feedetail := make([]map[string]interface{}, 0) // // for _, item := range result3260.Output.Data { // feedetailInfo := make(map[string]interface{}) // feedetailInfo["certno"] = item.Certno // feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回) // feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回) // feedetailInfo["setl_no"] = item.SetlNo // 收费批次号 // feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码 // feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号 // feedetail = append(feedetail, feedetailInfo) // } // inputData["detail"] = 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 + "3261" // } // // if insuplc_admdvs == "421300" { // var json2 string // cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2) // out, err := cmd.Output() // if err != nil { // fmt.Println("error:", err.Error()) // } // fmt.Println(string(out)) // return hex.EncodeToString(out), inputLog, "" // } else { // // //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, msg_id // // } // //} func HeBeiyb3262(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, year string, month string, otransid 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"] = "3262" // 交易编码 inputData["trt_year"] = year // 就诊凭证编号 inputData["trt_month"] = "" // 开始时间 inputData["otransid"] = otransid // 开始时间 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 + "3261" } if insuplc_admdvs == "421300" { var json2 string cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2) out, err := cmd.Output() if err != nil { fmt.Println("error:", err.Error()) } fmt.Println(string(out)) return hex.EncodeToString(out), inputLog } else { //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 setSignature2(timestamp int64, nonce string, secret_key string) string { fmt.Println(timestamp) fmt.Println(nonce) fmt.Println(secret_key) fmt.Println(strconv.FormatInt(timestamp, 10)) str := strconv.FormatInt(timestamp, 10) + secret_key + nonce + strconv.FormatInt(timestamp, 10) fmt.Println(str) hash := sha256.New() //输入数据 hash.Write([]byte(str)) //计算哈希值 bytes := hash.Sum(nil) //将字符串编码为16进制格式,返回字符串 hashCode := hex.EncodeToString(bytes) //返回哈希值 return hashCode } func HeBeiyb9001(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, admin_user_id int64) (string, string) { //生成签名 ul := uuid.New() nonce := ul.String() timestamp := time.Now().Unix() //now := time.Now() //获取当前时间 //t := now.Add(time.Minute * + 8 * 60) // 获取上一分钟时间 //lastM := t.Unix() - int64(now.Second()) // 上一分钟时间-上一分钟秒数 //timestamp = lastM signature := setSignature2(timestamp, nonce, "d6Ad0P1B3z6Dsdst0gYAFPlz8YlIvFDx") signature = ConvertToString(signature, "gbk", "utf-8") //生成输入报文 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"] = "9001" // 交易编码 inputData["opter_no"] = admin_user_id // 就诊凭证编号 inputData["mac"] = GetMac() // 开始时间 inputData["ip"] = GetLocalIp() input["signIn"] = 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 = "http://inner.getway.ylbzj.hebei.gov.cn/ebus/mbs_fsi_auth/fsi/api/signInSignOutService/signIn" } //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", "mbs_fsi_auth") //request.Header.Set("x-tif-signature", signature) //request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10)) //request.Header.Set("x-tif-nonce", nonce) request.Header["Content-Type"] = []string{"application/json"} request.Header["x-tif-paasid"] = []string{"mbs_fsi_auth"} request.Header["x-tif-signature"] = []string{signature} request.Header["x-tif-timestamp"] = []string{strconv.FormatInt(timestamp, 10)} request.Header["x-tif-nonce"] = []string{nonce} fmt.Println(string(bytesData)) fmt.Println(url) fmt.Println(gdyb_paasid) fmt.Println(request.Header) 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 HeBeiyb1101D(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, record_date 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"] = "1101" // 交易编码 if certificates == "3" { inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型 inputData["certno"] = certNo // 证件号码 inputData["psn_cert_type"] = "99" // 人员证件类型 } else { if certificates == "1" { if id_card_type == 1 { inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型 inputData["card_sn"] = "" // 卡识别码 inputData["certno"] = certNo // 证件号码 inputData["psn_cert_type"] = "01" // 人员证件类型 } else if id_card_type == 4 { inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型 inputData["certno"] = certNo // 证件号码 inputData["psn_cert_type"] = "01" // 人员证件类型 } else { inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型 inputData["card_sn"] = "" // 卡识别码 inputData["certno"] = certNo // 证件号码 inputData["psn_cert_type"] = "01" // 人员证件类型 } } else if certificates == "6" { inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型 inputData["card_sn"] = "" // 卡识别码 inputData["certno"] = certNo // 证件号码 inputData["psn_cert_type"] = "17" // 人员证件类型 } } inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号 inputData["begntime"] = "" // 开始时间 inputData["psn_name"] = "" // 人员姓名 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") //DllDef := syscall.MustLoadDLL("yh_hb_sctrl.dll") //Iinit := DllDef.MustFindProc("yh_hb_call") //var str3 string //ret, _, _ := Iinit.Call(StrPtr("1101"), StrPtr(string(bytesData)), StrPtr(str3)) //fmt.Println(ret) //fmt.Println(str3) // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101" var url string if fixmedins_code == "H15049901371" { url = gdyb_url } else { url = gdyb_url + "1101" } if insuplc_admdvs == "421300" { var json2 string cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2) out, err := cmd.Output() if err != nil { fmt.Println("error:", err.Error()) } fmt.Println(string(out)) return hex.EncodeToString(out), inputLog } else { //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 SetInputMessageFour(nonce string, timestamp int64, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) map[string]interface{} { // // 生成签名 // //tempTime := time.Unix(timestamp, 0) // //timeFormat := tempTime.Format("20060102150405") // //timeFormatOne := tempTime.Format("2006-01-02 15:04:05") // //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000) // // msec := time.Now().Format("000") // fmt.Println(utils.GetNetTime()) // // 生成输入报文 // inputMessage := make(map[string]interface{}) // inputMessage["msgid"] = fixmedins_code + utils.GetNetTime() + msec + "0" // 发送方报文 ID // inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划 // inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划 // inputMessage["recer_sys_code"] = "1" // 接收方系统代码 // inputMessage["dev_no"] = "" // 设备编号 // inputMessage["dev_safe_info"] = "" // 设备安全信息 // inputMessage["cainfo"] = "" // 数字签名信息 // inputMessage["signtype"] = "SM3" // 签名类型 // inputMessage["infver"] = "V1.0" // 接收方系统代码 // inputMessage["opter_type"] = "1" // 经办人类别 // inputMessage["opter"] = doctor // 经办人 // inputMessage["opter_name"] = doctor // 经办人姓名 // inputMessage["inf_time"] = utils.GetNetTime() // 交易时间 // inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号 // inputMessage["fixmedins_name"] = org_name //定点医药机构名称 // inputMessage["sign_no"] = "" //交易签到流水号 // return inputMessage //} func HeBeiyb5302(psnNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key 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"] = "5302" // 交易编码 inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回) inputData["biz_appy_type"] = "03" // 人员编号 (来自1101接口返回) input["data"] = inputData inputMessage["input"] = input //交易输入 bytesData, err := json.Marshal(inputMessage) fmt.Println(string(bytesData)) if err != nil { fmt.Println(err.Error()) return err.Error() } reader := bytes.NewReader(bytesData) //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301" gdyb_url := beego.AppConfig.String("gdyb_url") gdyb_paasid := beego.AppConfig.String("gdyb_paasid") //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101" url := gdyb_url + "5302" 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() } str := string(respBytes) fmt.Println(str) return str }