123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332 |
- package service
-
- import (
-
- //"crypto/md5"
-
- //"strings"
- //"gdyb/utils"
-
-
- "time"
- "fmt"
- "encoding/json"
- "github.com/astaxie/beego"
- "net/http"
- "strconv"
- "io/ioutil"
-
- "bytes"
- "github.com/go-ole/go-ole"
- "github.com/go-ole/go-ole/oleutil"
- )
-
- func Gxyb9001(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, admin_user_id int64,setlId string,mdtrtId string,psn_no string,medinsSetlId string){
-
- ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
- defer ole.CoUninitialize()
-
- // Replace with the ProgID or CLSID of your COM object
- progID := "YinHai.XJ.Actual.Interface.New"
-
- // Create COM object
- unknown, err := oleutil.CreateObject(progID)
- if err != nil {
- fmt.Println("Unable to create COM object:", err)
- }
- defer unknown.Release()
-
- // Query for the IDispatch interface
- dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
- if err != nil {
- fmt.Println("Unable to get IDispatch interface:", err)
- }
- defer dispatch.Release()
-
- nonce := GetRandomString(32)
- timestamp := time.Now().Unix()
- inputMessage := make(map[string]interface{})
- inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs,doctor)
- input := make(map[string]interface{})
- inputData := make(map[string]interface{})
- inputMessage["infno"] = "P0001" // 交易编码
- inputData["setlId"] = setlId
- inputData["mdtrtId"] = mdtrtId
- inputData["psn_no"] = psn_no
- inputData["medinsSetlId"] = medinsSetlId
- input["data"] = inputData
- inputMessage["input"] = input //交易输入
-
- jsonData, err := json.Marshal(inputMessage)
- if err != nil {
- fmt.Println("转换为JSON失败:", err)
-
- }
- //data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
- result2 := ""
- // Call COM object's method using the IDispatch interface
- resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "P0001", string(jsonData),&result2)
- fmt.Println(resulr)
-
-
- }
-
-
- func Gxyb5302(psnNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string,admin_user_id int64) string {
- // 生成签名
- nonce := GetRandomString(32)
- //timestamp := time.Now().Unix()
- timestamp := time.Now().UnixNano() / 1e6
-
- signature := setSignature(timestamp, nonce, secret_key)
-
- inputMessage := SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs,doctor)
-
- // 生成输入报文
- //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
- 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 Gxyb2207(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,admin_user_id int64) (string, string) {
- // 生成签名
- nonce := GetRandomString(32)
- timestamp := time.Now().Unix()
- signature := setSignature(timestamp, nonce, secret_key)
-
- // 生成输入报文
- inputMessage := make(map[string]interface{})
-
- if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127"{
-
- inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs,doctor)
- } else {
- inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
- }
- //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"] = token // 就诊凭证编号
- } 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"] = "140101" // 医疗类别 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" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
- 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"
-
-
- 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 Gxyb2503( org_name string, doctor string, fixmedins_code string,insuplc_admdvs string, mdtrtarea_admvs string, secret_key string,admin_user_id int64) string {
- // 生成签名
- nonce := GetRandomString(32)
- timestamp := time.Now().Unix()
- signature := setSignature(timestamp, nonce, secret_key)
-
- // 生成输入报文
- inputMessage := SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs,doctor)
-
- input := make(map[string]interface{})
- inputData := make(map[string]interface{})
- inputMessage["infno"] = "2503" // 交易编码
- inputData["psn_no"] = "45000000000008100150404986" // 人员编号 (来自1101接口返回)
- inputData["insutype"] = "390" // 险种类型(来自1101接口返回)
- inputData["opsp_dise_code"] = "M03900" // 险种类型(来自1101接口返回)
- inputData["opsp_dise_name"] = "高血压(高危组)" // 险种类型(来自1101接口返回)
- inputData["insu_optins"] = "450721" // 险种类型(来自1101接口返回)
- inputData["ide_fixmedins_no"] = "H45072101171" // 险种类型(来自1101接口返回)
- inputData["ide_fixmedins_name"] = "灵山盛康血液透析中心" // 险种类型(来自1101接口返回)
- inputData["hosp_ide_date"] = "2024-02-01" // 险种类型(来自1101接口返回)
- inputData["diag_dr_codg"] = "D450721000406" // 开始时间
- inputData["diag_dr_name"] = "韦秋萍" // 开始时间
- inputData["begndate"] = "2024-02-01" // 医师编码
- inputData["tel"] = "" // 医师编码
- inputData["addr"] = "" // 医师编码
- inputData["enddate"] = "2026-01-30" // 医师编码
-
- 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
-
- 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
- }
|