12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505 |
- package service
-
- import (
- "bytes"
- "encoding/json"
- "fmt"
- "gdyb/models"
- "github.com/astaxie/beego"
- "github.com/jinzhu/gorm"
- "io/ioutil"
- "net/http"
- "strconv"
- "time"
- _ "unsafe"
- )
-
- // 人员基本信息
- func ZHGdyb1101(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) (string, string, string) {
- //生成签名
- var requestLog string
- var resultLog 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"] = card_sn // 卡识别码
- inputData["certno"] = certNo // 证件号码
- inputData["psn_cert_type"] = "01" // 人员证件类型
-
- } else {
- inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
- inputData["card_sn"] = "" // 卡识别码
- inputData["certno"] = certNo // 证件号码
- inputData["psn_cert_type"] = "01" // 人员证件类型
- }
- }
-
- 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))
- 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 + "1101"
- if mdtrtarea_admvs == "150499" {
- url = gdyb_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)
- resultLog = str
- return str, requestLog, resultLog
- }
-
- func ZHGdyb1101B(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) (string, string) {
- //生成签名
- var requestLog 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"] = "02" // 就诊凭证类型
- inputData["card_sn"] = "" // 卡识别码
- inputData["certno"] = certNo // 证件号码
- inputData["psn_cert_type"] = "01" // 人员证件类型
-
- } else {
- inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
- inputData["card_sn"] = "" // 卡识别码
- inputData["certno"] = certNo // 证件号码
- inputData["psn_cert_type"] = "01" // 人员证件类型
- }
- }
-
- 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))
- 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 + "1101"
- if mdtrtarea_admvs == "150499" {
- url = gdyb_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, requestLog
- }
-
- type DiseinfoStruct struct {
- PsnNo string
- DiagType string
- MaindiagFlag string
- DiagSrtNo string
- DiagCode string
- DiagName string
- DiagDept string
- DiseDorNo string
- DiseDorName string
- DiagTime string
- }
- type Struct2401 struct {
- PsnNo string
- Insutype string
- MdtrtCertType string
- MdtrtCertNo string
- MedType string
- IptNo string
- AtddrNo string
- ChfpdrName string
- AdmDiagDscr string
- AdmDeptCodg string
- AdmDeptName string
- AdmBed string
- DscgMaindiagCode string
- DscgMaindiagName string
- Diseinfo []DiseinfoStruct
- Begntime string
- DiseCodg string
- DiseName string
- }
-
- // 住院登记
- func ZHGdyb2401(struct2401 Struct2401, secret_key string, org_name string, fixmedins_code string, doctor string, insuplc_admdvs string, mdtrtarea_admvs 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, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
- input := make(map[string]interface{})
- inputData := make(map[string]interface{})
- inputMessage["infno"] = "2401" // 交易编码
- inputData["psn_no"] = struct2401.PsnNo // 人员编号 (来自1101接口返回)
- inputData["insutype"] = struct2401.Insutype // 险种类型(来自1101接口返回)
- inputData["tel"] = ""
- inputData["coner_name"] = ""
- inputData["begntime"] = struct2401.Begntime // 开始时间
- inputData["mdtrt_cert_type"] = struct2401.MdtrtCertType // 就诊凭证类型
- inputData["mdtrt_cert_no"] = struct2401.MdtrtCertNo // 就诊凭证编号
- inputData["med_type"] = struct2401.MedType // 就诊凭证编号
- inputData["ipt_no"] = struct2401.IptNo // 住院/门诊号
- inputData["medrcdno"] = ""
- inputData["atddr_no"] = struct2401.AtddrNo
- inputData["chfpdr_name"] = struct2401.ChfpdrName
- inputData["adm_diag_dscr"] = struct2401.AdmDiagDscr
- inputData["adm_dept_codg"] = struct2401.AdmDeptCodg
- inputData["adm_dept_name"] = struct2401.AdmDeptName
- inputData["adm_bed"] = struct2401.AdmBed
- inputData["dscg_maindiag_code"] = struct2401.DscgMaindiagCode
- inputData["dscg_maindiag_name"] = struct2401.DscgMaindiagName
- inputData["main_cond_dscr"] = ""
- inputData["dise_codg"] = struct2401.DiseCodg
- inputData["dise_name"] = struct2401.DiseName
- inputData["oprn_oprt_code"] = ""
- inputData["oprn_oprt_name"] = ""
- inputData["fpsc_no"] = ""
- inputData["matn_type"] = ""
- inputData["birctrl_type"] = ""
- inputData["latechb_flag"] = ""
- inputData["geso_val"] = ""
- inputData["fetts"] = ""
- inputData["fetus_cnt"] = ""
- inputData["pret_flag"] = ""
- inputData["birctrl_matn_date"] = ""
- inputData["dise_type_code"] = ""
-
- inputDataArr := make([]map[string]interface{}, 0)
- for _, item := range struct2401.Diseinfo {
- inputDataTwo := make(map[string]interface{})
- inputDataTwo["psn_no"] = item.PsnNo
- inputDataTwo["diag_type"] = item.DiagType
- inputDataTwo["maindiag_flag"] = item.MaindiagFlag
- inputDataTwo["diag_srt_no"] = item.DiagSrtNo
- inputDataTwo["diag_code"] = item.DiagCode
- inputDataTwo["diag_name"] = item.DiagName
- inputDataTwo["adm_cond"] = ""
- inputDataTwo["diag_dept"] = item.DiagDept
- inputDataTwo["dise_dor_no"] = item.DiseDorNo
- inputDataTwo["dise_dor_name"] = item.DiseDorName
- inputDataTwo["diag_time"] = item.DiagTime
- inputDataArr = append(inputDataArr, inputDataTwo)
- }
- input["mdtrtinfo"] = inputData
- input["diseinfo"] = inputDataArr
- inputMessage["input"] = input //交易输入
-
- 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")
- url := gdyb_url + "2401"
- if mdtrtarea_admvs == "150499" {
- 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, requestLog
- }
-
- //住院撤销
- func ZHGdyb2404(mdtrt_id string, psn_no string, secret_key string, org_name string, fixmedins_code string, doctor 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"] = "2404" // 交易编码
- inputData["mdtrt_id"] = mdtrt_id // 人员编号 (来自1101接口返回)
- inputData["psn_no"] = psn_no // 人员编号 (来自1101接口返回)
- input["data"] = inputData
- inputMessage["input"] = input //交易输入
- 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")
- url := gdyb_url + "2404"
- if mdtrtarea_admvs == "150499" {
- 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, requestLog
- }
-
- //出院撤销
- func ZHGdyb2405(mdtrt_id string, psn_no string, secret_key string, org_name string, fixmedins_code string, doctor 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"] = "2405" // 交易编码
- inputData["mdtrt_id"] = mdtrt_id // 人员编号 (来自1101接口返回)
- inputData["psn_no"] = psn_no // 人员编号 (来自1101接口返回)
- input["data"] = inputData
- inputMessage["input"] = input //交易输入
- 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")
- url := gdyb_url + "2405"
- if mdtrtarea_admvs == "150499" {
- 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, requestLog
- }
-
- type Diseinfo2402Struct struct {
- MdtrtId string
- PsnNo string
- DiagType string
- MaindiagFlag string
- DiagSrtNo string
- DiagCode string
- DiagName string
- DiagDept string
- DiseDorNo string
- DiseDorName string
- DiagTime string
- }
- type Struct2402 struct {
- MdtrtId string
- PsnNo string
- Insutype string
- Endtime string
- DscgDeptCodg string
- DscgDeptName string
- DscgWay string
- Diseinfo []Diseinfo2402Struct
- DiseName string
- DiseCode string
- }
-
- // 出院
- func ZHGdyb2402(struct2402 Struct2402, 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)
- //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"] = "2402" // 交易编码
- inputData["mdtrt_id"] = struct2402.MdtrtId // 人员编号 (来自1101接口返回)
- inputData["psn_no"] = struct2402.PsnNo // 人员编号 (来自1101接口返回)
- inputData["insutype"] = struct2402.Insutype // 险种类型(来自1101接口返回)
- inputData["endtime"] = struct2402.Endtime // 结束时间
- inputData["dise_codg"] = struct2402.DiseCode // 就诊凭证类型
-
- inputData["dise_name"] = struct2402.DiseName // 就诊凭证类型
- inputData["oprn_oprt_code"] = "" // 就诊凭证类型
- inputData["oprn_oprt_name"] = "" // 就诊凭证类型
- inputData["fpsc_no"] = "" // 就诊凭证类型
-
- inputData["matn_type"] = "" // 就诊凭证类型
- inputData["birctrl_type"] = "" // 就诊凭证类型
- inputData["latechb_flag"] = "" // 就诊凭证类型
- inputData["geso_val"] = ""
- inputData["fetts"] = ""
- inputData["fetus_cnt"] = ""
- inputData["pret_flag"] = ""
- inputData["birctrl_matn_date"] = ""
- inputData["cop_flag"] = ""
-
- inputData["dscg_dept_codg"] = struct2402.DscgDeptCodg
- inputData["dscg_dept_name"] = struct2402.DscgDeptName
- inputData["dscg_bed"] = "待定"
- inputData["dscg_way"] = struct2402.DscgWay
- inputData["die_date"] = ""
-
- inputDataArr := make([]map[string]interface{}, 0)
- for _, item := range struct2402.Diseinfo {
- inputDataTwo := make(map[string]interface{})
- inputDataTwo["psn_no"] = item.PsnNo
- inputDataTwo["mdtrt_id"] = item.MdtrtId
- inputDataTwo["diag_type"] = item.DiagType
- inputDataTwo["maindiag_flag"] = item.MaindiagFlag
- inputDataTwo["diag_srt_no"] = item.DiagSrtNo
- inputDataTwo["diag_code"] = item.DiagCode
- inputDataTwo["diag_name"] = item.DiagName
- inputDataTwo["diag_dept"] = item.DiagDept
- inputDataTwo["dise_dor_no"] = item.DiseDorNo
- inputDataTwo["dise_dor_name"] = item.DiseDorName
- inputDataTwo["diag_time"] = item.DiagTime
- inputDataArr = append(inputDataArr, inputDataTwo)
- }
-
- input["dscginfo"] = inputData
- input["diseinfo"] = inputDataArr
-
- inputMessage["input"] = input //交易输入
-
- bytesData, err := json.Marshal(inputMessage)
- fmt.Println(string(bytesData))
- request_log := 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 + "2402"
- if mdtrtarea_admvs == "150499" {
- url = gdyb_url
- }
- //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"
- 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", "test_hosp")
- 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, request_log
- }
-
- type ZHCustom struct {
- DetItemFeeSumamt string
- Cut string
- FeedetlSn string
- Price string
- MedListCodg string
- LmtUsedFlag int64
- HospApprFlag int64
- }
- type ZHRequestResult struct {
- Output ZHOutput `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 ZHOutput struct {
- Result Result `json:"result" form:"result"`
- }
- type ZHResult 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 ZHGdyb2301(psnNo string, mdtrtId string, hisPrescription []*models.NewCustom, 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, med_type string, doctor_name string, doctor_number 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 []*models.NewCustom
-
- customs = hisPrescription
- // 生成输入报文
- 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"] = "2301" // 交易编码
-
- //chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
- for _, item := range customs {
- org_id, _ := beego.AppConfig.Int64("org_id")
- doctor_info, _ := GetAdminUserInfoByID(org_id, item.DoctorId)
-
- feedetailInfo := make(map[string]interface{})
- feedetailInfo["feedetl_sn"] = item.FeedetlSn
- feedetailInfo["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
- feedetailInfo["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
- feedetailInfo["med_type"] = med_type
- 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["bilg_dept_codg"] = dept_code // 开单科室编码
- feedetailInfo["bilg_dept_name"] = dept // 开单科室名称
- feedetailInfo["bilg_dr_codg"] = doctor_info.DoctorNumber // 开单医生编码
- feedetailInfo["bilg_dr_name"] = doctor_info.UserName
- feedetailInfo["acord_dept_codg"] = dept_code // 受单科室编码
- feedetailInfo["acord_dept_name"] = dept // 受单科室名称
- feedetailInfo["orders_dr_code"] = doctor_info.DoctorNumber // 受单医生编码
- feedetailInfo["orders_dr_name"] = doctor_info.UserName // 受单医生姓名
- feedetailInfo["chrg_bchno"] = chrg_bchno // 收费批次号
- feedetailInfo["dise_codg"] = "" // 病种编码
- feedetailInfo["rxno"] = "" // 处方号
- feedetailInfo["rx_circ_flag"] = "0" // 外购处方标志
- feedetailInfo["sin_dos_dscr"] = "" // 单次剂量描述
- feedetailInfo["used_frqu_dscr"] = "" // 使用频次描述
- feedetailInfo["prd_days"] = "0" // 周期天数
- feedetailInfo["medc_way_dscr"] = "" // 用药途径描述
- // 开单医师姓名
-
- if item.HospApprFlag != -1 {
- if item.HospApprFlag == 1 {
- feedetailInfo["hosp_appr_flag"] = "0" // 医院审批标志
- } else if item.HospApprFlag == 2 {
- feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
- } else if item.HospApprFlag == 3 {
- feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
- } 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 //交易输入
-
- 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 := gdyb_url + "2301"
- if mdtrtarea_admvs == "150499" {
- url = gdyb_url
- }
- 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
-
- }
-
- func ZHGdyb2301A(psnNo string, mdtrtId string, hisPrescription []*models.NewCustom, 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, med_type string, opertor 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 []*models.NewCustom
-
- customs = hisPrescription
- // 生成输入报文
- inputMessage := SetInputMessage(nonce, timestamp, org_name, opertor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
- input := make(map[string]interface{})
- feedetail := make([]map[string]interface{}, 0)
- inputMessage["infno"] = "2301" // 交易编码
-
- //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["med_type"] = ""
- 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["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"] = dept_code // 受单科室编码
- feedetailInfo["acord_dept_name"] = dept // 受单科室名称
- feedetailInfo["orders_dr_code"] = doctor_id // 受单医生编码
- feedetailInfo["orders_dr_name"] = doctor // 受单医生姓名
- feedetailInfo["chrg_bchno"] = chrg_bchno // 收费批次号
- feedetailInfo["dise_codg"] = "" // 病种编码
- feedetailInfo["rxno"] = "" // 处方号
- feedetailInfo["rx_circ_flag"] = "0" // 外购处方标志
- feedetailInfo["sin_dos_dscr"] = "" // 单次剂量描述
- feedetailInfo["used_frqu_dscr"] = "" // 使用频次描述
- feedetailInfo["prd_days"] = "0" // 周期天数
- feedetailInfo["medc_way_dscr"] = "" // 用药途径描述
- // 开单医师姓名
-
- if item.HospApprFlag != -1 {
- if item.HospApprFlag == 1 {
- feedetailInfo["hosp_appr_flag"] = "0" // 医院审批标志
- } else if item.HospApprFlag == 2 {
- feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
- } else if item.HospApprFlag == 3 {
- feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
- } 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 //交易输入
-
- 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 := gdyb_url + "2301"
- if mdtrtarea_admvs == "150499" {
- url = gdyb_url
- }
- 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
-
- }
-
- // 住院费用明细信息撤销
- func Gdyb2302(psnNo string, mdtrtId string, org_name string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, fixmedins_code string, number string, refund_type 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"] = "2302" // 交易编码
- if refund_type == 1 {
- inputData["feedetl_sn"] = number //
-
- } else {
- inputData["feedetl_sn"] = "0000" //
- }
-
- inputData["mdtrt_id"] = mdtrtId // 就诊 ID
- inputData["psn_no"] = psnNo // 人员编号
-
- input["data"] = inputData
- inputMessage["input"] = input //交易输入
-
- 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")
-
- //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
- url := gdyb_url + "2302"
- if mdtrtarea_admvs == "150499" {
- url = gdyb_url
- }
- //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"
- 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 ZHGdyb2303(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, mid_setl_flag 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"] = "2303" // 交易编码
- 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 // 就诊凭证编号
- }
- }
- inputData["mdtrt_cert_sn"] = ""
- inputData["mid_setl_flag"] = mid_setl_flag // 中途退费标志
- inputData["medfee_sumamt"] = total // 医疗费总额
- inputData["psn_setlway"] = "02" // 个人结算方式 01 按项目结 02 按定额结算
- inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
- inputData["acct_used_flag"] = "1" // 个人账户使用标志 0否 1是
- inputData["insutype"] = insutype // 险种类型
- inputData["invono"] = "" // 发票号
- inputData["dise_codg"] = "M07803" // 发票号
-
- 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 + "2303"
- if mdtrtarea_admvs == "150499" {
- url = gdyb_url
- }
-
- //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 ZHGdyb2304(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, mid_setl_flag string, id_card_type int64, fulamt_ownpay_amt float64, overlmt_selfpay float64, preselfpay_amt float64, inscp_scp_amt float64, certificates int64, fapiao_number string, 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"] = "2304" // 交易编码
- 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 // 就诊凭证编号
- }
- }
- inputData["mdtrt_cert_sn"] = ""
- inputData["mid_setl_flag"] = mid_setl_flag // 中途退费标志
- inputData["medfee_sumamt"] = total // 医疗费总额
- inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
- inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
- inputData["acct_used_flag"] = acct_used_flag // 个人账户使用标志 0否 1是
- inputData["insutype"] = insutype // 险种类型
- inputData["invono"] = fapiao_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 := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
- url := gdyb_url + "2304"
- if mdtrtarea_admvs == "150499" {
- url = gdyb_url
- }
-
- //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 Gdyb26011(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"
- if mdtrtarea_admvs == "150499" {
- 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 Gdyb2305(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"] = "2305" // 交易编码
-
- 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 := gdyb_url + "2305"
- if mdtrtarea_admvs == "150499" {
- 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)
- mjson, _ := json.Marshal(inputMessage)
- str2 := string(mjson)
- return str, str2
- }
-
- func Gdyb90306(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"] = "90306" // 交易编码
- inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
- 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 := gdyb_url + "90306"
- if mdtrtarea_admvs == "150499" {
- 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)
- mjson, _ := json.Marshal(inputMessage)
- str2 := string(mjson)
- return str, str2
- }
-
- func CreateHospitalRecord(record *models.HisHospitalCheckRecord) (err error) {
- err = writeDb.Save(&record).Error
- return
- }
-
- func GetInHospitalRecord(id int64) (record models.HisHospitalCheckRecord, err error) {
- err = readDb.Model(&models.HisHospitalCheckRecord{}).Where("id = ? AND status = 1", id).First(&record).Error
- return
- }
-
- func GetInHospitalRecordByNumber(number string) (record models.HisHospitalCheckRecord, err error) {
- err = readDb.Model(&models.HisHospitalCheckRecord{}).Where("number = ? AND status = 1", number).First(&record).Error
- return
- }
-
- func GetLastHospitalRecord(id int64, user_org_id int64) (record models.HisHospitalCheckRecord, err error) {
- err = readDb.Model(&models.HisHospitalCheckRecord{}).Where("id = ? AND status = 1 AND user_org_id = ?", id, user_org_id).Last(&record).Error
- return
- }
-
- func GetZHHisPrescription(org_id int64, patient_id int64, record_date int64) (prescription []*models.HisPrescription, err error) {
- err = readDb.Model(&models.HisPrescription{}).
- Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
- }).
- Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("BaseDrugLib", "status=1")
- }).
- Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1").Preload("GoodInfo", "status = 1")
- }).
- Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND order_status <> 2 AND order_status <> 4 AND p_type = 1", org_id, record_date, patient_id).
- Find(&prescription).Error
- return
- }
-
- func GetZHMonthHisPrescription(org_id int64, patient_id int64, start_time int64, end_time int64) (prescription []*models.HisPrescription, err error) {
- err = readDb.Model(&models.HisPrescription{}).
- Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
- }).
- Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("BaseDrugLib", "status=1")
- }).
- Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1").Preload("GoodInfo", "status = 1")
- }).
- Where("user_org_id = ? AND record_date >= ? AND record_date <= ? AND patient_id = ? AND order_status <> 2 AND order_status <> 4 AND status = 1 AND p_type = 1 ", org_id, start_time, end_time, patient_id).
- Find(&prescription).Error
- return
- }
-
- func GetZHHisUploadPrescription(org_id int64, patient_id int64, record_date int64) (prescription []*models.HisPrescription, err error) {
- err = readDb.Model(&models.HisPrescription{}).
- Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
- }).
- Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("BaseDrugLib", "status=1")
- }).
- Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
- }).
- Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND order_status = 4 AND p_type = 1", org_id, record_date, patient_id).
- Find(&prescription).Error
- return
- }
-
- func GetZHMonthHisUploadPrescription(org_id int64, patient_id int64, start_time int64, end_time int64) (prescription []*models.HisPrescription, err error) {
- err = readDb.Model(&models.HisPrescription{}).
- Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
- }).
- Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("BaseDrugLib", "status=1")
- }).
- Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
- }).
- Where("user_org_id = ? AND record_date >= ? AND record_date <= ? AND patient_id = ? AND order_status == 4 AND status = 1 AND p_type = 1 ", org_id, start_time, end_time, patient_id).
- Find(&prescription).Error
- return
- }
-
- func GetZHHisUploadOrderInfo(org_id int64, patient_id int64, record_date int64, record_end_date int64, number string) (infos []*models.HisOrderInfo, err error) {
- err = readDb.Model(&models.HisOrderInfo{}).
- Where("user_org_id = ? AND status = 1 AND upload_date <= ? AND upload_date >= ? AND patient_id = ? AND order_number = ? ", org_id, record_end_date, record_date, patient_id, number).
- Find(&infos).Error
- return
- }
-
- func UpDateOrderInfoStatus(patient_id int64, record_date int64, org_id int64, record_two_date int64) (err error) {
- err = writeDb.Model(&models.HisOrderInfo{}).Where("user_org_id = ? AND status = 1 AND upload_date <= ? AND upload_date >= ? AND patient_id = ?", org_id, record_two_date, record_date, patient_id).Updates(map[string]interface{}{"status": 0}).Error
- return
- }
-
- func UpDatePrescriptionOrderStatusTwo(patient_id int64, record_date int64, org_id int64) (err error) {
- err = writeDb.Model(&models.HisPrescription{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND p_type = 1", org_id, record_date, patient_id).Updates(map[string]interface{}{"order_status": 1}).Error
- return
- }
-
- //func GetAllOrderInfoByNumber(number string) (infos []*models.HisOrderInfo, err error){
- //
- // err = readDb.Model(&models.HisOrderInfo{}).Where("user_org_id = ? AND ")
- //}
-
- func GetZHSettleMonthHisPrescription(org_id int64, patient_id int64, start_time int64, end_time int64) (prescription []*models.HisPrescription, err error) {
- err = readDb.Model(&models.HisPrescription{}).
- Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
- }).
- Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("BaseDrugLib", "status=1")
- }).
- Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1").Preload("GoodInfo", "status = 1")
- }).
- Where("user_org_id = ? AND record_date >= ? AND record_date <= ? AND patient_id = ? AND order_status <> 2 AND order_status <> 4 AND status = 1 AND p_type = 1 ", org_id, start_time, end_time, patient_id).
- Find(&prescription).Error
- return
- }
-
- func ZHyb5203(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
- }
|