1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426 |
- package service
-
- import (
- "XT_New/models"
-
- "bytes"
- "crypto/sha256"
- "encoding/hex"
- "encoding/json"
- "fmt"
- "io"
- "io/ioutil"
- "math/rand"
- "mime/multipart"
- "net/http"
- "os"
- "path/filepath"
- "strconv"
- "strings"
- "time"
- _ "unsafe"
- )
-
- const (
- SceretKey = "RhaDw4H0RUbWYyTxmRKM1eSeN0qyGLds"
- )
-
-
- func Gdyb1101(certNo 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"] = "1101"
- inputData["mdtrt_cert_type"] = "02"
- inputData["mdtrt_cert_no"] = certNo
- inputData["card_sn"] = ""
- inputData["begntime"] = ""
- inputData["psn_cert_type"] = "1"
- inputData["certno"] = certNo
- 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)
- url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/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", "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()
- }
- fmt.Println(string(respBytes))
- str := string(respBytes)
- return str
- }
-
-
- func Gdyb2201(psnNo string, insutype string, certNo string, org_name string, doctor 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) 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{})
- inputMessage["infno"] = "2201"
- inputData["psn_no"] = psnNo
- inputData["insutype"] = insutype
- inputData["begntime"] = timeFormatOne
- 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
- inputData["dept_code"] = dept_code
- inputData["dept_name"] = dept
- inputData["caty"] = "A03.06"
-
- 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/2201"
-
-
- 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 Gdyb2202(psnNo string, mdtrtId string, ipt_otp_no string, org_name string, doctor 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, "", insuplc_admdvs, mdtrtarea_admvs)
- input := make(map[string]interface{})
- inputData := make(map[string]interface{})
- inputMessage["infno"] = "2202"
- inputData["psn_no"] = psnNo
- inputData["mdtrt_id"] = mdtrtId
- inputData["ipt_otp_no"] = ipt_otp_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)
-
- url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2202"
-
-
- 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 Gdyb2203(psnNo string, mdtrtId 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) 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
- inputData["psn_no"] = psnNo
- inputData["med_type"] = med_type
- inputData["begntime"] = timeFormatOne
- inputData["main_cond_dscr"] = ""
- inputData["dise_codg"] = ""
- inputData["dise_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"
-
-
- 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
- }
-
- type Custom struct {
- DetItemFeeSumamt string
- Cut string
- FeedetlSn string
- Price string
- MedListCodg string
- }
-
- type RequestResult struct {
- Output Output `json:"output" form:"output"`
- Infcode int64 `gorm:"column:infcode" json:"infcode" form:"infcode"`
- WarnMsg string `gorm:"column:warn_msg" json:"warn_msg" form:"warn_msg"`
- Cainfo string `gorm:"column:cainfo" json:"cainfo" form:"cainfo"`
- ErrMsg string `gorm:"column:err_msg" json:"err_msg" form:"err_msg"`
- RespondTime string `gorm:"column:respond_time" json:"respond_time" form:"respond_time"`
- InfRefmsgid string `gorm:"column:inf_refmsgid" json:"inf_refmsgid" form:"inf_refmsgid"`
- }
- type Output struct {
- Result Result `json:"result" form:"result"`
- }
-
- type Result struct {
- BasMednFlag string `json:"bas_medn_flag" form:"bas_medn_flag"`
- MedChrgitmType string `json:"med_chrgitm_type" form:"med_chrgitm_type"`
- DetItemFeeSumamt int64 `json:"det_item_fee_sumamt" form:"det_item_fee_sumamt"`
- HiNegoDrugFlag string `json:"hi_nego_drug_flag" form:"hi_nego_drug_flag"`
- FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
-
- FeedtlSn int64 `json:"feedtl_sn" form:"feedtl_sn"`
- UploadDate int64 `json:"upload_date" form:"upload_date"`
- AdviceId int64 `json:"advice_id" form:"advice_id"`
- Cnt int64 `json:"cnt" form:"cnt"`
- Pric float64 `json:"pric" form:"pric"`
- PatientId int64 `json:"patient_id" form:"patient_id"`
- PricUplmtAmt float64 `json:"pric_uplmt_amt" form:"pric_uplmt_amt"`
- SelfpayProp float64 `json:"selfpay_prop" form:"selfpay_prop"`
- OverlmtAmt float64 `json:"overlmt_amt" form:"overlmt_amt"`
- PreselfpayAmt float64 `json:"preselfpay_amt" form:"preselfpay_amt"`
- Status int64 `json:"status" form:"status"`
- Memo string `json:"memo" form:"memo"`
- FeedetlSn string `json:"feedetl_sn" form:"feedetl_sn"`
- Mtime int64 `json:"mtime" form:"mtime"`
- InscpScpAmt float64 `json:"inscp_scp_amt" form:"inscp_scp_amt"`
- DrtReimFlag string `json:"drt_reim_flag" form:"drt_reim_flag"`
- Ctime int64 `json:"ctime" form:"ctime"`
- ListSpItemFlag string `json:"list_sp_item_flag" form:"list_sp_item_flag"`
- ChldMedcFlag string `json:"chld_medc_flag" form:"chld_medc_flag"`
- LmtUsedFlag string `json:"lmt_used_flag" form:"lmt_used_flag"`
- ChrgitmLv string `json:"chrgitm_lv" form:"chrgitm_lv"`
- UserOrgId int64 `json:"user_org_id" form:"user_org_id"`
- HisPatientId int64 `json:"his_patient_id" form:"his_patient_id"`
- OrderId int64 `json:"order_id" form:"order_id"`
- }
-
-
- func Gdyb2204(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) 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")
-
-
- var customs []*Custom
-
- for _, item := range hisPrescription {
- if item.Type == 1 {
- for _, subItem := range item.HisDoctorAdviceInfo {
- if len(subItem.MedListCodg) > 0 {
-
-
- cus := &Custom{
- DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
- Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
- FeedetlSn: subItem.FeedetlSn,
- Price: fmt.Sprintf("%.2f", subItem.Price),
- MedListCodg: subItem.MedListCodg,
- }
-
- customs = append(customs, cus)
- }
- }
- }
-
- if item.Type == 2 {
- for _, subItem := range item.HisPrescriptionProject {
-
-
- if len(subItem.MedListCodg) > 0 {
- cut, _ := strconv.ParseFloat(subItem.Count, 64)
- cus := &Custom{
- DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*cut),
- Cut: fmt.Sprintf("%.2f", cut),
- FeedetlSn: subItem.FeedetlSn,
- Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
- MedListCodg: subItem.MedListCodg,
- }
- customs = append(customs, cus)
- }
- }
- }
-
- for _, subItem := range item.HisAdditionalCharge {
- if len(subItem.XtHisAddtionConfig.Code) > 0 {
- cus := &Custom{
- DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
- Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
- FeedetlSn: subItem.FeedetlSn,
- Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
- MedListCodg: subItem.XtHisAddtionConfig.Code,
- }
- 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"
-
-
- for _, item := range customs {
- feedetailInfo := make(map[string]interface{})
- feedetailInfo["feedetl_sn"] = item.FeedetlSn
- feedetailInfo["mdtrt_id"] = mdtrtId
- feedetailInfo["psn_no"] = psnNo
- feedetailInfo["chrg_bchno"] = chrg_bchno
- feedetailInfo["dise_codg"] = ""
- feedetailInfo["rxno"] = ""
- feedetailInfo["rx_circ_flag"] = "0"
- feedetailInfo["fee_ocur_time"] = timeFormatOne
- 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"] = doctor_id
- feedetailInfo["bilg_dr_name"] = doctor
- feedetailInfo["acord_dept_codg"] = ""
- feedetailInfo["acord_dept_name"] = ""
- feedetailInfo["orders_dr_code"] = ""
- feedetailInfo["orders_dr_name"] = ""
- 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
-
- bytesData, err := json.Marshal(inputMessage)
- fmt.Println("----------")
- fmt.Println(string(bytesData))
- fmt.Println("----------")
-
- if err != nil {
- fmt.Println(err.Error())
- return ""
- }
- reader := bytes.NewReader(bytesData)
- url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2204"
-
-
- 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", "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 ""
- }
- respBytes, err := ioutil.ReadAll(resp.Body)
- if err != nil {
- fmt.Println(err.Error())
- return ""
- }
- return string(respBytes)
-
-
-
- }
-
-
- func Gdyb2205(psnNo string, mdtrtId string, chrgBchno string, org_name string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, fixmedins_code 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
- inputData["chrg_bchno"] = chrgBchno
- inputData["psn_no"] = psnNo
-
- 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/2205"
-
-
- 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", "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 Gdyb2206(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string, total string, org_name string, doctor 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, "", "", "")
- input := make(map[string]interface{})
- inputData := make(map[string]interface{})
- inputMessage["infno"] = "2206"
-
- inputData["psn_no"] = psnNo
- inputData["mdtrt_cert_type"] = "02"
- inputData["mdtrt_cert_no"] = certNo
- inputData["med_type"] = "11"
- inputData["medfee_sumamt"] = total
- inputData["psn_setlway"] = "01"
- inputData["mdtrt_id"] = mdtrtId
- inputData["chrg_bchno"] = chrgBchno
- inputData["acct_used_flag"] = "1"
- inputData["insutype"] = insutype
-
- 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/2206"
-
-
- 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 Gdyb2207(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) 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
- inputData["mdtrt_cert_type"] = "02"
- inputData["mdtrt_cert_no"] = certNo
- inputData["med_type"] = "11"
- inputData["medfee_sumamt"] = total
- inputData["psn_setlway"] = "01"
- inputData["mdtrt_id"] = mdtrtId
- inputData["chrg_bchno"] = chrgBchno
- inputData["acct_used_flag"] = "1"
- inputData["insutype"] = insutype
- inputData["invono"] = ""
-
- 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/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", "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 Gdyb2208(psnNo string, mdtrtId string, setlId string, org_name string, doctor string, secret_key string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs 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
- inputData["mdtrt_id"] = mdtrtId
- inputData["setl_id"] = setlId
-
- 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/2208"
-
-
- 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 Gdyb3201(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
- inputData["setl_optins"] = baseParams.OrgName
- 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
-
- 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/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", "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
- }
-
- type Params struct {
- FileName string `json:"file_name"`
- In []byte `json:"in"`
- FixmedinsCode string `json:"fixmedins_code"`
- }
-
-
-
- func Gdyb9101(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"] = bytes.NewBuffer(file_byte).Bytes()
- 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"
-
-
- 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 Gdyb9102(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"] = "fsi/H44022900158/" + 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)
- url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/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", "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 Gdyb3202(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"] = "fsi/H44022900158/" + businessParams.FileQuryNo
- inputData["setl_optins"] = baseParams.OrgName
- 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
-
- 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/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", "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 Gdyb5203(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"] = "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))
- 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/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", "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 setSignature(timestamp int64, nonce string, secret_key string) string {
- str := strconv.FormatInt(timestamp, 10) + secret_key + nonce + strconv.FormatInt(timestamp, 10)
- hash := sha256.New()
-
- hash.Write([]byte(str))
-
- bytes := hash.Sum(nil)
-
- hashCode := hex.EncodeToString(bytes)
-
- return hashCode
- }
-
-
- func GetRandomString(l int) string {
- str := "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
- bytes := []byte(str)
- result := []byte{}
- r := rand.New(rand.NewSource(time.Now().UnixNano()))
- for i := 0; i < l; i++ {
- result = append(result, bytes[r.Intn(len(bytes))])
- }
- return string(result)
- }
-
-
- func SetInputMessage(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)
-
-
- inputMessage := make(map[string]interface{})
-
- inputMessage["infno"] = "1101"
- inputMessage["msgid"] = fixmedins_code + timeFormat + strconv.FormatInt(int64(randNum), 10)
- inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs
- inputMessage["insuplc_admdvs"] = insuplc_admdvs
- inputMessage["recer_sys_code"] = "01"
- inputMessage["dev_no"] = ""
- inputMessage["dev_safe_info"] = ""
- inputMessage["cainfo"] = ""
- inputMessage["signtype"] = ""
- inputMessage["infver"] = "V1.1"
- inputMessage["opter_type"] = "1"
- inputMessage["opter"] = doctor
- inputMessage["opter_name"] = doctor
- inputMessage["inf_time"] = timeFormatOne
- inputMessage["fixmedins_code"] = fixmedins_code
- inputMessage["fixmedins_name"] = org_name
- inputMessage["sign_no"] = ""
- return inputMessage
- }
-
- func postFile(filename string, target_url string) (*http.Response, error) {
- body_buf := bytes.NewBufferString("")
- body_writer := multipart.NewWriter(body_buf)
-
-
- _, err := body_writer.CreateFormFile("userfile", filename)
- if err != nil {
- fmt.Println("error writing to buffer")
- return nil, err
- }
-
-
- fh, err := os.Open(filename)
- if err != nil {
- fmt.Println("error opening file")
- return nil, err
- }
-
- boundary := body_writer.Boundary()
-
- close_buf := bytes.NewBufferString(fmt.Sprintf("\r\n--%s--\r\n", boundary))
-
-
-
- request_reader := io.MultiReader(body_buf, fh, close_buf)
- fi, err := fh.Stat()
- if err != nil {
- fmt.Printf("Error Stating file: %s", filename)
- return nil, err
- }
- req, err := http.NewRequest("POST", target_url, request_reader)
- if err != nil {
- return nil, err
- }
-
-
- req.Header.Add("Content-Type", "multipart/form-data; boundary="+boundary)
- req.ContentLength = fi.Size() + int64(body_buf.Len()) + int64(close_buf.Len())
-
- return http.DefaultClient.Do(req)
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- func newfileUploadRequest(uri string, params map[string]string, paramName, path string) (*http.Request, error) {
- file, err := os.Open(path)
- if err != nil {
- return nil, err
- }
- defer file.Close()
-
- body := &bytes.Buffer{}
- writer := multipart.NewWriter(body)
- part, err := writer.CreateFormFile(paramName, filepath.Base(path))
- if err != nil {
- return nil, err
- }
- _, err = io.Copy(part, file)
-
- for key, val := range params {
- _ = writer.WriteField(key, val)
- }
- err = writer.Close()
- if err != nil {
- return nil, err
- }
-
- req, err := http.NewRequest("POST", uri, body)
- req.Header.Set("Content-Type", writer.FormDataContentType())
- return req, err
- }
|