gdyb_service.go 172KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761
  1. package service
  2. import (
  3. "bytes"
  4. "crypto/md5"
  5. "crypto/sha256"
  6. "encoding/hex"
  7. "encoding/json"
  8. "fmt"
  9. "gdyb/models"
  10. "strings"
  11. //"gdyb/utils"
  12. "github.com/astaxie/beego"
  13. "io"
  14. "io/ioutil"
  15. "math/rand"
  16. "mime/multipart"
  17. "net"
  18. "net/http"
  19. "os"
  20. "os/exec"
  21. "path/filepath"
  22. "strconv"
  23. "syscall"
  24. "time"
  25. "unsafe"
  26. )
  27. const (
  28. SceretKey = "RhaDw4H0RUbWYyTxmRKM1eSeN0qyGLds" // secretKey 私钥
  29. )
  30. //机构信息
  31. func Gdyb1201(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, card_sn string) string {
  32. // 生成签名
  33. nonce := GetRandomString(32)
  34. timestamp := time.Now().Unix()
  35. signature := setSignature(timestamp, nonce, secret_key)
  36. // 生成输入报文
  37. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  38. input := make(map[string]interface{})
  39. inputData := make(map[string]interface{})
  40. inputMessage["infno"] = "1201" // 交易编码
  41. inputData["fixmedins_type"] = "1"
  42. inputData["fixmedins_name"] = org_name
  43. inputData["fixmedins_code"] = fixmedins_code
  44. input["medinsinfo"] = inputData
  45. inputMessage["input"] = input //交易输入
  46. bytesData, err := json.Marshal(inputMessage)
  47. fmt.Println(string(bytesData))
  48. if err != nil {
  49. fmt.Println(err.Error())
  50. return err.Error()
  51. }
  52. reader := bytes.NewReader(bytesData)
  53. gdyb_url := beego.AppConfig.String("gdyb_url")
  54. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  55. url := gdyb_url + "1201"
  56. request, err := http.NewRequest("POST", url, reader)
  57. if err != nil {
  58. fmt.Println(err.Error())
  59. return err.Error()
  60. }
  61. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  62. request.Header.Set("x-tif-paasid", gdyb_paasid)
  63. request.Header.Set("x-tif-signature", signature)
  64. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  65. request.Header.Set("x-tif-nonce", nonce)
  66. client := http.Client{}
  67. resp, err := client.Do(request)
  68. if err != nil {
  69. fmt.Println(err.Error())
  70. return err.Error()
  71. }
  72. respBytes, err := ioutil.ReadAll(resp.Body)
  73. if err != nil {
  74. fmt.Println(err.Error())
  75. return err.Error()
  76. }
  77. fmt.Println(string(respBytes))
  78. str2 := string(respBytes)
  79. return str2
  80. }
  81. // 人员基本信息
  82. func Gdyb1101(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, card_sn string, certificates string, psn_name string) (string, string) {
  83. //生成签名
  84. nonce := GetRandomString(32)
  85. timestamp := time.Now().Unix()
  86. signature := setSignature(timestamp, nonce, secret_key)
  87. //生成输入报文
  88. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  89. input := make(map[string]interface{})
  90. inputData := make(map[string]interface{})
  91. inputMessage["infno"] = "1101" // 交易编码
  92. if certificates == "3" {
  93. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  94. inputData["certno"] = certNo // 证件号码
  95. inputData["psn_cert_type"] = "99" // 人员证件类型
  96. } else {
  97. if id_card_type == 1 {
  98. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  99. inputData["card_sn"] = card_sn // 卡识别码
  100. inputData["certno"] = certNo // 证件号码
  101. inputData["psn_cert_type"] = "" // 人员证件类型
  102. } else {
  103. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  104. inputData["card_sn"] = "" // 卡识别码
  105. inputData["certno"] = certNo // 证件号码
  106. inputData["psn_cert_type"] = "" // 人员证件类型
  107. }
  108. }
  109. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  110. inputData["begntime"] = "" // 开始时间
  111. inputData["psn_name"] = psn_name // 人员姓名
  112. input["data"] = inputData
  113. inputMessage["input"] = input //交易输入
  114. var inputLog string
  115. bytesData, err := json.Marshal(inputMessage)
  116. inputLog = string(bytesData)
  117. fmt.Println(string(bytesData))
  118. if err != nil {
  119. fmt.Println(err.Error())
  120. return err.Error(), ""
  121. }
  122. reader := bytes.NewReader(bytesData)
  123. gdyb_url := beego.AppConfig.String("gdyb_url")
  124. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  125. var url string
  126. if fixmedins_code == "H15049901371" {
  127. url = gdyb_url
  128. } else {
  129. url = gdyb_url + "1101"
  130. }
  131. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  132. request, err := http.NewRequest("POST", url, reader)
  133. if err != nil {
  134. fmt.Println(err.Error())
  135. return err.Error(), ""
  136. }
  137. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  138. request.Header.Set("x-tif-paasid", gdyb_paasid)
  139. request.Header.Set("x-tif-signature", signature)
  140. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  141. request.Header.Set("x-tif-nonce", nonce)
  142. client := http.Client{}
  143. resp, err := client.Do(request)
  144. if err != nil {
  145. fmt.Println(err.Error())
  146. return err.Error(), ""
  147. }
  148. respBytes, err := ioutil.ReadAll(resp.Body)
  149. if err != nil {
  150. fmt.Println(err.Error())
  151. return err.Error(), ""
  152. }
  153. fmt.Println(string(respBytes))
  154. str := string(respBytes)
  155. return str, inputLog
  156. }
  157. func Gdyb1101A(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, name string) string {
  158. //生成签名
  159. nonce := GetRandomString(32)
  160. timestamp := time.Now().Unix()
  161. signature := setSignature(timestamp, nonce, secret_key)
  162. //生成输入报文
  163. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  164. input := make(map[string]interface{})
  165. inputData := make(map[string]interface{})
  166. inputMessage["infno"] = "1101" // 交易编码
  167. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  168. inputData["card_sn"] = "" // 卡识别码
  169. inputData["certno"] = certNo // 证件号码
  170. inputData["psn_cert_type"] = "1" // 人员证件类型
  171. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  172. inputData["begntime"] = "" // 开始时间
  173. inputData["psn_name"] = name // 人员姓名
  174. input["data"] = inputData
  175. inputMessage["input"] = input //交易输入
  176. bytesData, err := json.Marshal(inputMessage)
  177. fmt.Println(string(bytesData))
  178. if err != nil {
  179. fmt.Println(err.Error())
  180. return err.Error()
  181. }
  182. reader := bytes.NewReader(bytesData)
  183. gdyb_url := beego.AppConfig.String("gdyb_url")
  184. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  185. var url string
  186. if fixmedins_code == "H15049901371" {
  187. url = gdyb_url
  188. } else {
  189. url = gdyb_url + "1101"
  190. }
  191. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  192. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  193. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  194. if insuplc_admdvs == "421300" {
  195. var json2 string
  196. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101A", string(bytesData), json2)
  197. out, err := cmd.Output()
  198. if err != nil {
  199. fmt.Println("error:", err.Error())
  200. }
  201. fmt.Println(string(out))
  202. return hex.EncodeToString(out)
  203. } else {
  204. request, err := http.NewRequest("POST", url, reader)
  205. if err != nil {
  206. fmt.Println(err.Error())
  207. return err.Error()
  208. }
  209. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  210. request.Header.Set("x-tif-paasid", gdyb_paasid)
  211. request.Header.Set("x-tif-signature", signature)
  212. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  213. request.Header.Set("x-tif-nonce", nonce)
  214. client := http.Client{}
  215. resp, err := client.Do(request)
  216. if err != nil {
  217. fmt.Println(err.Error())
  218. return err.Error()
  219. }
  220. respBytes, err := ioutil.ReadAll(resp.Body)
  221. if err != nil {
  222. fmt.Println(err.Error())
  223. return err.Error()
  224. }
  225. fmt.Println(string(respBytes))
  226. str := string(respBytes)
  227. return str
  228. }
  229. }
  230. // 门诊挂号
  231. func Gdyb2201(psnNo string, insutype string, certNo string, org_name string, opera string, ipt_otp_no string, dept string, fixmedins_code string, dept_code string, doctor_id string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, doctor_name string) (string, string) {
  232. fmt.Println(opera)
  233. // 生成签名
  234. nonce := GetRandomString(32)
  235. timestamp := time.Now().Unix()
  236. signature := setSignature(timestamp, nonce, secret_key)
  237. tempTime := time.Unix(timestamp, 0)
  238. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  239. // 生成输入报文
  240. inputMessage := SetInputMessage(nonce, timestamp, org_name, opera, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  241. input := make(map[string]interface{})
  242. inputData := make(map[string]interface{})
  243. inputMessage["infno"] = "2201" // 交易编码
  244. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  245. inputData["insutype"] = insutype // 险种类型(来自1101接口返回)
  246. inputData["begntime"] = timeFormatOne // 开始时间
  247. if id_card_type == 1 {
  248. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  249. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  250. } else {
  251. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  252. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  253. }
  254. inputData["ipt_otp_no"] = ipt_otp_no // 住院/门诊号
  255. inputData["atddr_no"] = doctor_id // 医师编码
  256. inputData["dr_name"] = doctor_name // 医师姓名
  257. inputData["dept_code"] = dept_code // 科室编码
  258. inputData["dept_name"] = dept // 科室名称
  259. inputData["caty"] = "A03.06" // 科别
  260. input["data"] = inputData
  261. inputMessage["input"] = input //交易输入
  262. var requestLog string
  263. bytesData, err := json.Marshal(inputMessage)
  264. requestLog = string(bytesData)
  265. fmt.Println(string(bytesData))
  266. if err != nil {
  267. fmt.Println(err.Error())
  268. return err.Error(), ""
  269. }
  270. reader := bytes.NewReader(bytesData)
  271. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2201"
  272. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2201"
  273. gdyb_url := beego.AppConfig.String("gdyb_url")
  274. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  275. var url string
  276. if fixmedins_code == "H15049901371" {
  277. url = gdyb_url
  278. } else {
  279. url = gdyb_url + "2201"
  280. }
  281. if insuplc_admdvs == "421300" {
  282. var json2 string
  283. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2201", string(bytesData), json2)
  284. out, err := cmd.Output()
  285. if err != nil {
  286. fmt.Println("error:", err.Error())
  287. }
  288. fmt.Println(string(out))
  289. return hex.EncodeToString(out), requestLog
  290. } else {
  291. request, err := http.NewRequest("POST", url, reader)
  292. if err != nil {
  293. fmt.Println(err.Error())
  294. return err.Error(), ""
  295. }
  296. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  297. request.Header.Set("x-tif-paasid", gdyb_paasid)
  298. request.Header.Set("x-tif-signature", signature)
  299. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  300. request.Header.Set("x-tif-nonce", nonce)
  301. client := http.Client{}
  302. resp, err := client.Do(request)
  303. if err != nil {
  304. fmt.Println(err.Error())
  305. return err.Error(), ""
  306. }
  307. respBytes, err := ioutil.ReadAll(resp.Body)
  308. if err != nil {
  309. fmt.Println(err.Error())
  310. return err.Error(), ""
  311. }
  312. str := string(respBytes)
  313. fmt.Println(str)
  314. return str, requestLog
  315. }
  316. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2201"
  317. }
  318. func Gdyb2201A(psnNo string, insutype string, certNo string, org_name string, opera string, ipt_otp_no string, dept string, fixmedins_code string, dept_code string, doctor_id string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, doctor_name string, record_time string, token string) (string, string) {
  319. fmt.Println(opera)
  320. // 生成签名
  321. nonce := GetRandomString(32)
  322. timestamp := time.Now().Unix()
  323. signature := setSignature(timestamp, nonce, secret_key)
  324. //tempTime := time.Unix(timestamp, 0)
  325. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  326. // 生成输入报文
  327. inputMessage := SetInputMessage(nonce, timestamp, org_name, opera, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  328. input := make(map[string]interface{})
  329. inputData := make(map[string]interface{})
  330. inputMessage["infno"] = "2201" // 交易编码
  331. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  332. inputData["insutype"] = insutype // 险种类型(来自1101接口返回)
  333. inputData["begntime"] = record_time // 开始时间
  334. if id_card_type == 1 {
  335. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  336. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  337. } else if id_card_type == 4 {
  338. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  339. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  340. } else {
  341. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  342. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  343. }
  344. inputData["ipt_otp_no"] = ipt_otp_no // 住院/门诊号
  345. inputData["atddr_no"] = doctor_id // 医师编码
  346. inputData["dr_name"] = doctor_name // 医师姓名
  347. inputData["dept_code"] = dept_code // 科室编码
  348. inputData["dept_name"] = dept // 科室名称
  349. inputData["caty"] = "A03.06" // 科别
  350. input["data"] = inputData
  351. inputMessage["input"] = input //交易输入
  352. var requestLog string
  353. bytesData, err := json.Marshal(inputMessage)
  354. requestLog = string(bytesData)
  355. fmt.Println(string(bytesData))
  356. if err != nil {
  357. fmt.Println(err.Error())
  358. return err.Error(), ""
  359. }
  360. reader := bytes.NewReader(bytesData)
  361. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2201"
  362. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2201"
  363. gdyb_url := beego.AppConfig.String("gdyb_url")
  364. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  365. var url string
  366. if fixmedins_code == "H15049901371" {
  367. url = gdyb_url
  368. } else {
  369. url = gdyb_url + "2201"
  370. }
  371. if insuplc_admdvs == "421300" {
  372. var json2 string
  373. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2201", string(bytesData), json2)
  374. out, err := cmd.Output()
  375. if err != nil {
  376. fmt.Println("error:", err.Error())
  377. }
  378. fmt.Println(string(out))
  379. return hex.EncodeToString(out), requestLog
  380. } else {
  381. request, err := http.NewRequest("POST", url, reader)
  382. if err != nil {
  383. fmt.Println(err.Error())
  384. return err.Error(), ""
  385. }
  386. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  387. request.Header.Set("x-tif-paasid", gdyb_paasid)
  388. request.Header.Set("x-tif-signature", signature)
  389. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  390. request.Header.Set("x-tif-nonce", nonce)
  391. client := http.Client{}
  392. resp, err := client.Do(request)
  393. if err != nil {
  394. fmt.Println(err.Error())
  395. return err.Error(), ""
  396. }
  397. respBytes, err := ioutil.ReadAll(resp.Body)
  398. if err != nil {
  399. fmt.Println(err.Error())
  400. return err.Error(), ""
  401. }
  402. str := string(respBytes)
  403. fmt.Println(str)
  404. return str, requestLog
  405. }
  406. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2201"
  407. }
  408. // 门诊挂号撤销
  409. func Gdyb2202(psnNo string, mdtrtId string, ipt_otp_no string, org_name string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, fixmedins_code string) (string, string) {
  410. // 生成签名
  411. nonce := GetRandomString(32)
  412. timestamp := time.Now().Unix()
  413. signature := setSignature(timestamp, nonce, secret_key)
  414. // 生成输入报文
  415. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  416. input := make(map[string]interface{})
  417. inputData := make(map[string]interface{})
  418. inputMessage["infno"] = "2202" // 交易编码
  419. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  420. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  421. inputData["ipt_otp_no"] = ipt_otp_no // 住院/门诊号
  422. input["data"] = inputData
  423. inputMessage["input"] = input //交易输入
  424. var requestLog string
  425. bytesData, err := json.Marshal(inputMessage)
  426. fmt.Println(string(bytesData))
  427. requestLog = string(bytesData)
  428. if err != nil {
  429. fmt.Println(err.Error())
  430. return err.Error(), ""
  431. }
  432. reader := bytes.NewReader(bytesData)
  433. gdyb_url := beego.AppConfig.String("gdyb_url")
  434. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  435. var url string
  436. if fixmedins_code == "H15049901371" {
  437. url = gdyb_url
  438. } else {
  439. url = gdyb_url + "2202"
  440. }
  441. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2202"
  442. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2202"
  443. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2202"
  444. if insuplc_admdvs == "421300" {
  445. var json2 string
  446. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2202", string(bytesData), json2)
  447. out, err := cmd.Output()
  448. if err != nil {
  449. fmt.Println("error:", err.Error())
  450. }
  451. fmt.Println(string(out))
  452. return hex.EncodeToString(out), requestLog
  453. } else {
  454. request, err := http.NewRequest("POST", url, reader)
  455. if err != nil {
  456. fmt.Println(err.Error())
  457. return err.Error(), ""
  458. }
  459. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  460. request.Header.Set("x-tif-paasid", gdyb_paasid)
  461. request.Header.Set("x-tif-signature", signature)
  462. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  463. request.Header.Set("x-tif-nonce", nonce)
  464. client := http.Client{}
  465. resp, err := client.Do(request)
  466. if err != nil {
  467. fmt.Println(err.Error())
  468. return err.Error(), ""
  469. }
  470. respBytes, err := ioutil.ReadAll(resp.Body)
  471. if err != nil {
  472. fmt.Println(err.Error())
  473. return err.Error(), ""
  474. }
  475. str := string(respBytes)
  476. fmt.Println(str)
  477. return str, requestLog
  478. }
  479. }
  480. // 门诊就诊信息上传
  481. func Gdyb2203(psnNo string, mdtrtId string, doctor string, department string, org_name string, med_type string, doctor_id string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, sick_code string, sick_name string, dept string, config []*models.HisXtDiagnoseConfig, begin_time string) (string, string) {
  482. // 生成签名
  483. nonce := GetRandomString(32)
  484. timestamp := time.Now().Unix()
  485. signature := setSignature(timestamp, nonce, secret_key)
  486. //tempTime := time.Unix(timestamp, 0)
  487. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  488. // 生成输入报文
  489. inputMessage := SetInputMessage(nonce, timestamp, org_name, dept, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  490. input := make(map[string]interface{})
  491. inputData := make(map[string]interface{})
  492. diseinfo := make([]map[string]interface{}, 0)
  493. if med_type == "1111" || med_type == "1112" {
  494. med_type = "11"
  495. }
  496. inputMessage["infno"] = "2203" // 交易编码
  497. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  498. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  499. inputData["med_type"] = med_type // 医疗类别 16门诊特殊病
  500. inputData["begntime"] = begin_time // 开始时间
  501. //inputData["begntime"] = // 开始时间
  502. inputData["main_cond_dscr"] = "" // 主要病情描述
  503. inputData["dise_codg"] = sick_code // 病种编码
  504. inputData["dise_name"] = sick_name // 病种名称
  505. inputData["birctrl_type"] = "" // 计划生育手术类别
  506. inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
  507. for index, item := range config {
  508. diseinfo_sun := make(map[string]interface{})
  509. diseinfo_sun["diag_type"] = "1" // 诊断类别
  510. diseinfo_sun["diag_srt_no"] = index // 诊断排序号
  511. diseinfo_sun["diag_code"] = item.CountryCode // 诊断代码
  512. diseinfo_sun["diag_name"] = item.ClassName // 诊断名称
  513. diseinfo_sun["diag_dept"] = department // 诊断科室
  514. diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
  515. diseinfo_sun["dise_dor_name"] = doctor // 诊断医生姓名
  516. diseinfo_sun["diag_time"] = begin_time // 诊断时间
  517. diseinfo_sun["vali_flag"] = "1" // 有效标志
  518. diseinfo = append(diseinfo, diseinfo_sun)
  519. }
  520. input["diseinfo"] = diseinfo
  521. input["mdtrtinfo"] = inputData
  522. inputMessage["input"] = input //交易输入
  523. var requestLog string
  524. bytesData, err := json.Marshal(inputMessage)
  525. fmt.Println(string(bytesData))
  526. requestLog = string(bytesData)
  527. if err != nil {
  528. fmt.Println(err.Error())
  529. return err.Error(), ""
  530. }
  531. reader := bytes.NewReader(bytesData)
  532. gdyb_url := beego.AppConfig.String("gdyb_url")
  533. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  534. var url string
  535. if fixmedins_code == "H15049901371" {
  536. url = gdyb_url
  537. } else {
  538. url = gdyb_url + "2203"
  539. }
  540. if insuplc_admdvs == "421300" {
  541. var json2 string
  542. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2203", string(bytesData), json2)
  543. out, err := cmd.Output()
  544. if err != nil {
  545. fmt.Println("error:", err.Error())
  546. }
  547. fmt.Println(string(out))
  548. return hex.EncodeToString(out), requestLog
  549. } else {
  550. request, err := http.NewRequest("POST", url, reader)
  551. if err != nil {
  552. fmt.Println(err.Error())
  553. return err.Error(), ""
  554. }
  555. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  556. request.Header.Set("x-tif-paasid", gdyb_paasid)
  557. request.Header.Set("x-tif-signature", signature)
  558. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  559. request.Header.Set("x-tif-nonce", nonce)
  560. client := http.Client{}
  561. resp, err := client.Do(request)
  562. if err != nil {
  563. fmt.Println(err.Error())
  564. return err.Error(), ""
  565. }
  566. respBytes, err := ioutil.ReadAll(resp.Body)
  567. if err != nil {
  568. fmt.Println(err.Error())
  569. return err.Error(), ""
  570. }
  571. str := string(respBytes)
  572. fmt.Println(str)
  573. return str, requestLog
  574. }
  575. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2203"
  576. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  577. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  578. }
  579. // 门诊就诊信息上传
  580. func Gdyb2203A(psnNo string, mdtrtId string, doctor string, department string, org_name string, med_type string, doctor_id string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, sick_code string, sick_name string, dept string, config []*models.HisXtDiagnoseConfig, begin_time string) (string, string) {
  581. // 生成签名
  582. nonce := GetRandomString(32)
  583. timestamp := time.Now().Unix()
  584. signature := setSignature(timestamp, nonce, secret_key)
  585. tempTime := time.Unix(timestamp, 0)
  586. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  587. // 生成输入报文
  588. inputMessage := SetInputMessage(nonce, timestamp, org_name, dept, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  589. input := make(map[string]interface{})
  590. inputData := make(map[string]interface{})
  591. diseinfo := make([]map[string]interface{}, 0)
  592. if med_type == "1111" || med_type == "1112" {
  593. med_type = "11"
  594. }
  595. inputMessage["infno"] = "2203A" // 交易编码
  596. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  597. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  598. inputData["med_type"] = med_type // 医疗类别 16门诊特殊病
  599. inputData["begntime"] = begin_time // 开始时间
  600. inputData["main_cond_dscr"] = "" // 主要病情描述
  601. inputData["dise_codg"] = sick_code // 病种编码
  602. inputData["dise_name"] = sick_name // 病种名称
  603. inputData["birctrl_type"] = "" // 计划生育手术类别
  604. inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
  605. inputData["matn_type"] = "" // 生育类别
  606. inputData["geso_val"] = "" // 孕周数
  607. for index, item := range config {
  608. diseinfo_sun := make(map[string]interface{})
  609. diseinfo_sun["diag_type"] = "1" // 诊断类别
  610. diseinfo_sun["diag_srt_no"] = index // 诊断排序号
  611. diseinfo_sun["diag_code"] = item.CountryCode // 诊断代码
  612. diseinfo_sun["diag_name"] = item.ClassName // 诊断名称
  613. diseinfo_sun["diag_dept"] = department // 诊断科室
  614. diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
  615. diseinfo_sun["dise_dor_name"] = doctor // 诊断医生姓名
  616. diseinfo_sun["diag_time"] = timeFormatOne // 诊断时间
  617. diseinfo_sun["vali_flag"] = "1" // 有效标志
  618. diseinfo = append(diseinfo, diseinfo_sun)
  619. }
  620. input["diseinfo"] = diseinfo
  621. input["mdtrtinfo"] = inputData
  622. inputMessage["input"] = input //交易输入
  623. var requestLog string
  624. bytesData, err := json.Marshal(inputMessage)
  625. fmt.Println(string(bytesData))
  626. requestLog = string(bytesData)
  627. if err != nil {
  628. fmt.Println(err.Error())
  629. return err.Error(), ""
  630. }
  631. reader := bytes.NewReader(bytesData)
  632. gdyb_url := beego.AppConfig.String("gdyb_url")
  633. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  634. var url string
  635. if fixmedins_code == "H15049901371" {
  636. url = gdyb_url
  637. } else {
  638. url = gdyb_url + "2203A"
  639. }
  640. if insuplc_admdvs == "421300" {
  641. var json2 string
  642. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2203A", string(bytesData), json2)
  643. out, err := cmd.Output()
  644. if err != nil {
  645. fmt.Println("error:", err.Error())
  646. }
  647. fmt.Println(string(out))
  648. return hex.EncodeToString(out), requestLog
  649. } else {
  650. request, err := http.NewRequest("POST", url, reader)
  651. if err != nil {
  652. fmt.Println(err.Error())
  653. return err.Error(), ""
  654. }
  655. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  656. request.Header.Set("x-tif-paasid", gdyb_paasid)
  657. request.Header.Set("x-tif-signature", signature)
  658. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  659. request.Header.Set("x-tif-nonce", nonce)
  660. client := http.Client{}
  661. resp, err := client.Do(request)
  662. if err != nil {
  663. fmt.Println(err.Error())
  664. return err.Error(), ""
  665. }
  666. respBytes, err := ioutil.ReadAll(resp.Body)
  667. if err != nil {
  668. fmt.Println(err.Error())
  669. return err.Error(), ""
  670. }
  671. str := string(respBytes)
  672. fmt.Println(str)
  673. return str, requestLog
  674. }
  675. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2203A"
  676. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  677. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  678. }
  679. type Custom struct {
  680. DetItemFeeSumamt string
  681. Cut string
  682. FeedetlSn string
  683. Price string
  684. MedListCodg string
  685. LmtUsedFlag int64
  686. HospApprFlag int64
  687. DoctorNumber string
  688. DoctorName string
  689. ProvinceDrugMedListCodg string
  690. ProvinceGoodMedListCodg string
  691. IsUser int64
  692. FeeOcurTime string
  693. Unit string
  694. }
  695. type RequestResult struct {
  696. Output Output `json:"output" form:"output"`
  697. Infcode int64 `gorm:"column:infcode" json:"infcode" form:"infcode"`
  698. WarnMsg string `gorm:"column:warn_msg" json:"warn_msg" form:"warn_msg"`
  699. Cainfo string `gorm:"column:cainfo" json:"cainfo" form:"cainfo"`
  700. ErrMsg string `gorm:"column:err_msg" json:"err_msg" form:"err_msg"`
  701. RespondTime string `gorm:"column:respond_time" json:"respond_time" form:"respond_time"`
  702. InfRefmsgid string `gorm:"column:inf_refmsgid" json:"inf_refmsgid" form:"inf_refmsgid"`
  703. }
  704. type Output struct {
  705. Result Result `json:"result" form:"result"`
  706. }
  707. type Result struct {
  708. BasMednFlag string `json:"bas_medn_flag" form:"bas_medn_flag"`
  709. MedChrgitmType string `json:"med_chrgitm_type" form:"med_chrgitm_type"`
  710. DetItemFeeSumamt int64 `json:"det_item_fee_sumamt" form:"det_item_fee_sumamt"`
  711. HiNegoDrugFlag string `json:"hi_nego_drug_flag" form:"hi_nego_drug_flag"`
  712. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
  713. FeedtlSn int64 `json:"feedtl_sn" form:"feedtl_sn"`
  714. UploadDate int64 `json:"upload_date" form:"upload_date"`
  715. AdviceId int64 `json:"advice_id" form:"advice_id"`
  716. Cnt int64 `json:"cnt" form:"cnt"`
  717. Pric float64 `json:"pric" form:"pric"`
  718. PatientId int64 `json:"patient_id" form:"patient_id"`
  719. PricUplmtAmt float64 `json:"pric_uplmt_amt" form:"pric_uplmt_amt"`
  720. SelfpayProp float64 `json:"selfpay_prop" form:"selfpay_prop"`
  721. OverlmtAmt float64 `json:"overlmt_amt" form:"overlmt_amt"`
  722. PreselfpayAmt float64 `json:"preselfpay_amt" form:"preselfpay_amt"`
  723. Status int64 `json:"status" form:"status"`
  724. Memo string `json:"memo" form:"memo"`
  725. FeedetlSn string `json:"feedetl_sn" form:"feedetl_sn"`
  726. Mtime int64 `json:"mtime" form:"mtime"`
  727. InscpScpAmt float64 `json:"inscp_scp_amt" form:"inscp_scp_amt"`
  728. DrtReimFlag string `json:"drt_reim_flag" form:"drt_reim_flag"`
  729. Ctime int64 `json:"ctime" form:"ctime"`
  730. ListSpItemFlag string `json:"list_sp_item_flag" form:"list_sp_item_flag"`
  731. ChldMedcFlag string `json:"chld_medc_flag" form:"chld_medc_flag"`
  732. LmtUsedFlag string `json:"lmt_used_flag" form:"lmt_used_flag"`
  733. ChrgitmLv string `json:"chrgitm_lv" form:"chrgitm_lv"`
  734. UserOrgId int64 `json:"user_org_id" form:"user_org_id"`
  735. HisPatientId int64 `json:"his_patient_id" form:"his_patient_id"`
  736. OrderId int64 `json:"order_id" form:"order_id"`
  737. }
  738. // 门诊费用明细信息上传
  739. 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, balance_accounts_type string, new_doctor_id int64, diag_code string) (string, string) {
  740. // 生成签名
  741. nonce := GetRandomString(32)
  742. timestamp := time.Now().Unix()
  743. signature := setSignature(timestamp, nonce, secret_key)
  744. //tempTime := time.Unix(timestamp, 0)
  745. //timeFormat := tempTime.Format("20060102150405")
  746. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  747. //chrgBchno := rand.Intn(100000) + 10000
  748. var customs []*Custom
  749. for _, item := range hisPrescription {
  750. role, _ := GetAdminUserInfoByID(item.UserOrgId, new_doctor_id)
  751. tm := time.Unix(item.PreTime, 0)
  752. if item.Type == 1 { //药品
  753. for _, subItem := range item.HisDoctorAdviceInfo {
  754. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 && subItem.BaseDrugLib.IsUser != 1 {
  755. //var randNum int
  756. //randNum = rand.Intn(10000) + 1000
  757. role, _ := GetAdminUserInfoByID(item.UserOrgId, new_doctor_id)
  758. cus := &Custom{
  759. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber),
  760. Cut: fmt.Sprintf("%.4f", subItem.PrescribingNumber),
  761. FeedetlSn: subItem.FeedetlSn,
  762. Price: fmt.Sprintf("%.4f", subItem.Price),
  763. MedListCodg: subItem.BaseDrugLib.MedicalInsuranceNumber,
  764. HospApprFlag: subItem.HospApprFlag,
  765. DoctorNumber: role.DoctorNumber,
  766. DoctorName: role.UserName,
  767. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  768. }
  769. customs = append(customs, cus)
  770. }
  771. }
  772. }
  773. if item.Type == 2 { //项目
  774. for _, subItem := range item.HisPrescriptionProject {
  775. //var randNum int
  776. //randNum = rand.Intn(10000) + 1000
  777. if subItem.Type == 2 {
  778. if len(subItem.HisProject.MedicalCode) > 0 {
  779. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  780. cus := &Custom{
  781. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  782. Cut: fmt.Sprintf("%.4f", cnt),
  783. FeedetlSn: subItem.FeedetlSn,
  784. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  785. MedListCodg: subItem.HisProject.MedicalCode,
  786. DoctorNumber: role.DoctorNumber,
  787. DoctorName: role.UserName,
  788. HospApprFlag: -1,
  789. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  790. }
  791. customs = append(customs, cus)
  792. }
  793. } else if subItem.Type == 3 {
  794. if len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  795. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  796. cus := &Custom{
  797. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  798. Cut: fmt.Sprintf("%.4f", cnt),
  799. FeedetlSn: subItem.FeedetlSn,
  800. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  801. MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
  802. HospApprFlag: -1,
  803. DoctorNumber: role.DoctorNumber,
  804. DoctorName: role.UserName,
  805. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  806. }
  807. customs = append(customs, cus)
  808. }
  809. }
  810. }
  811. }
  812. for _, subItem := range item.HisAdditionalCharge {
  813. if len(subItem.XtHisAddtionConfig.Code) > 0 {
  814. cus := &Custom{
  815. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*float64(subItem.Count)),
  816. Cut: fmt.Sprintf("%.4f", float64(subItem.Count)),
  817. FeedetlSn: subItem.FeedetlSn,
  818. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  819. MedListCodg: subItem.XtHisAddtionConfig.Code,
  820. HospApprFlag: -1,
  821. DoctorNumber: role.DoctorNumber,
  822. DoctorName: role.UserName,
  823. }
  824. customs = append(customs, cus)
  825. }
  826. }
  827. }
  828. // 生成输入报文
  829. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  830. input := make(map[string]interface{})
  831. feedetail := make([]map[string]interface{}, 0)
  832. inputMessage["infno"] = "2204" // 交易编码
  833. //chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  834. for _, item := range customs {
  835. feedetailInfo := make(map[string]interface{})
  836. feedetailInfo["feedetl_sn"] = item.FeedetlSn
  837. feedetailInfo["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  838. feedetailInfo["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  839. feedetailInfo["chrg_bchno"] = chrg_bchno // 收费批次号
  840. feedetailInfo["dise_codg"] = diag_code // 病种编码
  841. feedetailInfo["rxno"] = "" // 处方号
  842. feedetailInfo["rx_circ_flag"] = "0" // 外购处方标志
  843. feedetailInfo["fee_ocur_time"] = item.FeeOcurTime // 费用发生时间
  844. feedetailInfo["med_list_codg"] = item.MedListCodg // 医疗目录编码
  845. feedetailInfo["medins_list_codg"] = fixmedins_code // 医药机构目录编码
  846. feedetailInfo["det_item_fee_sumamt"] = item.DetItemFeeSumamt // 明细项目费用总额
  847. feedetailInfo["cnt"] = item.Cut // 数量
  848. feedetailInfo["pric"] = item.Price // 单价
  849. feedetailInfo["sin_dos_dscr"] = "" // 单次剂量描述
  850. feedetailInfo["used_frqu_dscr"] = "" // 使用频次描述
  851. feedetailInfo["prd_days"] = "0" // 周期天数
  852. feedetailInfo["medc_way_dscr"] = "" // 用药途径描述
  853. feedetailInfo["bilg_dept_codg"] = dept_code // 开单科室编码
  854. feedetailInfo["bilg_dept_name"] = dept // 开单科室名称
  855. feedetailInfo["bilg_dr_codg"] = item.DoctorNumber // 开单医生编码
  856. feedetailInfo["bilg_dr_name"] = item.DoctorName // 开单医师姓名
  857. feedetailInfo["acord_dept_codg"] = "" // 受单科室编码
  858. feedetailInfo["acord_dept_name"] = "" // 受单科室名称
  859. feedetailInfo["orders_dr_code"] = item.DoctorNumber // 受单医生编码
  860. feedetailInfo["orders_dr_name"] = item.DoctorName // 受单医生姓名
  861. if balance_accounts_type == "8" {
  862. feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
  863. } else {
  864. if item.HospApprFlag != -1 {
  865. if item.HospApprFlag == 1 {
  866. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  867. } else if item.HospApprFlag == 2 {
  868. feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
  869. } else if item.HospApprFlag == 3 {
  870. feedetailInfo["hosp_appr_flag"] = "0" // 医院审批标志
  871. } else {
  872. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  873. }
  874. } else {
  875. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  876. }
  877. }
  878. //feedetailInfo["tcmdrug_used_way"] = "" // 中药使用方式
  879. feedetailInfo["etip_flag"] = "" // 外检标志
  880. feedetailInfo["etip_hosp_code"] = "" // 外检医院编码
  881. feedetailInfo["dscg_tkdrug_flag"] = "" // 出院带药标志
  882. feedetailInfo["matn_fee_flag"] = "" // 生育费用标志
  883. feedetail = append(feedetail, feedetailInfo)
  884. }
  885. input["feedetail"] = feedetail
  886. inputMessage["input"] = input //交易输入
  887. var requestLog string
  888. bytesData, err := json.Marshal(inputMessage)
  889. fmt.Println("----------")
  890. fmt.Println(string(bytesData))
  891. fmt.Println("----------")
  892. requestLog = string(bytesData)
  893. if err != nil {
  894. fmt.Println(err.Error())
  895. return "", ""
  896. }
  897. reader := bytes.NewReader(bytesData)
  898. gdyb_url := beego.AppConfig.String("gdyb_url")
  899. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  900. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  901. var url string
  902. if fixmedins_code == "H15049901371" {
  903. url = gdyb_url
  904. } else {
  905. url = gdyb_url + "2204"
  906. }
  907. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2204"
  908. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2204"
  909. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2204"
  910. if insuplc_admdvs == "421300" {
  911. var json2 string
  912. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2204", string(bytesData), json2)
  913. out, err := cmd.Output()
  914. if err != nil {
  915. fmt.Println("error:", err.Error())
  916. }
  917. fmt.Println(string(out))
  918. return hex.EncodeToString(out), requestLog
  919. } else {
  920. request, err := http.NewRequest("POST", url, reader)
  921. if err != nil {
  922. fmt.Println(err.Error())
  923. return "", ""
  924. }
  925. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  926. request.Header.Set("x-tif-paasid", gdyb_paasid)
  927. request.Header.Set("x-tif-signature", signature)
  928. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  929. request.Header.Set("x-tif-nonce", nonce)
  930. client := http.Client{}
  931. resp, err := client.Do(request)
  932. if err != nil {
  933. fmt.Println(err.Error())
  934. return "", ""
  935. }
  936. respBytes, err := ioutil.ReadAll(resp.Body)
  937. if err != nil {
  938. fmt.Println(err.Error())
  939. return "", ""
  940. }
  941. return string(respBytes), requestLog
  942. }
  943. //var result RequestResult
  944. //json.Unmarshal(respBytes, &result)
  945. //return &result
  946. }
  947. // 门诊费用明细信息撤销
  948. 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, string) {
  949. // 生成签名
  950. nonce := GetRandomString(32)
  951. timestamp := time.Now().Unix()
  952. signature := setSignature(timestamp, nonce, secret_key)
  953. // 生成输入报文
  954. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  955. input := make(map[string]interface{})
  956. inputData := make(map[string]interface{})
  957. inputMessage["infno"] = "2205" // 交易编码
  958. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  959. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  960. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  961. input["data"] = inputData
  962. inputMessage["input"] = input //交易输入
  963. bytesData, err := json.Marshal(inputMessage)
  964. fmt.Println(string(bytesData))
  965. var requestLog string
  966. requestLog = string(bytesData)
  967. if err != nil {
  968. fmt.Println(err.Error())
  969. return err.Error(), ""
  970. }
  971. reader := bytes.NewReader(bytesData)
  972. gdyb_url := beego.AppConfig.String("gdyb_url")
  973. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  974. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  975. //url := gdyb_url + "2205"
  976. var url string
  977. if fixmedins_code == "H15049901371" {
  978. url = gdyb_url
  979. } else {
  980. url = gdyb_url + "2205"
  981. }
  982. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2205"
  983. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2205"
  984. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2205"
  985. if insuplc_admdvs == "421300" {
  986. var json2 string
  987. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2205", string(bytesData), json2)
  988. out, err := cmd.Output()
  989. if err != nil {
  990. fmt.Println("error:", err.Error())
  991. }
  992. fmt.Println(string(out))
  993. return hex.EncodeToString(out), requestLog
  994. } else {
  995. request, err := http.NewRequest("POST", url, reader)
  996. fmt.Println(err)
  997. fmt.Println(request)
  998. if err != nil {
  999. fmt.Println(err.Error())
  1000. return err.Error(), ""
  1001. }
  1002. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1003. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1004. request.Header.Set("x-tif-signature", signature)
  1005. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1006. request.Header.Set("x-tif-nonce", nonce)
  1007. client := http.Client{}
  1008. resp, err := client.Do(request)
  1009. if err != nil {
  1010. fmt.Println(err.Error())
  1011. return err.Error(), ""
  1012. }
  1013. respBytes, err := ioutil.ReadAll(resp.Body)
  1014. if err != nil {
  1015. fmt.Println(err.Error())
  1016. return err.Error(), ""
  1017. }
  1018. str := string(respBytes)
  1019. fmt.Println(str)
  1020. return str, requestLog
  1021. }
  1022. }
  1023. // 门诊预结算
  1024. //func Gdyb2206(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string, total string, org_name string, doctor string, secret_key string) string {
  1025. func Gdyb2206(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string, total string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, med_type string, id_card_type int64, fulamt_ownpay_amt float64, overlmt_selfpay float64, preselfpay_amt float64, inscp_scp_amt float64, certificates int64) (string, string) {
  1026. // 生成签名
  1027. nonce := GetRandomString(32)
  1028. timestamp := time.Now().Unix()
  1029. signature := setSignature(timestamp, nonce, secret_key)
  1030. // 生成输入报文
  1031. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1032. input := make(map[string]interface{})
  1033. inputData := make(map[string]interface{})
  1034. inputMessage["infno"] = "2206" // 交易编码
  1035. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1036. if certificates == 3 {
  1037. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  1038. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1039. } else {
  1040. if id_card_type == 1 {
  1041. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  1042. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1043. } else {
  1044. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  1045. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1046. }
  1047. }
  1048. if insuplc_admdvs == "421300" {
  1049. if med_type == "11" || med_type == "1112" || med_type == "1111" {
  1050. inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
  1051. } else if med_type == "14" {
  1052. inputData["med_type"] = "140110" // 医疗类别 11 普通门诊 12 门诊挂号
  1053. }
  1054. } else {
  1055. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  1056. }
  1057. inputData["medfee_sumamt"] = total // 医疗费总额
  1058. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  1059. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1060. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  1061. inputData["acct_used_flag"] = "0" // 个人账户使用标志 0否 1是
  1062. inputData["insutype"] = insutype // 险种类型
  1063. inputData["invono"] = "" // 发票号
  1064. input["data"] = inputData
  1065. inputMessage["input"] = input //交易输入
  1066. var requestLog string
  1067. bytesData, err := json.Marshal(inputMessage)
  1068. requestLog = string(bytesData)
  1069. fmt.Println(string(bytesData))
  1070. if err != nil {
  1071. fmt.Println(err.Error())
  1072. return err.Error(), ""
  1073. }
  1074. reader := bytes.NewReader(bytesData)
  1075. gdyb_url := beego.AppConfig.String("gdyb_url")
  1076. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1077. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1078. //url := gdyb_url + "2206"
  1079. var url string
  1080. if fixmedins_code == "H15049901371" {
  1081. url = gdyb_url
  1082. } else {
  1083. url = gdyb_url + "2206"
  1084. }
  1085. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2206"
  1086. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2206"
  1087. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2206"
  1088. if insuplc_admdvs == "421300" {
  1089. var json2 string
  1090. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2206", string(bytesData), json2)
  1091. out, err := cmd.Output()
  1092. if err != nil {
  1093. fmt.Println("error:", err.Error())
  1094. }
  1095. fmt.Println(string(out))
  1096. return hex.EncodeToString(out), requestLog
  1097. } else {
  1098. request, err := http.NewRequest("POST", url, reader)
  1099. if err != nil {
  1100. fmt.Println(err.Error())
  1101. return err.Error(), ""
  1102. }
  1103. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1104. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1105. request.Header.Set("x-tif-signature", signature)
  1106. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1107. request.Header.Set("x-tif-nonce", nonce)
  1108. client := http.Client{}
  1109. resp, err := client.Do(request)
  1110. if err != nil {
  1111. fmt.Println(err.Error())
  1112. return err.Error(), ""
  1113. }
  1114. respBytes, err := ioutil.ReadAll(resp.Body)
  1115. if err != nil {
  1116. fmt.Println(err.Error())
  1117. return err.Error(), ""
  1118. }
  1119. str := string(respBytes)
  1120. fmt.Println(str)
  1121. return str, requestLog
  1122. }
  1123. }
  1124. // 门诊结算
  1125. 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, med_type string, id_card_type int64, fulamt_ownpay_amt float64, overlmt_selfpay float64, preselfpay_amt float64, inscp_scp_amt float64, certificates int64, acct_used_flag string) (string, string) {
  1126. // 生成签名
  1127. nonce := GetRandomString(32)
  1128. timestamp := time.Now().Unix()
  1129. signature := setSignature(timestamp, nonce, secret_key)
  1130. // 生成输入报文
  1131. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1132. input := make(map[string]interface{})
  1133. inputData := make(map[string]interface{})
  1134. inputMessage["infno"] = "2207" // 交易编码
  1135. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1136. if certificates == 3 {
  1137. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  1138. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1139. } else {
  1140. if id_card_type == 1 {
  1141. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  1142. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1143. } else {
  1144. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  1145. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1146. }
  1147. }
  1148. if med_type == "1111" || med_type == "1112" {
  1149. med_type = "11"
  1150. }
  1151. if insuplc_admdvs == "421300" {
  1152. if med_type == "11" {
  1153. inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
  1154. } else if med_type == "14" {
  1155. inputData["med_type"] = "140101" // 医疗类别 11 普通门诊 12 门诊挂号
  1156. }
  1157. } else {
  1158. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  1159. }
  1160. inputData["medfee_sumamt"] = total // 医疗费总额
  1161. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  1162. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1163. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  1164. inputData["acct_used_flag"] = acct_used_flag // 个人账户使用标志 0否 1是
  1165. inputData["insutype"] = insutype // 险种类型
  1166. inputData["invono"] = "" // 发票号
  1167. inputData["fulamt_ownpay_amt"] = fulamt_ownpay_amt //
  1168. inputData["overlmt_selfpay"] = overlmt_selfpay //
  1169. inputData["preselfpay_amt"] = preselfpay_amt //
  1170. inputData["inscp_scp_amt"] = inscp_scp_amt //
  1171. input["data"] = inputData
  1172. inputMessage["input"] = input //交易输入
  1173. bytesData, err := json.Marshal(inputMessage)
  1174. fmt.Println(string(bytesData))
  1175. if err != nil {
  1176. fmt.Println(err.Error())
  1177. return err.Error(), ""
  1178. }
  1179. reader := bytes.NewReader(bytesData)
  1180. gdyb_url := beego.AppConfig.String("gdyb_url")
  1181. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1182. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1183. //url := gdyb_url + "2207"
  1184. var url string
  1185. if fixmedins_code == "H15049901371" {
  1186. url = gdyb_url
  1187. } else {
  1188. url = gdyb_url + "2207"
  1189. }
  1190. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2207"
  1191. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  1192. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  1193. if insuplc_admdvs == "421300" {
  1194. var json2 string
  1195. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2207", string(bytesData), json2)
  1196. out, err := cmd.Output()
  1197. if err != nil {
  1198. fmt.Println("error:", err.Error())
  1199. }
  1200. mjson, _ := json.Marshal(inputMessage)
  1201. str2 := string(mjson)
  1202. fmt.Println(string(out))
  1203. return hex.EncodeToString(out), str2
  1204. } else {
  1205. request, err := http.NewRequest("POST", url, reader)
  1206. if err != nil {
  1207. fmt.Println(err.Error())
  1208. return err.Error(), ""
  1209. }
  1210. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1211. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1212. request.Header.Set("x-tif-signature", signature)
  1213. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1214. request.Header.Set("x-tif-nonce", nonce)
  1215. client := http.Client{}
  1216. resp, err := client.Do(request)
  1217. if err != nil {
  1218. fmt.Println(err.Error())
  1219. return err.Error(), ""
  1220. }
  1221. respBytes, err := ioutil.ReadAll(resp.Body)
  1222. if err != nil {
  1223. fmt.Println(err.Error())
  1224. return err.Error(), ""
  1225. }
  1226. str := string(respBytes)
  1227. fmt.Println(str)
  1228. mjson, _ := json.Marshal(inputMessage)
  1229. str2 := string(mjson)
  1230. return str, str2
  1231. }
  1232. }
  1233. func Gdyb2207A(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string, total string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, med_type string, id_card_type int64, fulamt_ownpay_amt float64, overlmt_selfpay float64, preselfpay_amt float64, inscp_scp_amt float64, certificates int64, acct_used_flag string) (string, string) {
  1234. // 生成签名
  1235. nonce := GetRandomString(32)
  1236. timestamp := time.Now().Unix()
  1237. signature := setSignature(timestamp, nonce, secret_key)
  1238. // 生成输入报文
  1239. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1240. input := make(map[string]interface{})
  1241. inputData := make(map[string]interface{})
  1242. inputMessage["infno"] = "2207A" // 交易编码
  1243. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1244. if certificates == 3 {
  1245. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  1246. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1247. } else {
  1248. if id_card_type == 1 {
  1249. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  1250. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1251. } else {
  1252. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  1253. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1254. }
  1255. }
  1256. if med_type == "1111" || med_type == "1112" {
  1257. med_type = "11"
  1258. }
  1259. if insuplc_admdvs == "421300" {
  1260. if med_type == "11" {
  1261. inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
  1262. } else if med_type == "14" {
  1263. inputData["med_type"] = "140101" // 医疗类别 11 普通门诊 12 门诊挂号
  1264. }
  1265. } else {
  1266. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  1267. }
  1268. inputData["medfee_sumamt"] = total // 医疗费总额
  1269. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  1270. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1271. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  1272. inputData["acct_used_flag"] = acct_used_flag // 个人账户使用标志 0否 1是
  1273. inputData["insutype"] = insutype // 险种类型
  1274. inputData["invono"] = "" // 发票号
  1275. inputData["fulamt_ownpay_amt"] = fulamt_ownpay_amt //
  1276. inputData["overlmt_selfpay"] = overlmt_selfpay //
  1277. inputData["preselfpay_amt"] = preselfpay_amt //
  1278. inputData["inscp_scp_amt"] = inscp_scp_amt //
  1279. input["data"] = inputData
  1280. inputMessage["input"] = input //交易输入
  1281. bytesData, err := json.Marshal(inputMessage)
  1282. fmt.Println(string(bytesData))
  1283. if err != nil {
  1284. fmt.Println(err.Error())
  1285. return err.Error(), ""
  1286. }
  1287. reader := bytes.NewReader(bytesData)
  1288. gdyb_url := beego.AppConfig.String("gdyb_url")
  1289. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1290. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1291. //url := gdyb_url + "2207"
  1292. var url string
  1293. if fixmedins_code == "H15049901371" {
  1294. url = gdyb_url
  1295. } else {
  1296. url = gdyb_url + "2207"
  1297. }
  1298. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2207"
  1299. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  1300. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  1301. if insuplc_admdvs == "421300" {
  1302. var json2 string
  1303. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2207", string(bytesData), json2)
  1304. out, err := cmd.Output()
  1305. if err != nil {
  1306. fmt.Println("error:", err.Error())
  1307. }
  1308. mjson, _ := json.Marshal(inputMessage)
  1309. str2 := string(mjson)
  1310. fmt.Println(string(out))
  1311. return hex.EncodeToString(out), str2
  1312. } else {
  1313. request, err := http.NewRequest("POST", url, reader)
  1314. if err != nil {
  1315. fmt.Println(err.Error())
  1316. return err.Error(), ""
  1317. }
  1318. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1319. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1320. request.Header.Set("x-tif-signature", signature)
  1321. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1322. request.Header.Set("x-tif-nonce", nonce)
  1323. client := http.Client{}
  1324. resp, err := client.Do(request)
  1325. if err != nil {
  1326. fmt.Println(err.Error())
  1327. return err.Error(), ""
  1328. }
  1329. respBytes, err := ioutil.ReadAll(resp.Body)
  1330. if err != nil {
  1331. fmt.Println(err.Error())
  1332. return err.Error(), ""
  1333. }
  1334. str := string(respBytes)
  1335. fmt.Println(str)
  1336. mjson, _ := json.Marshal(inputMessage)
  1337. str2 := string(mjson)
  1338. return str, str2
  1339. }
  1340. }
  1341. // 门诊结算撤销
  1342. 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, string) {
  1343. // 生成签名
  1344. nonce := GetRandomString(32)
  1345. timestamp := time.Now().Unix()
  1346. signature := setSignature(timestamp, nonce, secret_key)
  1347. // 生成输入报文
  1348. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1349. input := make(map[string]interface{})
  1350. inputData := make(map[string]interface{})
  1351. inputMessage["infno"] = "2208" // 交易编码
  1352. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1353. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1354. inputData["setl_id"] = setlId // 结算 ID
  1355. input["data"] = inputData
  1356. inputMessage["input"] = input //交易输入
  1357. bytesData, err := json.Marshal(inputMessage)
  1358. fmt.Println(string(bytesData))
  1359. if err != nil {
  1360. fmt.Println(err.Error())
  1361. return err.Error(), ""
  1362. }
  1363. reader := bytes.NewReader(bytesData)
  1364. gdyb_url := beego.AppConfig.String("gdyb_url")
  1365. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1366. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1367. //url := gdyb_url + "2208"
  1368. var url string
  1369. if fixmedins_code == "H15049901371" {
  1370. url = gdyb_url
  1371. } else {
  1372. url = gdyb_url + "2208"
  1373. }
  1374. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2208"
  1375. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2208"
  1376. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2208"
  1377. if insuplc_admdvs == "421300" {
  1378. var json2 string
  1379. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2208", string(bytesData), json2)
  1380. out, err := cmd.Output()
  1381. if err != nil {
  1382. fmt.Println("error:", err.Error())
  1383. }
  1384. mjson, _ := json.Marshal(inputMessage)
  1385. str2 := string(mjson)
  1386. fmt.Println(string(out))
  1387. return hex.EncodeToString(out), str2
  1388. } else {
  1389. request, err := http.NewRequest("POST", url, reader)
  1390. if err != nil {
  1391. fmt.Println(err.Error())
  1392. return err.Error(), ""
  1393. }
  1394. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1395. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1396. request.Header.Set("x-tif-signature", signature)
  1397. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1398. request.Header.Set("x-tif-nonce", nonce)
  1399. client := http.Client{}
  1400. resp, err := client.Do(request)
  1401. if err != nil {
  1402. fmt.Println(err.Error())
  1403. return err.Error(), ""
  1404. }
  1405. respBytes, err := ioutil.ReadAll(resp.Body)
  1406. if err != nil {
  1407. fmt.Println(err.Error())
  1408. return err.Error(), ""
  1409. }
  1410. str := string(respBytes)
  1411. fmt.Println(str)
  1412. mjson, _ := json.Marshal(inputMessage)
  1413. str2 := string(mjson)
  1414. return str, str2
  1415. }
  1416. }
  1417. //确认订单
  1418. func Gdyb6201(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, order models.HisOrder) string {
  1419. // 生成签名
  1420. nonce := GetRandomString(32)
  1421. timestamp := time.Now().Unix()
  1422. signature := setSignature(timestamp, nonce, secret_key)
  1423. // 生成输入报文
  1424. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1425. input := make(map[string]interface{})
  1426. inputData := make(map[string]interface{})
  1427. inputMessage["infno"] = "6201" // 交易编码
  1428. inputData["mdtrt_id"] = order.MdtrtId
  1429. inputData["chrg_bchno"] = order.Number
  1430. inputData["psn_no"] = order.PsnNo
  1431. inputData["psn_name"] = order.PsnName
  1432. inputData["psn_cert_type"] = order.PsnCertType
  1433. inputData["certno"] = order.Certno
  1434. inputData["insutype"] = order.Insutype
  1435. inputData["med_type"] = order.MedType
  1436. inputData["medfee_sumamt"] = order.MedfeeSumamt
  1437. inputData["fulamt_ownpay_amt"] = order.FulamtOwnpayAmt
  1438. inputData["overlmt_selfpay"] = order.OverlmtSelfPay
  1439. inputData["preselfpay_amt"] = order.PreselfpayAmt
  1440. inputData["inscp_scp_amt"] = order.InscpScpAmt
  1441. inputData["act_pay_dedc"] = order.ActPayDedc
  1442. inputData["hifp_pay"] = order.HifpPay
  1443. inputData["pool_prop_selfpay"] = order.PoolPropSelfpay
  1444. inputData["cvlserv_pay"] = order.CvlservPay
  1445. inputData["hifes_pay"] = order.HifesPay
  1446. inputData["hifmi_pay"] = order.HifmiPay
  1447. inputData["hifob_pay"] = order.HifobPay
  1448. inputData["maf_pay"] = order.MafPay
  1449. inputData["oth_pay"] = order.OthPay
  1450. inputData["fund_pay_sumamt"] = order.FundPaySumamt
  1451. inputData["psn_part_amt"] = order.PsnPartAmt
  1452. inputData["acct_pay"] = order.AcctPay
  1453. inputData["psn_cash_pay"] = order.PsnCashPay
  1454. inputData["hosp_part_amt"] = order.HospPartAmt
  1455. inputData["acct_mulaid_pay"] = order.AcctMulaidPay
  1456. input["data"] = inputData
  1457. inputMessage["input"] = input //交易输入
  1458. bytesData, err := json.Marshal(inputMessage)
  1459. fmt.Println(string(bytesData))
  1460. if err != nil {
  1461. fmt.Println(err.Error())
  1462. return err.Error()
  1463. }
  1464. reader := bytes.NewReader(bytesData)
  1465. gdyb_url := beego.AppConfig.String("gdyb_url")
  1466. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1467. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1468. url := gdyb_url + "6201"
  1469. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/6201"
  1470. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/6201"
  1471. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  1472. request, err := http.NewRequest("POST", url, reader)
  1473. if err != nil {
  1474. fmt.Println(err.Error())
  1475. return err.Error()
  1476. }
  1477. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1478. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1479. request.Header.Set("x-tif-signature", signature)
  1480. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1481. request.Header.Set("x-tif-nonce", nonce)
  1482. client := http.Client{}
  1483. resp, err := client.Do(request)
  1484. if err != nil {
  1485. fmt.Println(err.Error())
  1486. return err.Error()
  1487. }
  1488. respBytes, err := ioutil.ReadAll(resp.Body)
  1489. if err != nil {
  1490. fmt.Println(err.Error())
  1491. return err.Error()
  1492. }
  1493. str := string(respBytes)
  1494. fmt.Println(str)
  1495. return str
  1496. }
  1497. // 医药机构费用结算对总账 func Gdyb3201( org_name string, doctor string, secret_key string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) string {
  1498. func Gdyb3201(baseParams models.BaseParams, businessParams models.BusinessParams) string {
  1499. fmt.Println("11222333-----")
  1500. fmt.Println(baseParams)
  1501. fmt.Println(businessParams)
  1502. // 生成签名
  1503. nonce := GetRandomString(32)
  1504. timestamp := time.Now().Unix()
  1505. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1506. // 生成输入报文
  1507. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1508. input := make(map[string]interface{})
  1509. inputData := make(map[string]interface{})
  1510. inputMessage["infno"] = "3201" // 交易编码
  1511. inputData["insutype"] = businessParams.Insutype // 险种
  1512. inputData["clr_type"] = businessParams.ClrType // 就诊 ID(来自2201接口返回)
  1513. inputData["setl_optins"] = businessParams.SetlOptins // 结算经办机构
  1514. inputData["stmt_begndate"] = businessParams.StmtBegndate // 对帐开始时间
  1515. inputData["stmt_enddate"] = businessParams.StmtEnddate //对帐结束时间
  1516. inputData["medfee_sumamt"] = businessParams.MedfeeSumamt //医疗费总额
  1517. inputData["fund_pay_sumamt"] = businessParams.FundPaySumamt //基金支付总额
  1518. inputData["acct_pay"] = businessParams.AcctPay //个人账户支付金额
  1519. inputData["fixmedins_setl_cnt"] = businessParams.FixmedinsSetlCnt //定点医药机构结算笔数
  1520. inputData["refd_setl_flag"] = 0 // 就诊 ID(来自2201接口返回)
  1521. input["data"] = inputData
  1522. inputMessage["input"] = input //交易输入
  1523. bytesData, err := json.Marshal(inputMessage)
  1524. fmt.Println(string(bytesData))
  1525. if err != nil {
  1526. fmt.Println(err.Error())
  1527. return err.Error()
  1528. }
  1529. reader := bytes.NewReader(bytesData)
  1530. gdyb_url := beego.AppConfig.String("gdyb_url")
  1531. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1532. var url string
  1533. if baseParams.MdtrtareaAdmvs == "150499" {
  1534. url = gdyb_url
  1535. } else {
  1536. url = gdyb_url + "3201"
  1537. }
  1538. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1539. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3201"
  1540. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3201"
  1541. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3201"
  1542. request, err := http.NewRequest("POST", url, reader)
  1543. if err != nil {
  1544. fmt.Println(err.Error())
  1545. return err.Error()
  1546. }
  1547. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1548. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1549. request.Header.Set("x-tif-signature", signature)
  1550. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1551. request.Header.Set("x-tif-nonce", nonce)
  1552. client := http.Client{}
  1553. resp, err := client.Do(request)
  1554. if err != nil {
  1555. fmt.Println(err.Error())
  1556. return err.Error()
  1557. }
  1558. respBytes, err := ioutil.ReadAll(resp.Body)
  1559. if err != nil {
  1560. fmt.Println(err.Error())
  1561. return err.Error()
  1562. }
  1563. str := string(respBytes)
  1564. fmt.Println(str)
  1565. return str
  1566. }
  1567. type Params struct {
  1568. FileName string `json:"file_name"` //产品ID
  1569. In []byte `json:"in"` //
  1570. FixmedinsCode string `json:"fixmedins_code"` //调用环境生产为1 沙盒2
  1571. }
  1572. //文件上传
  1573. func Gdyb9101(baseParams models.BaseParams, file_name string, file_byte []byte) string {
  1574. // 生成签名
  1575. nonce := GetRandomString(32)
  1576. timestamp := time.Now().Unix()
  1577. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1578. //buf := new(bytes.Buffer)
  1579. //buf.ReadFrom(strings.NewReader(string(file_byte)))
  1580. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1581. input := make(map[string]interface{})
  1582. inputData := make(map[string]interface{})
  1583. inputMessage["infno"] = "9101" // 交易编码
  1584. inputData["file_name"] = file_name //文件名
  1585. inputData["in"] = file_byte //文件数据
  1586. inputData["fixmedins_code"] = baseParams.FixmedinsCode //编码
  1587. input["fsUploadIn"] = inputData
  1588. inputMessage["input"] = input //交易输入
  1589. bytesData, err := json.Marshal(inputMessage)
  1590. fmt.Println(string(bytesData))
  1591. if err != nil {
  1592. fmt.Println(err.Error())
  1593. return err.Error()
  1594. }
  1595. reader := bytes.NewReader(bytesData)
  1596. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/9101"
  1597. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9101"
  1598. gdyb_url := beego.AppConfig.String("gdyb_url")
  1599. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1600. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1601. url := gdyb_url + "9101"
  1602. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9101"
  1603. request, err := http.NewRequest("POST", url, reader)
  1604. if err != nil {
  1605. fmt.Println(err.Error())
  1606. return err.Error()
  1607. }
  1608. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1609. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1610. request.Header.Set("x-tif-signature", signature)
  1611. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1612. request.Header.Set("x-tif-nonce", nonce)
  1613. client := http.Client{}
  1614. resp, err := client.Do(request)
  1615. if err != nil {
  1616. fmt.Println(err.Error())
  1617. return err.Error()
  1618. }
  1619. respBytes, err := ioutil.ReadAll(resp.Body)
  1620. if err != nil {
  1621. fmt.Println(err.Error())
  1622. return err.Error()
  1623. }
  1624. str := string(respBytes)
  1625. fmt.Println(str)
  1626. return str
  1627. }
  1628. func Gdyb9102(baseParams models.BaseParams, file_name string, file_qury_no string) string {
  1629. // 生成签名
  1630. nonce := GetRandomString(32)
  1631. timestamp := time.Now().Unix()
  1632. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1633. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1634. input := make(map[string]interface{})
  1635. inputData := make(map[string]interface{})
  1636. inputMessage["infno"] = "9102" // 交易编码
  1637. inputData["file_name"] = file_name //文件名
  1638. inputData["file_qury_no"] = file_qury_no //文件数据
  1639. inputData["fixmedins_code"] = baseParams.FixmedinsCode //编码
  1640. input["fsDownloadIn"] = inputData
  1641. inputMessage["input"] = input //交易输入
  1642. bytesData, err := json.Marshal(inputMessage)
  1643. fmt.Println(string(bytesData))
  1644. if err != nil {
  1645. fmt.Println(err.Error())
  1646. return err.Error()
  1647. }
  1648. reader := bytes.NewReader(bytesData)
  1649. gdyb_url := beego.AppConfig.String("gdyb_url")
  1650. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1651. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1652. url := gdyb_url + "9102"
  1653. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/9102"
  1654. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9102"
  1655. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9102"
  1656. request, err := http.NewRequest("POST", url, reader)
  1657. if err != nil {
  1658. fmt.Println(err.Error())
  1659. return err.Error()
  1660. }
  1661. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1662. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1663. request.Header.Set("x-tif-signature", signature)
  1664. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1665. request.Header.Set("x-tif-nonce", nonce)
  1666. client := http.Client{}
  1667. resp, err := client.Do(request)
  1668. if err != nil {
  1669. fmt.Println(err.Error())
  1670. return err.Error()
  1671. }
  1672. respBytes, err := ioutil.ReadAll(resp.Body)
  1673. if err != nil {
  1674. fmt.Println(err.Error())
  1675. return err.Error()
  1676. }
  1677. str := string(respBytes)
  1678. fmt.Println(str)
  1679. return str
  1680. }
  1681. func Gdyb3202(baseParams models.BaseParams, businessParams models.BusinessParams) string {
  1682. // 生成签名
  1683. nonce := GetRandomString(32)
  1684. timestamp := time.Now().Unix()
  1685. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1686. // 生成输入报文
  1687. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1688. input := make(map[string]interface{})
  1689. inputData := make(map[string]interface{})
  1690. inputMessage["infno"] = "3202" // 交易编码
  1691. inputData["file_qury_no"] = businessParams.FileQuryNo // 险种
  1692. inputData["setl_optins"] = baseParams.InsuplcAdmdvs // 结算经办机构
  1693. inputData["stmt_begndate"] = businessParams.StmtBegndate // 对帐开始时间
  1694. inputData["stmt_enddate"] = businessParams.StmtEnddate //对帐结束时间
  1695. inputData["medfee_sumamt"] = businessParams.MedfeeSumamt //医疗费总额
  1696. inputData["fund_pay_sumamt"] = businessParams.FundPaySumamt //基金支付总额
  1697. inputData["cash_payamt"] = businessParams.CashPayamt //现金支付金额
  1698. inputData["fixmedins_setl_cnt"] = businessParams.FixmedinsSetlCnt //定点医药机构结算笔数
  1699. inputData["clr_type"] = "11" // 就诊 ID(来自2201接口返回)
  1700. inputData["refd_setl_flag"] = 1 // 就诊 ID(来自2201接口返回)
  1701. input["data"] = inputData
  1702. inputMessage["input"] = input //交易输入
  1703. bytesData, err := json.Marshal(inputMessage)
  1704. fmt.Println(string(bytesData))
  1705. if err != nil {
  1706. fmt.Println(err.Error())
  1707. return err.Error()
  1708. }
  1709. reader := bytes.NewReader(bytesData)
  1710. gdyb_url := beego.AppConfig.String("gdyb_url")
  1711. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1712. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1713. url := gdyb_url + "3202"
  1714. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3202"
  1715. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3202"
  1716. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3202"
  1717. request, err := http.NewRequest("POST", url, reader)
  1718. if err != nil {
  1719. fmt.Println(err.Error())
  1720. return err.Error()
  1721. }
  1722. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1723. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1724. request.Header.Set("x-tif-signature", signature)
  1725. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1726. request.Header.Set("x-tif-nonce", nonce)
  1727. client := http.Client{}
  1728. resp, err := client.Do(request)
  1729. if err != nil {
  1730. fmt.Println(err.Error())
  1731. return err.Error()
  1732. }
  1733. respBytes, err := ioutil.ReadAll(resp.Body)
  1734. if err != nil {
  1735. fmt.Println(err.Error())
  1736. return err.Error()
  1737. }
  1738. str := string(respBytes)
  1739. fmt.Println(str)
  1740. return str
  1741. }
  1742. func Gdyb5203(baseParams models.BaseParams, businessParams models.BusinessParams) string {
  1743. fmt.Println("~~~~~~1")
  1744. fmt.Println(baseParams)
  1745. fmt.Println(businessParams)
  1746. // 生成签名
  1747. nonce := GetRandomString(32)
  1748. timestamp := time.Now().Unix()
  1749. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1750. fmt.Println("~~~~~~2")
  1751. // 生成输入报文
  1752. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1753. input := make(map[string]interface{})
  1754. inputData := make(map[string]interface{})
  1755. inputMessage["infno"] = "5203" // 交易编码
  1756. inputData["psn_no"] = businessParams.PsnNo
  1757. inputData["setl_id"] = businessParams.SetlId
  1758. inputData["mdtrt_id"] = businessParams.MdtrtId
  1759. input["data"] = inputData
  1760. inputMessage["input"] = input //交易输入
  1761. bytesData, err := json.Marshal(inputMessage)
  1762. fmt.Println(string(bytesData))
  1763. fmt.Println("~~~~~~")
  1764. fmt.Println("~~~~~~")
  1765. fmt.Println(string(bytesData))
  1766. if err != nil {
  1767. fmt.Println(err.Error())
  1768. return err.Error()
  1769. }
  1770. reader := bytes.NewReader(bytesData)
  1771. gdyb_url := beego.AppConfig.String("gdyb_url")
  1772. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1773. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1774. //url := gdyb_url + "5203"
  1775. var url string
  1776. if baseParams.FixmedinsCode == "H15049901371" {
  1777. url = gdyb_url
  1778. } else {
  1779. url = gdyb_url + "5203"
  1780. }
  1781. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5203"
  1782. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
  1783. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
  1784. request, err := http.NewRequest("POST", url, reader)
  1785. if err != nil {
  1786. fmt.Println(err.Error())
  1787. return err.Error()
  1788. }
  1789. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1790. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1791. request.Header.Set("x-tif-signature", signature)
  1792. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1793. request.Header.Set("x-tif-nonce", nonce)
  1794. client := http.Client{}
  1795. resp, err := client.Do(request)
  1796. if err != nil {
  1797. fmt.Println(err.Error())
  1798. return err.Error()
  1799. }
  1800. respBytes, err := ioutil.ReadAll(resp.Body)
  1801. if err != nil {
  1802. fmt.Println(err.Error())
  1803. return err.Error()
  1804. }
  1805. str := string(respBytes)
  1806. fmt.Println(str)
  1807. return str
  1808. }
  1809. func Gdyb5204(baseParams models.BaseParams, businessParams models.BusinessParams) string {
  1810. // 生成签名
  1811. nonce := GetRandomString(32)
  1812. timestamp := time.Now().Unix()
  1813. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1814. // 生成输入报文
  1815. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1816. input := make(map[string]interface{})
  1817. inputData := make(map[string]interface{})
  1818. inputMessage["infno"] = "5204" // 交易编码
  1819. inputData["psn_no"] = businessParams.PsnNo
  1820. inputData["setl_id"] = businessParams.SetlId
  1821. inputData["mdtrt_id"] = businessParams.MdtrtId
  1822. input["data"] = inputData
  1823. inputMessage["input"] = input //交易输入
  1824. bytesData, err := json.Marshal(inputMessage)
  1825. fmt.Println(string(bytesData))
  1826. if err != nil {
  1827. fmt.Println(err.Error())
  1828. return err.Error()
  1829. }
  1830. reader := bytes.NewReader(bytesData)
  1831. gdyb_url := beego.AppConfig.String("gdyb_url")
  1832. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1833. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1834. //url := gdyb_url + "5203"
  1835. var url string
  1836. if baseParams.FixmedinsCode == "H15049901371" {
  1837. url = gdyb_url
  1838. } else {
  1839. url = gdyb_url + "5204"
  1840. }
  1841. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5203"
  1842. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
  1843. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
  1844. request, err := http.NewRequest("POST", url, reader)
  1845. if err != nil {
  1846. fmt.Println(err.Error())
  1847. return err.Error()
  1848. }
  1849. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1850. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1851. request.Header.Set("x-tif-signature", signature)
  1852. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1853. request.Header.Set("x-tif-nonce", nonce)
  1854. client := http.Client{}
  1855. resp, err := client.Do(request)
  1856. if err != nil {
  1857. fmt.Println(err.Error())
  1858. return err.Error()
  1859. }
  1860. respBytes, err := ioutil.ReadAll(resp.Body)
  1861. if err != nil {
  1862. fmt.Println(err.Error())
  1863. return err.Error()
  1864. }
  1865. str := string(respBytes)
  1866. fmt.Println(str)
  1867. return str
  1868. }
  1869. func Gdyb2001(baseParams models.BaseParams, psn_no string, insutype string, med_type string) string {
  1870. if med_type == "1111" || med_type == "1112" {
  1871. med_type = "11"
  1872. }
  1873. // 生成签名
  1874. nonce := GetRandomString(32)
  1875. timestamp := time.Now().Unix()
  1876. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1877. // 生成输入报文
  1878. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1879. input := make(map[string]interface{})
  1880. inputData := make(map[string]interface{})
  1881. inputMessage["infno"] = "2001" // 交易编码
  1882. inputData["psn_no"] = psn_no
  1883. inputData["insutype"] = insutype
  1884. inputData["fixmedins_code"] = baseParams.FixmedinsCode
  1885. inputData["med_type"] = med_type
  1886. inputData["begntime"] = "2021-01-01 00:00:00"
  1887. input["data"] = inputData
  1888. inputMessage["input"] = input //交易输入
  1889. bytesData, err := json.Marshal(inputMessage)
  1890. fmt.Println(string(bytesData))
  1891. if err != nil {
  1892. fmt.Println(err.Error())
  1893. return err.Error()
  1894. }
  1895. reader := bytes.NewReader(bytesData)
  1896. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3301"
  1897. gdyb_url := beego.AppConfig.String("gdyb_url")
  1898. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1899. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1900. url := gdyb_url
  1901. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3301"
  1902. request, err := http.NewRequest("POST", url, reader)
  1903. if err != nil {
  1904. fmt.Println(err.Error())
  1905. return err.Error()
  1906. }
  1907. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1908. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1909. request.Header.Set("x-tif-signature", signature)
  1910. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1911. request.Header.Set("x-tif-nonce", nonce)
  1912. client := http.Client{}
  1913. resp, err := client.Do(request)
  1914. if err != nil {
  1915. fmt.Println(err.Error())
  1916. return err.Error()
  1917. }
  1918. respBytes, err := ioutil.ReadAll(resp.Body)
  1919. if err != nil {
  1920. fmt.Println(err.Error())
  1921. return err.Error()
  1922. }
  1923. str := string(respBytes)
  1924. fmt.Println(str)
  1925. return str
  1926. }
  1927. func Gdyb3301(baseParams *models.BaseParams, name string, codg string, list_type_code string, start_time string, ent_time string, list_type string) string {
  1928. // 生成签名
  1929. nonce := GetRandomString(32)
  1930. timestamp := time.Now().Unix()
  1931. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1932. // 生成输入报文
  1933. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1934. input := make(map[string]interface{})
  1935. inputData := make(map[string]interface{})
  1936. inputMessage["infno"] = "3301" // 交易编码
  1937. inputData["fixmedins_hilist_id"] = codg
  1938. inputData["fixmedins_hilist_name"] = name
  1939. inputData["list_type"] = list_type
  1940. inputData["med_list_codg"] = codg
  1941. inputData["begndate"] = start_time
  1942. inputData["enddate"] = ent_time
  1943. inputData["aprvno"] = ""
  1944. inputData["dosform"] = ""
  1945. inputData["exct_cont"] = ""
  1946. inputData["item_cont"] = ""
  1947. inputData["prcunt"] = ""
  1948. inputData["spec"] = ""
  1949. inputData["pacspec"] = ""
  1950. inputData["memo"] = ""
  1951. input["data"] = inputData
  1952. inputMessage["input"] = input //交易输入
  1953. bytesData, err := json.Marshal(inputMessage)
  1954. fmt.Println(string(bytesData))
  1955. if err != nil {
  1956. fmt.Println(err.Error())
  1957. return err.Error()
  1958. }
  1959. reader := bytes.NewReader(bytesData)
  1960. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3301"
  1961. //
  1962. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3301"
  1963. gdyb_url := beego.AppConfig.String("gdyb_url")
  1964. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1965. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1966. url := gdyb_url + "3301"
  1967. request, err := http.NewRequest("POST", url, reader)
  1968. if err != nil {
  1969. fmt.Println(err.Error())
  1970. return err.Error()
  1971. }
  1972. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1973. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1974. request.Header.Set("x-tif-signature", signature)
  1975. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1976. request.Header.Set("x-tif-nonce", nonce)
  1977. client := http.Client{}
  1978. resp, err := client.Do(request)
  1979. if err != nil {
  1980. fmt.Println(err.Error())
  1981. return err.Error()
  1982. }
  1983. respBytes, err := ioutil.ReadAll(resp.Body)
  1984. if err != nil {
  1985. fmt.Println(err.Error())
  1986. return err.Error()
  1987. }
  1988. str := string(respBytes)
  1989. fmt.Println(str)
  1990. return str
  1991. }
  1992. func Gdyb3302(baseParams *models.BaseParams, name string, codg string, list_type_code string) string {
  1993. // 生成签名
  1994. nonce := GetRandomString(32)
  1995. timestamp := time.Now().Unix()
  1996. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1997. // 生成输入报文
  1998. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1999. input := make(map[string]interface{})
  2000. inputData := make(map[string]interface{})
  2001. inputMessage["infno"] = "3302" // 交易编码
  2002. inputData["fixmedins_code"] = baseParams.FixmedinsCode
  2003. inputData["fixmedins_hilist_id"] = codg
  2004. inputData["list_type"] = list_type_code
  2005. inputData["med_list_codg"] = codg
  2006. input["data"] = inputData
  2007. inputMessage["input"] = input //交易输入
  2008. bytesData, err := json.Marshal(inputMessage)
  2009. fmt.Println(string(bytesData))
  2010. if err != nil {
  2011. fmt.Println(err.Error())
  2012. return err.Error()
  2013. }
  2014. reader := bytes.NewReader(bytesData)
  2015. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3302"
  2016. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3302"
  2017. gdyb_url := beego.AppConfig.String("gdyb_url")
  2018. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2019. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2020. url := gdyb_url + "3302"
  2021. request, err := http.NewRequest("POST", url, reader)
  2022. if err != nil {
  2023. fmt.Println(err.Error())
  2024. return err.Error()
  2025. }
  2026. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2027. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2028. request.Header.Set("x-tif-signature", signature)
  2029. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2030. request.Header.Set("x-tif-nonce", nonce)
  2031. client := http.Client{}
  2032. resp, err := client.Do(request)
  2033. if err != nil {
  2034. fmt.Println(err.Error())
  2035. return err.Error()
  2036. }
  2037. respBytes, err := ioutil.ReadAll(resp.Body)
  2038. if err != nil {
  2039. fmt.Println(err.Error())
  2040. return err.Error()
  2041. }
  2042. str := string(respBytes)
  2043. fmt.Println(str)
  2044. return str
  2045. }
  2046. func Gdyb2505(psnNo string, doctor string, org_name string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, start_time string, end_time string) string {
  2047. // 生成签名
  2048. nonce := GetRandomString(32)
  2049. timestamp := time.Now().Unix()
  2050. signature := setSignature(timestamp, nonce, secret_key)
  2051. // 生成输入报文
  2052. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2053. input := make(map[string]interface{})
  2054. inputData := make(map[string]interface{})
  2055. inputMessage["infno"] = "2505"
  2056. inputData["psn_no"] = psnNo
  2057. inputData["biz_appy_type"] = "03"
  2058. inputData["begndate"] = start_time
  2059. inputData["enddate"] = end_time
  2060. inputData["fixmedins_code"] = fixmedins_code
  2061. inputData["fixmedins_name"] = org_name
  2062. inputData["tel"] = ""
  2063. inputData["addr"] = ""
  2064. inputData["agnter_name"] = ""
  2065. inputData["agnter_cert_type"] = ""
  2066. inputData["agnter_certno"] = ""
  2067. inputData["agnter_tel"] = ""
  2068. inputData["agnter_addr"] = ""
  2069. inputData["agnter_rlts"] = ""
  2070. inputData["fix_srt_no"] = ""
  2071. inputData["memo"] = ""
  2072. input["data"] = inputData
  2073. inputMessage["input"] = input //交易输入
  2074. bytesData, err := json.Marshal(inputMessage)
  2075. if err != nil {
  2076. fmt.Println(err.Error())
  2077. return err.Error()
  2078. }
  2079. reader := bytes.NewReader(bytesData)
  2080. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2505"
  2081. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2505"
  2082. gdyb_url := beego.AppConfig.String("gdyb_url")
  2083. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2084. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2085. url := gdyb_url + "2505"
  2086. request, err := http.NewRequest("POST", url, reader)
  2087. if err != nil {
  2088. fmt.Println(err.Error())
  2089. return err.Error()
  2090. }
  2091. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2092. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2093. request.Header.Set("x-tif-signature", signature)
  2094. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2095. request.Header.Set("x-tif-nonce", nonce)
  2096. client := http.Client{}
  2097. resp, err := client.Do(request)
  2098. if err != nil {
  2099. fmt.Println(err.Error())
  2100. return err.Error()
  2101. }
  2102. respBytes, err := ioutil.ReadAll(resp.Body)
  2103. if err != nil {
  2104. fmt.Println(err.Error())
  2105. return err.Error()
  2106. }
  2107. str := string(respBytes)
  2108. fmt.Println(str)
  2109. return str
  2110. }
  2111. func Gdyb2506(psnNo string, doctor string, org_name string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, trt_dcla_detl_sn string) string {
  2112. // 生成签名
  2113. nonce := GetRandomString(32)
  2114. timestamp := time.Now().Unix()
  2115. signature := setSignature(timestamp, nonce, secret_key)
  2116. // 生成输入报文
  2117. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2118. input := make(map[string]interface{})
  2119. inputData := make(map[string]interface{})
  2120. inputMessage["infno"] = "2506"
  2121. inputData["psn_no"] = psnNo
  2122. inputData["trt_dcla_detl_sn"] = trt_dcla_detl_sn
  2123. inputData["memo"] = ""
  2124. input["data"] = inputData
  2125. inputMessage["input"] = input //交易输入
  2126. bytesData, err := json.Marshal(inputMessage)
  2127. fmt.Println(string(bytesData))
  2128. if err != nil {
  2129. fmt.Println(err.Error())
  2130. return err.Error()
  2131. }
  2132. reader := bytes.NewReader(bytesData)
  2133. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2506"
  2134. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2506"
  2135. gdyb_url := beego.AppConfig.String("gdyb_url")
  2136. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2137. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2138. url := gdyb_url + "2506"
  2139. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  2140. request, err := http.NewRequest("POST", url, reader)
  2141. if err != nil {
  2142. fmt.Println(err.Error())
  2143. return err.Error()
  2144. }
  2145. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2146. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2147. request.Header.Set("x-tif-signature", signature)
  2148. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2149. request.Header.Set("x-tif-nonce", nonce)
  2150. client := http.Client{}
  2151. resp, err := client.Do(request)
  2152. if err != nil {
  2153. fmt.Println(err.Error())
  2154. return err.Error()
  2155. }
  2156. respBytes, err := ioutil.ReadAll(resp.Body)
  2157. if err != nil {
  2158. fmt.Println(err.Error())
  2159. return err.Error()
  2160. }
  2161. str := string(respBytes)
  2162. fmt.Println(str)
  2163. return str
  2164. }
  2165. func Gdyb2503(psnNo string, insutype string, org_name string, doctor string, fixmedins_code string, doctor_id string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, sick_name string, sick_code string, start_time string, end_time string, check_time string) string {
  2166. // 生成签名
  2167. nonce := GetRandomString(32)
  2168. timestamp := time.Now().Unix()
  2169. signature := setSignature(timestamp, nonce, secret_key)
  2170. //tempTime := time.Unix(timestamp, 0)
  2171. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2172. //timeFormatTwo := tempTime.Format("2006-01-02")
  2173. //t := time.Now()
  2174. //last := time.Date(t.Year(), time.December, 31, 0, 0, 0, 0, time.UTC)
  2175. //tm := time.Unix(last.Unix(), 0)
  2176. // 生成输入报文
  2177. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2178. input := make(map[string]interface{})
  2179. inputData := make(map[string]interface{})
  2180. inputMessage["infno"] = "2503" // 交易编码
  2181. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  2182. inputData["insutype"] = insutype // 险种类型(来自1101接口返回)
  2183. inputData["opsp_dise_code"] = sick_code // 险种类型(来自1101接口返回)
  2184. inputData["opsp_dise_name"] = sick_name // 险种类型(来自1101接口返回)
  2185. inputData["insu_optins"] = insuplc_admdvs // 险种类型(来自1101接口返回)
  2186. inputData["ide_fixmedins_no"] = fixmedins_code // 险种类型(来自1101接口返回)
  2187. inputData["ide_fixmedins_name"] = org_name // 险种类型(来自1101接口返回)
  2188. inputData["hosp_ide_date"] = check_time // 险种类型(来自1101接口返回)
  2189. inputData["diag_dr_codg"] = doctor_id // 开始时间
  2190. inputData["diag_dr_name"] = doctor // 开始时间
  2191. inputData["begndate"] = start_time // 医师编码
  2192. inputData["tel"] = "" // 医师编码
  2193. inputData["addr"] = "" // 医师编码
  2194. inputData["enddate"] = end_time // 医师编码
  2195. input["data"] = inputData
  2196. inputMessage["input"] = input //交易输入
  2197. bytesData, err := json.Marshal(inputMessage)
  2198. fmt.Println(string(bytesData))
  2199. if err != nil {
  2200. fmt.Println(err.Error())
  2201. return err.Error()
  2202. }
  2203. reader := bytes.NewReader(bytesData)
  2204. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2503"
  2205. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2503"
  2206. gdyb_url := beego.AppConfig.String("gdyb_url")
  2207. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2208. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2209. //url := gdyb_url + "2503"
  2210. var url string
  2211. if fixmedins_code == "H15049901371" {
  2212. url = gdyb_url
  2213. } else {
  2214. url = gdyb_url + "2503"
  2215. }
  2216. request, err := http.NewRequest("POST", url, reader)
  2217. if err != nil {
  2218. fmt.Println(err.Error())
  2219. return err.Error()
  2220. }
  2221. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2222. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2223. request.Header.Set("x-tif-signature", signature)
  2224. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2225. request.Header.Set("x-tif-nonce", nonce)
  2226. client := http.Client{}
  2227. resp, err := client.Do(request)
  2228. if err != nil {
  2229. fmt.Println(err.Error())
  2230. return err.Error()
  2231. }
  2232. respBytes, err := ioutil.ReadAll(resp.Body)
  2233. if err != nil {
  2234. fmt.Println(err.Error())
  2235. return err.Error()
  2236. }
  2237. str := string(respBytes)
  2238. fmt.Println(str)
  2239. return str
  2240. }
  2241. func Gdyb2504(psnNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, trt_dcla_detl_sn string) string {
  2242. // 生成签名
  2243. nonce := GetRandomString(32)
  2244. timestamp := time.Now().Unix()
  2245. signature := setSignature(timestamp, nonce, secret_key)
  2246. // 生成输入报文
  2247. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2248. input := make(map[string]interface{})
  2249. inputData := make(map[string]interface{})
  2250. inputMessage["infno"] = "2504" // 交易编码
  2251. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  2252. inputData["trt_dcla_detl_sn"] = trt_dcla_detl_sn // 人员编号 (来自1101接口返回)
  2253. inputData["memo"] = "撤销备案" // 人员编号 (来自1101接口返回)
  2254. input["data"] = inputData
  2255. inputMessage["input"] = input //交易输入
  2256. bytesData, err := json.Marshal(inputMessage)
  2257. fmt.Println(string(bytesData))
  2258. if err != nil {
  2259. fmt.Println(err.Error())
  2260. return err.Error()
  2261. }
  2262. reader := bytes.NewReader(bytesData)
  2263. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2504"
  2264. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2504"
  2265. gdyb_url := beego.AppConfig.String("gdyb_url")
  2266. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2267. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2268. url := gdyb_url + "2504"
  2269. request, err := http.NewRequest("POST", url, reader)
  2270. if err != nil {
  2271. fmt.Println(err.Error())
  2272. return err.Error()
  2273. }
  2274. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2275. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2276. request.Header.Set("x-tif-signature", signature)
  2277. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2278. request.Header.Set("x-tif-nonce", nonce)
  2279. client := http.Client{}
  2280. resp, err := client.Do(request)
  2281. if err != nil {
  2282. fmt.Println(err.Error())
  2283. return err.Error()
  2284. }
  2285. respBytes, err := ioutil.ReadAll(resp.Body)
  2286. if err != nil {
  2287. fmt.Println(err.Error())
  2288. return err.Error()
  2289. }
  2290. str := string(respBytes)
  2291. fmt.Println(str)
  2292. return str
  2293. }
  2294. //func Gdyb2503(psnNo string, doctor string, department string, diag string, org_name string, med_type string, doctor_id int64, fixmedins_code string, diag_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, sick_code string, sick_name string) string {
  2295. // // 生成签名
  2296. // nonce := GetRandomString(32)
  2297. // timestamp := time.Now().Unix()
  2298. // signature := setSignature(timestamp, nonce, secret_key)
  2299. // tempTime := time.Unix(timestamp, 0)
  2300. // timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2301. //
  2302. // // 生成输入报文
  2303. // inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2304. // input := make(map[string]interface{})
  2305. // inputData := make(map[string]interface{})
  2306. // diseinfo := make([]map[string]interface{}, 0)
  2307. //
  2308. // inputMessage["infno"] = "2203" // 交易编码
  2309. // inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  2310. // inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  2311. // inputData["med_type"] = med_type // 医疗类别 16门诊特殊病
  2312. // inputData["begntime"] = timeFormatOne // 开始时间
  2313. // inputData["main_cond_dscr"] = "" // 主要病情描述
  2314. // inputData["dise_codg"] = sick_code // 病种编码
  2315. // inputData["dise_name"] = sick_name // 病种名称
  2316. // inputData["birctrl_type"] = "" // 计划生育手术类别
  2317. // inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
  2318. //
  2319. // diseinfo_sun := make(map[string]interface{})
  2320. // diseinfo_sun["diag_type"] = "1" // 诊断类别
  2321. // diseinfo_sun["diag_srt_no"] = "1" // 诊断排序号
  2322. // diseinfo_sun["diag_code"] = diag_code // 诊断代码
  2323. // diseinfo_sun["diag_name"] = diag // 诊断名称
  2324. // diseinfo_sun["diag_dept"] = department // 诊断科室
  2325. // diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
  2326. // diseinfo_sun["dise_dor_name"] = doctor // 诊断医生姓名
  2327. // diseinfo_sun["diag_time"] = timeFormatOne // 诊断时间
  2328. // diseinfo_sun["vali_flag"] = "1" // 有效标志
  2329. //
  2330. // diseinfo = append(diseinfo, diseinfo_sun)
  2331. // input["diseinfo"] = diseinfo
  2332. // input["mdtrtinfo"] = inputData
  2333. // inputMessage["input"] = input //交易输入
  2334. //
  2335. // bytesData, err := json.Marshal(inputMessage)
  2336. // fmt.Println(string(bytesData))
  2337. // if err != nil {
  2338. // fmt.Println(err.Error())
  2339. // return err.Error()
  2340. // }
  2341. // reader := bytes.NewReader(bytesData)
  2342. //
  2343. // url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2203"
  2344. //
  2345. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  2346. // request, err := http.NewRequest("POST", url, reader)
  2347. // if err != nil {
  2348. // fmt.Println(err.Error())
  2349. // return err.Error()
  2350. // }
  2351. //
  2352. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2353. // request.Header.Set("x-tif-paasid", "sg03_prd")
  2354. // request.Header.Set("x-tif-signature", signature)
  2355. // request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2356. // request.Header.Set("x-tif-nonce", nonce)
  2357. //
  2358. // client := http.Client{}
  2359. // resp, err := client.Do(request)
  2360. // if err != nil {
  2361. // fmt.Println(err.Error())
  2362. // return err.Error()
  2363. // }
  2364. // respBytes, err := ioutil.ReadAll(resp.Body)
  2365. // if err != nil {
  2366. // fmt.Println(err.Error())
  2367. // return err.Error()
  2368. // }
  2369. // str := string(respBytes)
  2370. // fmt.Println(str)
  2371. // return str
  2372. //}
  2373. func Gdyb5301(psnNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  2374. // 生成签名
  2375. nonce := GetRandomString(32)
  2376. timestamp := time.Now().Unix()
  2377. signature := setSignature(timestamp, nonce, secret_key)
  2378. //tempTime := time.Unix(timestamp, 0)
  2379. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2380. //timeFormatTwo := tempTime.Format("2006-01-02")
  2381. // 生成输入报文
  2382. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2383. input := make(map[string]interface{})
  2384. inputData := make(map[string]interface{})
  2385. inputMessage["infno"] = "5301" // 交易编码
  2386. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  2387. input["data"] = inputData
  2388. inputMessage["input"] = input //交易输入
  2389. bytesData, err := json.Marshal(inputMessage)
  2390. fmt.Println(string(bytesData))
  2391. if err != nil {
  2392. fmt.Println(err.Error())
  2393. return err.Error()
  2394. }
  2395. reader := bytes.NewReader(bytesData)
  2396. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  2397. gdyb_url := beego.AppConfig.String("gdyb_url")
  2398. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2399. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2400. url := gdyb_url + "5301"
  2401. request, err := http.NewRequest("POST", url, reader)
  2402. if err != nil {
  2403. fmt.Println(err.Error())
  2404. return err.Error()
  2405. }
  2406. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2407. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2408. request.Header.Set("x-tif-signature", signature)
  2409. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2410. request.Header.Set("x-tif-nonce", nonce)
  2411. client := http.Client{}
  2412. resp, err := client.Do(request)
  2413. if err != nil {
  2414. fmt.Println(err.Error())
  2415. return err.Error()
  2416. }
  2417. respBytes, err := ioutil.ReadAll(resp.Body)
  2418. if err != nil {
  2419. fmt.Println(err.Error())
  2420. return err.Error()
  2421. }
  2422. str := string(respBytes)
  2423. fmt.Println(str)
  2424. return str
  2425. }
  2426. func Gdyb5301Two(psnNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  2427. // 生成签名
  2428. nonce := GetRandomString(32)
  2429. timestamp := time.Now().Unix()
  2430. signature := setSignature(timestamp, nonce, secret_key)
  2431. //tempTime := time.Unix(timestamp, 0)
  2432. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2433. //timeFormatTwo := tempTime.Format("2006-01-02")
  2434. // 生成输入报文
  2435. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2436. input := make(map[string]interface{})
  2437. inputData := make(map[string]interface{})
  2438. inputMessage["infno"] = "5301" // 交易编码
  2439. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  2440. input["data"] = inputData
  2441. inputMessage["input"] = input //交易输入
  2442. bytesData, err := json.Marshal(inputMessage)
  2443. fmt.Println(string(bytesData))
  2444. if err != nil {
  2445. fmt.Println(err.Error())
  2446. return err.Error()
  2447. }
  2448. reader := bytes.NewReader(bytesData)
  2449. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  2450. gdyb_url := beego.AppConfig.String("gdyb_url")
  2451. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2452. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2453. url := gdyb_url
  2454. request, err := http.NewRequest("POST", url, reader)
  2455. if err != nil {
  2456. fmt.Println(err.Error())
  2457. return err.Error()
  2458. }
  2459. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2460. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2461. request.Header.Set("x-tif-signature", signature)
  2462. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2463. request.Header.Set("x-tif-nonce", nonce)
  2464. client := http.Client{}
  2465. resp, err := client.Do(request)
  2466. if err != nil {
  2467. fmt.Println(err.Error())
  2468. return err.Error()
  2469. }
  2470. respBytes, err := ioutil.ReadAll(resp.Body)
  2471. if err != nil {
  2472. fmt.Println(err.Error())
  2473. return err.Error()
  2474. }
  2475. str := string(respBytes)
  2476. fmt.Println(str)
  2477. return str
  2478. }
  2479. type CustomStruct struct {
  2480. FundPayType string
  2481. FundPayamt float64
  2482. }
  2483. type OpspdiseinfoStruct struct {
  2484. DiagName string
  2485. DiagCode string
  2486. OprnOprtName string
  2487. OprnOprtCode string
  2488. }
  2489. type DiaginfoStructTwo struct {
  2490. DiagType string
  2491. DiagCode string
  2492. DiagName string
  2493. MaindiagFlag string
  2494. }
  2495. type IteminfoStruct struct {
  2496. MedChrgitm string
  2497. Amt float64
  2498. ClaaSumfee float64
  2499. ClabAmt float64
  2500. FulamtOwnpayAmt float64
  2501. OthAmt float64
  2502. }
  2503. type Struct4101 struct {
  2504. PsnNo string
  2505. MdtrtId string
  2506. SetlId string
  2507. HiSetlLv string
  2508. PsnName string
  2509. Gend string
  2510. Brdy string
  2511. Ntly string
  2512. Naty string
  2513. PatnCertType string
  2514. Certno string
  2515. Prfs string
  2516. ConerName string
  2517. PatnRlts string
  2518. ConerAddr string
  2519. ConerTel string
  2520. HiType string
  2521. Insuplc string
  2522. AdmCaty string
  2523. DscgCaty string
  2524. MaindiagFlag string
  2525. BillCode string
  2526. BillNo string
  2527. BizSn string
  2528. SetlBegnDate string
  2529. SetlEndDate string
  2530. PsnSelfPay float64
  2531. PsnOwnPay float64
  2532. AcctPay float64
  2533. PsnCashpay float64
  2534. HiPaymtd string
  2535. Hsorg string
  2536. HsorgOpter string
  2537. MedinsFillDept string
  2538. MedinsFillPsn string
  2539. IptMedType string
  2540. Age int64
  2541. CustomStruct []CustomStruct
  2542. OpspdiseinfoStruct []OpspdiseinfoStruct
  2543. Diseinfo []DiaginfoStructTwo
  2544. IteminfoStruct []IteminfoStruct
  2545. AdmTime string
  2546. AdmEndTime string
  2547. HisNo string
  2548. }
  2549. //
  2550. func Gdyb4101(struct4101 Struct4101, secret_key string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, org_id int64) string {
  2551. // 生成签名
  2552. nonce := GetRandomString(32)
  2553. timestamp := time.Now().Unix()
  2554. signature := setSignature(timestamp, nonce, secret_key)
  2555. // 生成输入报文
  2556. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2557. input := make(map[string]interface{})
  2558. inputData := make(map[string]interface{})
  2559. if org_id == 10106 || org_id == 10215 || org_id == 10138 || org_id == 9504 {
  2560. inputMessage["infno"] = "4101A" // 交易编码
  2561. } else {
  2562. inputMessage["infno"] = "4101A" // 交易编码
  2563. }
  2564. year := time.Now().Format("2006")
  2565. month := time.Now().Format("01")
  2566. day := time.Now().Format("02")
  2567. inputData["mdtrt_id"] = struct4101.MdtrtId // 就诊 ID 必填(来自2201接口返回)
  2568. inputData["setl_id"] = struct4101.SetlId // 结算 ID 必填
  2569. inputData["psn_no"] = struct4101.PsnNo // 结算 ID 必填
  2570. inputData["fixmedins_name"] = org_name // 定点医药机构名称 必填
  2571. inputData["fixmedins_code"] = fixmedins_code // 定点医药机构编码 必填
  2572. inputData["hi_setl_lv"] = "" // 医保结算等级
  2573. inputData["hi_no"] = struct4101.PsnNo // 医保编号
  2574. inputData["medcasno"] = struct4101.PsnNo // 病案号 必填
  2575. inputData["dcla_time"] = year + "-" + month + "-" + day // 申报时间 必填
  2576. inputData["psn_name"] = struct4101.PsnName // 人员姓名 必填
  2577. inputData["gend"] = struct4101.Gend // 性别 必填
  2578. inputData["brdy"] = struct4101.Brdy // 出生日期 必填
  2579. inputData["age"] = struct4101.Age // 年龄 必填
  2580. inputData["ntly"] = struct4101.Ntly // 国籍 必填
  2581. inputData["nwb_age"] = "" // 年龄 必填
  2582. inputData["naty"] = struct4101.Naty // 民族 必填
  2583. inputData["patn_cert_type"] = struct4101.PatnCertType // 患者证件类别 必填
  2584. inputData["certno"] = struct4101.Certno // 证件号码 必填
  2585. inputData["prfs"] = struct4101.Prfs // 职业 必填
  2586. inputData["curr_addr"] = "" // 现住址 必填
  2587. inputData["emp_name"] = "" // 单位名称 必填
  2588. inputData["emp_addr"] = "" // 单位地址 必填
  2589. inputData["emp_tel"] = "" // 单位电话 必填
  2590. inputData["poscode"] = "" // 邮编 必填
  2591. inputData["coner_name"] = struct4101.ConerName // 联系人姓名 必填
  2592. inputData["patn_rlts"] = struct4101.PatnRlts // 与患者关系 必填
  2593. inputData["coner_addr"] = struct4101.ConerAddr // 联系人地址 必填
  2594. inputData["coner_tel"] = struct4101.ConerTel // 联系人电话 必填
  2595. inputData["hi_type"] = struct4101.HiType // 医保类型 必填
  2596. inputData["insuplc"] = struct4101.Insuplc // 参保地 必填
  2597. inputData["sp_psn_type"] = "" // 特殊人员类型 必填
  2598. inputData["nwb_adm_type"] = "" // 新生儿入院类型 必填
  2599. inputData["nwb_bir_wt"] = "" // 新生儿出生体重 必填
  2600. inputData["nwb_adm_wt"] = "" // 新生儿入院体重 必填
  2601. inputData["opsp_diag_caty"] = "" // 门诊慢特病诊断 必填
  2602. inputData["opsp_mdtrt_date"] = "" // 门诊慢特病就诊日期 必填
  2603. inputData["ipt_med_type"] = struct4101.IptMedType // 住院医疗类型 必填
  2604. inputData["adm_way"] = "" // 入院途径 必填
  2605. inputData["trt_type"] = "" // 治疗类别 必填
  2606. inputData["adm_time"] = struct4101.AdmTime // 入院时间 必填
  2607. inputData["adm_caty"] = struct4101.AdmCaty // 入院科别 必填
  2608. inputData["refldept_dept"] = "" // 转科科别 必填
  2609. inputData["dscg_time"] = struct4101.AdmEndTime // 出院时间 必填
  2610. inputData["dscg_caty"] = struct4101.AdmCaty // 出院科别 必填
  2611. inputData["act_ipt_days"] = "" // 实际住院天数 必填
  2612. inputData["otp_wm_dise"] = "" // 门(急) 诊西医诊断 必填
  2613. inputData["wm_dise_code"] = "" // 门(急) 诊中医诊断 必填
  2614. inputData["otp_tcm_dise"] = "" // 西医诊断疾病代码 必填
  2615. inputData["tcm_dise_code"] = "" // 中医诊断代码 必填
  2616. inputData["oprn_oprt_code_cnt"] = "" // 手术操作代码计数 必填
  2617. inputData["vent_used_dura"] = "" // 呼吸机使用时长 必填
  2618. inputData["pwcry_bfadm_coma_dura"] = "" // 颅脑损伤患者入院前昏迷时长 必填
  2619. inputData["pwcry_afadm_coma_dura"] = "" // 颅脑损伤患者入院后昏迷时长 必填
  2620. inputData["bld_cat"] = "" // 输血品种 必填
  2621. inputData["bld_amt"] = "" // 输血量 必填
  2622. inputData["bld_unt"] = "" // 输血计量单位 必填
  2623. inputData["spga_nurscare_days"] = "" // 特级护理天数 必填
  2624. inputData["lv1_nurscare_days"] = "" // 一级护理天数 必填
  2625. inputData["scd_nurscare_days"] = "" // 二级护理天数 必填
  2626. inputData["lv3_nurscare_days"] = "" // 三级护理天数 必填
  2627. inputData["acp_medins_name"] = "" // 拟接收机构名称 必填
  2628. inputData["acp_optins_code"] = "" // 拟接收机构代码 必填
  2629. inputData["bill_code"] = struct4101.BillCode // 票据代码 必填
  2630. inputData["bill_no"] = struct4101.BillNo // 票据号码 必填
  2631. inputData["biz_sn"] = struct4101.BizSn // 业务流水号 必填
  2632. inputData["days_rinp_flag_31"] = "" // 出院 31 天内再住院计划标志 必填
  2633. inputData["days_rinp_pup_31"] = "" // 出院 31 天内再住院目的 必填
  2634. inputData["chfpdr_name"] = "" // 主诊医师姓名 必填
  2635. inputData["chfpdr_code"] = "" // 主诊医师代码 必填
  2636. inputData["setl_begn_date"] = struct4101.SetlBegnDate // 结算开始日期 必填
  2637. inputData["setl_end_date"] = struct4101.SetlEndDate // 结算结束日期 必填
  2638. inputData["psn_selfpay"] = struct4101.PsnSelfPay // 个人自付 必填
  2639. inputData["psn_ownpay"] = struct4101.PsnOwnPay // 个人自费 必填
  2640. inputData["acct_pay"] = struct4101.AcctPay // 个人账户支出 必填
  2641. inputData["hi_paymtd"] = struct4101.HiPaymtd // 医保支付方式 必填
  2642. inputData["hsorg"] = struct4101.Hsorg // 医保机构 必填
  2643. inputData["hsorg_opter"] = struct4101.HsorgOpter // 医保机构经办人 必填
  2644. inputData["medins_fill_dept"] = struct4101.MedinsFillDept // 医疗机构填报部门 必填
  2645. inputData["medins_fill_psn"] = struct4101.MedinsFillPsn // 医疗机构填报人 必填
  2646. inputData["psn_cashpay"] = struct4101.PsnCashpay // 医疗机构填报人 必填
  2647. payinfo := make([]map[string]interface{}, 0) // 基金支付信息
  2648. for _, item := range struct4101.CustomStruct {
  2649. payinfotemp := make(map[string]interface{})
  2650. if item.FundPayType == "310100" || item.FundPayType == "310200" || item.FundPayType == "320100" || item.FundPayType == "330100" || item.FundPayType == "340100" || item.FundPayType == "350100" || item.FundPayType == "370100" || item.FundPayType == "390100" || item.FundPayType == "610100" || item.FundPayType == "640100" || item.FundPayType == "620100" {
  2651. payinfotemp["fund_pay_type"] = item.FundPayType // 基金支付类型 必填
  2652. payinfotemp["fund_payamt"] = item.FundPayamt // 基金支付金额
  2653. payinfo = append(payinfo, payinfotemp)
  2654. }
  2655. }
  2656. opspdiseinfo := make([]map[string]interface{}, 0) // 门诊慢特病诊断信息
  2657. opspdiseinfotemp := make(map[string]interface{})
  2658. opspdiseinfotemp["diag_name"] = struct4101.OpspdiseinfoStruct[len(struct4101.OpspdiseinfoStruct)-1].DiagName // 诊断名称 必填
  2659. opspdiseinfotemp["diag_code"] = struct4101.OpspdiseinfoStruct[len(struct4101.OpspdiseinfoStruct)-1].DiagCode // 诊断代码 必填
  2660. opspdiseinfotemp["oprn_oprt_name"] = "血液透析" // 手术操作名称 必填
  2661. opspdiseinfotemp["oprn_oprt_code"] = "39.9500" // 手术操作代码 必填
  2662. opspdiseinfo = append(opspdiseinfo, opspdiseinfotemp)
  2663. diseinfo := make([]map[string]interface{}, 0) // 住院诊断信息
  2664. for _, item := range struct4101.Diseinfo {
  2665. diseinfotemp := make(map[string]interface{})
  2666. diseinfotemp["maindiag_flag"] = item.MaindiagFlag // 手术操作代码 必填
  2667. diseinfotemp["diag_type"] = item.DiagType // 诊断类别 必填
  2668. diseinfotemp["diag_code"] = item.DiagCode // 诊断代码 必填
  2669. diseinfotemp["diag_name"] = item.DiagName // 诊断名称 必填
  2670. diseinfotemp["adm_cond_type"] = "3" // 入院病情类型 必填
  2671. diseinfo = append(diseinfo, diseinfotemp)
  2672. }
  2673. iteminfo := make([]map[string]interface{}, 0)
  2674. for _, item := range struct4101.IteminfoStruct {
  2675. iteminfotemp := make(map[string]interface{})
  2676. iteminfotemp["med_chrgitm"] = item.MedChrgitm // 医疗收费项目 必填
  2677. iteminfotemp["amt"] = item.Amt // 金额 必填
  2678. iteminfotemp["claa_sumfee"] = item.ClaaSumfee // 甲类费用合计 必填
  2679. iteminfotemp["clab_amt"] = item.ClabAmt // 乙类金额 必填
  2680. iteminfotemp["fulamt_ownpay_amt"] = item.FulamtOwnpayAmt // 全自费金额 必填
  2681. iteminfotemp["oth_amt"] = item.OthAmt // 其他金额 必填
  2682. iteminfo = append(iteminfo, iteminfotemp)
  2683. }
  2684. oprninfo := make([]map[string]interface{}, 0) // 手术操作信息
  2685. oprninfotemp := make(map[string]interface{})
  2686. oprninfotemp["oprn_oprt_type"] = "" // 手术操作类别 必填
  2687. oprninfotemp["oprn_oprt_name"] = "" // 手术操作名称 必填
  2688. oprninfotemp["oprn_oprt_code"] = "" // 手术操作代码 必填
  2689. oprninfotemp["oprn_oprt_date"] = "" // 手术操作日期 必填
  2690. oprninfotemp["anst_way"] = "" // 麻醉方式 必填
  2691. oprninfotemp["oper_dr_name"] = "" // 术者医师姓名 必填
  2692. oprninfotemp["oper_dr_code"] = "" // 术者医师代码 必填
  2693. oprninfotemp["anst_dr_name"] = "" // 麻醉医师姓名 必填
  2694. oprninfotemp["anst_dr_code"] = "" // 麻醉医师代码 必填
  2695. oprninfo = append(oprninfo, oprninfotemp)
  2696. icuinfo := make([]map[string]interface{}, 0) // 重症监护信息
  2697. icuinfotemp := make(map[string]interface{})
  2698. icuinfotemp["scs_cutd_ward_type"] = "" // 重症监护病房类型 必填
  2699. icuinfotemp["scs_cutd_inpool_time"] = "" // 重症监护进入时间 必填
  2700. icuinfotemp["scs_cutd_exit_time"] = "" // 重症监护退出时间 必填
  2701. icuinfotemp["scs_cutd_sum_dura"] = "" // 重症监护合计时长 必填
  2702. icuinfo = append(icuinfo, icuinfotemp)
  2703. input["setlinfo"] = inputData
  2704. input["payinfo"] = payinfo
  2705. input["opspdiseinfo"] = oprninfo
  2706. input["diseinfo"] = diseinfo
  2707. input["iteminfo"] = iteminfo
  2708. inputMessage["input"] = input //交易输入
  2709. bytesData, err := json.Marshal(inputMessage)
  2710. fmt.Println(string(bytesData))
  2711. if err != nil {
  2712. fmt.Println(err.Error())
  2713. return err.Error()
  2714. }
  2715. reader := bytes.NewReader(bytesData)
  2716. gdyb_url := beego.AppConfig.String("gdyb_url")
  2717. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2718. //url := gdyb_url + "4101"
  2719. var url string
  2720. if fixmedins_code == "H15049901371" {
  2721. url = gdyb_url
  2722. } else {
  2723. if org_id == 10106 || org_id == 10215 || org_id == 10138 || org_id == 9504 {
  2724. url = gdyb_url + "4101A"
  2725. } else {
  2726. url = gdyb_url + "4101"
  2727. }
  2728. }
  2729. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/4101"
  2730. request, err := http.NewRequest("POST", url, reader)
  2731. if err != nil {
  2732. fmt.Println(err.Error())
  2733. return err.Error()
  2734. }
  2735. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2736. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2737. request.Header.Set("x-tif-signature", signature)
  2738. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2739. request.Header.Set("x-tif-nonce", nonce)
  2740. client := http.Client{}
  2741. resp, err := client.Do(request)
  2742. if err != nil {
  2743. fmt.Println(err.Error())
  2744. return err.Error()
  2745. }
  2746. respBytes, err := ioutil.ReadAll(resp.Body)
  2747. if err != nil {
  2748. fmt.Println(err.Error())
  2749. return err.Error()
  2750. }
  2751. str := string(respBytes)
  2752. fmt.Println(str)
  2753. return str
  2754. }
  2755. //func Gdyb7101(psnNo string, insutype string, org_name string, doctor string, fixmedins_code string, doctor_id string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, sick_name string, sick_code string) string {
  2756. // // 生成签名
  2757. // nonce := GetRandomString(32)
  2758. // timestamp := time.Now().Unix()
  2759. // signature := setSignature(timestamp, nonce, secret_key)
  2760. // tempTime := time.Unix(timestamp, 0)
  2761. // //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2762. //
  2763. // timeFormatTwo := tempTime.Format("2006-01-02")
  2764. //
  2765. // t := time.Now()
  2766. // last := time.Date(t.Year(), time.December, 31, 0, 0, 0, 0, time.UTC)
  2767. // tm := time.Unix(last.Unix(), 0)
  2768. //
  2769. // // 生成输入报文
  2770. // inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2771. // input := make(map[string]interface{})
  2772. // inputData := make(map[string]interface{})
  2773. //
  2774. // inputData2 := make(map[string]interface{})
  2775. //
  2776. // inputMessage["infno"] = "7101" // 交易编码
  2777. // inputData["hosp_rxno"] = psnNo // 人员编号 (来自1101接口返回)
  2778. // inputData["init_rxno"] = insutype // 险种类型(来自1101接口返回)
  2779. // inputData["rx_type_code"] = sick_code // 险种类型(来自1101接口返回)
  2780. // inputData["prsc_time"] = sick_name // 险种类型(来自1101接口返回)
  2781. // inputData["rx_drug_nums"] = insuplc_admdvs // 险种类型(来自1101接口返回)
  2782. // inputData["rx_way_codg"] = fixmedins_code // 险种类型(来自1101接口返回)
  2783. // inputData["rx_way_name"] = org_name // 险种类型(来自1101接口返回)
  2784. // inputData["rx_freq_codg"] = timeFormatTwo // 险种类型(来自1101接口返回)
  2785. // inputData["rx_freq_name"] = doctor_id // 开始时间
  2786. // inputData["rx_dosunt"] = doctor // 开始时间
  2787. // inputData["rx_doscnt"] = timeFormatTwo // 医师编码
  2788. // inputData["rx_drord_dscr"] = "" // 医师编码
  2789. // inputData["valid_days"] = "" // 医师编码
  2790. // inputData["valid_end_time"] = tm.Format("2006-01-02") // 医师编码
  2791. // inputData["rept_flag"] = tm.Format("2006-01-02") // 医师编码
  2792. // inputData["max_rept_cnt"] = tm.Format("2006-01-02") // 医师编码
  2793. // inputData["reptd_cnt"] = tm.Format("2006-01-02") // 医师编码
  2794. // inputData["min_inrv_days"] = tm.Format("2006-01-02") // 医师编码
  2795. // inputData["dr_sign_info"] = tm.Format("2006-01-02") // 医师编码
  2796. // inputData["phar_sign_info"] = tm.Format("2006-01-02") // 医师编码
  2797. // inputData["fixmedins_sign_info"] = tm.Format("2006-01-02") // 医师编码
  2798. // inputData["rx_cotn_flag"] = tm.Format("2006-01-02") // 医师编码
  2799. // inputData["rx_file"] = tm.Format("2006-01-02") // 医师编码
  2800. // input["data"] = inputData
  2801. //
  2802. //
  2803. // inputData2["med_list_codg"] = psnNo // 人员编号 (来自1101接口返回)
  2804. // inputData2["fixmedins_hilist_id"] = insutype // 险种类型(来自1101接口返回)
  2805. // inputData["hosp_prep_flag"] = sick_code // 险种类型(来自1101接口返回)
  2806. // inputData["rx_item_type_code"] = sick_name // 险种类型(来自1101接口返回)
  2807. // inputData["rx_item_type_name"] = insuplc_admdvs // 险种类型(来自1101接口返回)
  2808. // inputData["tcmdrug_type_name"] = fixmedins_code // 险种类型(来自1101接口返回)
  2809. // inputData["tcmdrug_type_code"] = org_name // 险种类型(来自1101接口返回)
  2810. // inputData["tcmherb_foote"] = timeFormatTwo // 险种类型(来自1101接口返回)
  2811. // inputData["medn_type_code"] = doctor_id // 开始时间
  2812. // inputData["medn_type_name"] = doctor // 开始时间
  2813. // inputData["main_medc_flag"] = timeFormatTwo // 医师编码
  2814. // inputData["urgt_flag"] = "" // 医师编码
  2815. // inputData["bas_medn_flag"] = "" // 医师编码
  2816. // inputData["imp_drug_flag"] = tm.Format("2006-01-02") // 医师编码
  2817. // inputData["prod_barc"] = tm.Format("2006-01-02") // 医师编码
  2818. // inputData["drug_prodname"] = tm.Format("2006-01-02") // 医师编码
  2819. //
  2820. // inputData["genname_codg"] = tm.Format("2006-01-02") // 医师编码
  2821. // inputData["drug_genname"] = tm.Format("2006-01-02") // 医师编码
  2822. // inputData["chemname"] = tm.Format("2006-01-02") // 医师编码
  2823. //
  2824. // inputData["drugstdcode"] = tm.Format("2006-01-02") // 医师编码
  2825. // inputData["drug_dosform"] = tm.Format("2006-01-02") // 医师编码
  2826. //
  2827. //
  2828. // inputData["drug_spec"] = tm.Format("2006-01-02") // 医师编码
  2829. // inputData["prdr_name"] = tm.Format("2006-01-02") // 医师编码
  2830. //
  2831. //
  2832. // inputData["drug_pric"] = tm.Format("2006-01-02") // 医师编码
  2833. // inputData["drug_cnt"] = tm.Format("2006-01-02") // 医师编码
  2834. // inputData["drug_cnt_unit"] = tm.Format("2006-01-02") // 医师编码
  2835. // inputData["drug_sumamt"] = tm.Format("2006-01-02") // 医师编码
  2836. // inputData["medc_way_codg"] = tm.Format("2006-01-02") // 医师编码
  2837. // inputData["medc_way_dscr"] = tm.Format("2006-01-02") // 医师编码
  2838. // inputData["medc_starttime"] = tm.Format("2006-01-02") // 医师编码
  2839. //
  2840. // inputData["medc_endtime"] = tm.Format("2006-01-02") // 医师编码
  2841. //
  2842. //
  2843. // inputData["medc_days"] = tm.Format("2006-01-02") // 医师编码
  2844. // inputData["drug_dosunt"] = tm.Format("2006-01-02") // 医师编码
  2845. // inputData["sin_doscnt"] = tm.Format("2006-01-02") // 医师编码
  2846. // inputData["sin_dosunt"] = tm.Format("2006-01-02") // 医师编码
  2847. // inputData["used_frqu_codg"] = tm.Format("2006-01-02") // 医师编码
  2848. //
  2849. //
  2850. // inputData["used_frqu_name"] = tm.Format("2006-01-02") // 医师编码
  2851. // inputData["drug_totlnt"] = tm.Format("2006-01-02") // 医师编码
  2852. //
  2853. // inputData["drug_totlnt_emp"] = tm.Format("2006-01-02") // 医师编码
  2854. // inputData["dise_codg"] = tm.Format("2006-01-02") // 医师编码
  2855. // inputData["drug_res"] = tm.Format("2006-01-02") // 医师编码
  2856. // inputData["drug_limit"] = tm.Format("2006-01-02") // 医师编码
  2857. //
  2858. //
  2859. //
  2860. //
  2861. //
  2862. //
  2863. //
  2864. //
  2865. //
  2866. // input["rxdrugdetail"] = inputData2
  2867. //
  2868. //
  2869. //
  2870. //
  2871. // inputMessage["input"] = input //交易输入
  2872. // bytesData, err := json.Marshal(inputMessage)
  2873. // fmt.Println(string(bytesData))
  2874. // if err != nil {
  2875. // fmt.Println(err.Error())
  2876. // return err.Error()
  2877. // }
  2878. // reader := bytes.NewReader(bytesData)
  2879. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2503"
  2880. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2503"
  2881. // gdyb_url := beego.AppConfig.String("gdyb_url")
  2882. // gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2883. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2884. // url := gdyb_url + "2503"
  2885. //
  2886. // request, err := http.NewRequest("POST", url, reader)
  2887. // if err != nil {
  2888. // fmt.Println(err.Error())
  2889. // return err.Error()
  2890. // }
  2891. //
  2892. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2893. // request.Header.Set("x-tif-paasid", gdyb_paasid)
  2894. // request.Header.Set("x-tif-signature", signature)
  2895. // request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2896. // request.Header.Set("x-tif-nonce", nonce)
  2897. //
  2898. // client := http.Client{}
  2899. // resp, err := client.Do(request)
  2900. // if err != nil {
  2901. // fmt.Println(err.Error())
  2902. // return err.Error()
  2903. // }
  2904. // respBytes, err := ioutil.ReadAll(resp.Body)
  2905. // if err != nil {
  2906. // fmt.Println(err.Error())
  2907. // return err.Error()
  2908. // }
  2909. // str := string(respBytes)
  2910. // fmt.Println(str)
  2911. // return str
  2912. //}
  2913. // 生成签名
  2914. func setSignature(timestamp int64, nonce string, secret_key string) string {
  2915. str := strconv.FormatInt(timestamp, 10) + secret_key + nonce + strconv.FormatInt(timestamp, 10)
  2916. hash := sha256.New()
  2917. //输入数据
  2918. hash.Write([]byte(str))
  2919. //计算哈希值
  2920. bytes := hash.Sum(nil)
  2921. //将字符串编码为16进制格式,返回字符串
  2922. hashCode := hex.EncodeToString(bytes)
  2923. //返回哈希值
  2924. return hashCode
  2925. }
  2926. // 生成随机字符串
  2927. func GetRandomString(l int) string {
  2928. str := "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
  2929. bytes := []byte(str)
  2930. result := []byte{}
  2931. r := rand.New(rand.NewSource(time.Now().UnixNano()))
  2932. for i := 0; i < l; i++ {
  2933. result = append(result, bytes[r.Intn(len(bytes))])
  2934. }
  2935. return string(result)
  2936. }
  2937. // 生成基础报文
  2938. func SetInputMessage(nonce string, timestamp int64, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) map[string]interface{} {
  2939. // 生成签名
  2940. tempTime := time.Unix(timestamp, 0)
  2941. //timeFormat := tempTime.Format("20060102150405")
  2942. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2943. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  2944. month := time.Unix(1557042972, 0).Format("1")
  2945. year := time.Now().Format("2006")
  2946. month = time.Now().Format("01")
  2947. day := time.Now().Format("02")
  2948. hour := time.Now().Format("15")
  2949. min := time.Now().Format("04")
  2950. sec := time.Now().Format("05")
  2951. msec := time.Now().Format("000")
  2952. // 生成输入报文
  2953. inputMessage := make(map[string]interface{})
  2954. inputMessage["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  2955. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  2956. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  2957. inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  2958. inputMessage["dev_no"] = "" // 设备编号
  2959. inputMessage["dev_safe_info"] = "" // 设备安全信息
  2960. inputMessage["cainfo"] = "" // 数字签名信息
  2961. inputMessage["signtype"] = "SM3" // 签名类型
  2962. inputMessage["infver"] = "V1.0" // 接收方系统代码
  2963. inputMessage["opter_type"] = "1" // 经办人类别
  2964. inputMessage["opter"] = doctor // 经办人
  2965. inputMessage["opter_name"] = doctor // 经办人姓名
  2966. inputMessage["inf_time"] = timeFormatOne // 交易时间
  2967. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  2968. inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  2969. if mdtrtarea_admvs == "440100" {
  2970. inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号
  2971. } else {
  2972. inputMessage["sign_no"] = "" //交易签到流水号
  2973. }
  2974. return inputMessage
  2975. }
  2976. func SetInputMessageThree(nonce string, timestamp int64, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, msg_id string) map[string]interface{} {
  2977. // 生成签名
  2978. tempTime := time.Unix(timestamp, 0)
  2979. //timeFormat := tempTime.Format("20060102150405")
  2980. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2981. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  2982. // 生成输入报文
  2983. inputMessage := make(map[string]interface{})
  2984. inputMessage["msgid"] = msg_id // 发送方报文 ID
  2985. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  2986. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  2987. inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  2988. inputMessage["dev_no"] = "" // 设备编号
  2989. inputMessage["dev_safe_info"] = "" // 设备安全信息
  2990. inputMessage["cainfo"] = "" // 数字签名信息
  2991. inputMessage["signtype"] = "SM3" // 签名类型
  2992. inputMessage["infver"] = "V1.0" // 接收方系统代码
  2993. inputMessage["opter_type"] = "1" // 经办人类别
  2994. inputMessage["opter"] = doctor // 经办人
  2995. inputMessage["opter_name"] = doctor // 经办人姓名
  2996. inputMessage["inf_time"] = timeFormatOne // 交易时间
  2997. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  2998. inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  2999. if mdtrtarea_admvs == "440100" {
  3000. inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号
  3001. } else {
  3002. inputMessage["sign_no"] = "" //交易签到流水号
  3003. }
  3004. return inputMessage
  3005. }
  3006. func SetInputMessageTwo(nonce string, timestamp int64, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, sign_no string) map[string]interface{} {
  3007. // 生成签名
  3008. tempTime := time.Unix(timestamp, 0)
  3009. //timeFormat := tempTime.Format("20060102150405")
  3010. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  3011. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  3012. month := time.Unix(1557042972, 0).Format("1")
  3013. year := time.Now().Format("2006")
  3014. month = time.Now().Format("01")
  3015. day := time.Now().Format("02")
  3016. hour := time.Now().Format("15")
  3017. min := time.Now().Format("04")
  3018. sec := time.Now().Format("05")
  3019. msec := time.Now().Format("000")
  3020. // 生成输入报文
  3021. inputMessage := make(map[string]interface{})
  3022. inputMessage["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  3023. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  3024. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  3025. inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  3026. inputMessage["dev_no"] = "" // 设备编号
  3027. inputMessage["dev_safe_info"] = "" // 设备安全信息
  3028. inputMessage["cainfo"] = "" // 数字签名信息
  3029. inputMessage["signtype"] = "SM3" // 签名类型
  3030. inputMessage["infver"] = "V1.0" // 接收方系统代码
  3031. inputMessage["opter_type"] = "1" // 经办人类别
  3032. inputMessage["opter"] = doctor // 经办人
  3033. inputMessage["opter_name"] = doctor // 经办人姓名
  3034. inputMessage["inf_time"] = timeFormatOne // 交易时间
  3035. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  3036. inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  3037. if mdtrtarea_admvs == "440100" {
  3038. inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号
  3039. } else {
  3040. inputMessage["sign_no"] = "" //交易签到流水号
  3041. }
  3042. return inputMessage
  3043. }
  3044. func postFile(filename string, target_url string) (*http.Response, error) {
  3045. body_buf := bytes.NewBufferString("")
  3046. body_writer := multipart.NewWriter(body_buf)
  3047. // use the body_writer to write the Part headers to the buffer
  3048. _, err := body_writer.CreateFormFile("userfile", filename)
  3049. if err != nil {
  3050. fmt.Println("error writing to buffer")
  3051. return nil, err
  3052. }
  3053. // the file data will be the second part of the body
  3054. fh, err := os.Open(filename)
  3055. if err != nil {
  3056. fmt.Println("error opening file")
  3057. return nil, err
  3058. }
  3059. // need to know the boundary to properly close the part myself.
  3060. boundary := body_writer.Boundary()
  3061. //close_string := fmt.Sprintf("\r\n--%s--\r\n", boundary)
  3062. close_buf := bytes.NewBufferString(fmt.Sprintf("\r\n--%s--\r\n", boundary))
  3063. // use multi-reader to defer the reading of the file data until
  3064. // writing to the socket buffer.
  3065. request_reader := io.MultiReader(body_buf, fh, close_buf)
  3066. fi, err := fh.Stat()
  3067. if err != nil {
  3068. fmt.Printf("Error Stating file: %s", filename)
  3069. return nil, err
  3070. }
  3071. req, err := http.NewRequest("POST", target_url, request_reader)
  3072. if err != nil {
  3073. return nil, err
  3074. }
  3075. // Set headers for multipart, and Content Length
  3076. req.Header.Add("Content-Type", "multipart/form-data; boundary="+boundary)
  3077. req.ContentLength = fi.Size() + int64(body_buf.Len()) + int64(close_buf.Len())
  3078. return http.DefaultClient.Do(req)
  3079. }
  3080. //func Gdyb1201(psnNo string, org_name string, doctor string) string {
  3081. // // 生成签名
  3082. // nonce := GetRandomString(32)
  3083. // timestamp := time.Now().Unix()
  3084. // signature := setSignature(timestamp, nonce)
  3085. //
  3086. // // 生成输入报文
  3087. // inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, "")
  3088. // input := make(map[string]interface{})
  3089. // inputData := make(map[string]interface{})
  3090. // inputMessage["infno"] = "1201" // 交易编码
  3091. // inputData["fixmedins_type"] = psnNo // 人员编号 (来自1101接口返回)
  3092. // inputData["fixmedins_name"] = org_name // 人员编号 (来自1101接口返回)
  3093. // inputData["fixmedins_code"] = "" // 人员编号 (来自1101接口返回)
  3094. //
  3095. // input["medinsinfo"] = inputData
  3096. // inputMessage["input"] = input //交易输入
  3097. //
  3098. // bytesData, err := json.Marshal(inputMessage)
  3099. // fmt.Println(string(bytesData))
  3100. // if err != nil {
  3101. // fmt.Println(err.Error())
  3102. // return err.Error()
  3103. // }
  3104. // reader := bytes.NewReader(bytesData)
  3105. //
  3106. // url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1201"
  3107. // request, err := http.NewRequest("POST", url, reader)
  3108. // if err != nil {
  3109. // fmt.Println(err.Error())
  3110. // return err.Error()
  3111. // }
  3112. //
  3113. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3114. // request.Header.Set("x-tif-paasid", "test_hosp")
  3115. // request.Header.Set("x-tif-signature", signature)
  3116. // request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3117. // request.Header.Set("x-tif-nonce", nonce)
  3118. //
  3119. // client := http.Client{}
  3120. // resp, err := client.Do(request)
  3121. // if err != nil {
  3122. // fmt.Println(err.Error())
  3123. // return err.Error()
  3124. // }
  3125. // respBytes, err := ioutil.ReadAll(resp.Body)
  3126. // if err != nil {
  3127. // fmt.Println(err.Error())
  3128. // return err.Error()
  3129. // }
  3130. // str := string(respBytes)
  3131. // fmt.Println(str)
  3132. // return str
  3133. //}
  3134. func newfileUploadRequest(uri string, params map[string]string, paramName, path string) (*http.Request, error) {
  3135. file, err := os.Open(path)
  3136. if err != nil {
  3137. return nil, err
  3138. }
  3139. defer file.Close()
  3140. body := &bytes.Buffer{}
  3141. writer := multipart.NewWriter(body)
  3142. part, err := writer.CreateFormFile(paramName, filepath.Base(path))
  3143. if err != nil {
  3144. return nil, err
  3145. }
  3146. _, err = io.Copy(part, file)
  3147. for key, val := range params {
  3148. _ = writer.WriteField(key, val)
  3149. }
  3150. err = writer.Close()
  3151. if err != nil {
  3152. return nil, err
  3153. }
  3154. req, err := http.NewRequest("POST", uri, body)
  3155. req.Header.Set("Content-Type", writer.FormDataContentType())
  3156. return req, err
  3157. }
  3158. func CreateMedicalInsuranceCostCompareRecord(record *models.MedicalInsuranceCostCompare) error {
  3159. err := writeDb.Save(&record).Error
  3160. return err
  3161. }
  3162. //func Gdyb5203(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  3163. // // 生成签名
  3164. // nonce := GetRandomString(32)
  3165. // timestamp := time.Now().Unix()
  3166. // signature := setSignature(timestamp, nonce, secret_key)
  3167. //
  3168. // // 生成输入报文
  3169. // inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3170. // input := make(map[string]interface{})
  3171. // inputData := make(map[string]interface{})
  3172. // inputMessage["infno"] = "5203" // 交易编码
  3173. //
  3174. // inputData["fixmedins_type"] = "1"
  3175. // inputData["fixmedins_name"] = org_name
  3176. // inputData["fixmedins_code"] = fixmedins_code
  3177. // input["medinsinfo"] = inputData
  3178. // inputMessage["input"] = input //交易输入
  3179. //
  3180. // bytesData, err := json.Marshal(inputMessage)
  3181. // fmt.Println(string(bytesData))
  3182. // if err != nil {
  3183. // fmt.Println(err.Error())
  3184. // return err.Error()
  3185. // }
  3186. // reader := bytes.NewReader(bytesData)
  3187. // url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1201"
  3188. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1201"
  3189. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  3190. // request, err := http.NewRequest("POST", url, reader)
  3191. // if err != nil {
  3192. // fmt.Println(err.Error())
  3193. // return err.Error()
  3194. // }
  3195. //
  3196. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3197. // request.Header.Set("x-tif-paasid", "sg03_prd")
  3198. // request.Header.Set("x-tif-signature", signature)
  3199. // request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3200. // request.Header.Set("x-tif-nonce", nonce)
  3201. //
  3202. // client := http.Client{}
  3203. // resp, err := client.Do(request)
  3204. // if err != nil {
  3205. // fmt.Println(err.Error())
  3206. // return err.Error()
  3207. // }
  3208. // respBytes, err := ioutil.ReadAll(resp.Body)
  3209. // if err != nil {
  3210. // fmt.Println(err.Error())
  3211. // return err.Error()
  3212. // }
  3213. // fmt.Println(string(respBytes))
  3214. // str := string(respBytes)
  3215. // return str
  3216. //}
  3217. func CreatePsnRecord(record *models.GdybPsnRecord) {
  3218. writeDb.Save(&record)
  3219. return
  3220. }
  3221. func GetPsnRecordById(id int64) (record models.GdybPsnRecord, err error) {
  3222. err = readDb.Model(&models.GdybPsnRecord{}).Where("id = ?").First(&record).Error
  3223. return
  3224. }
  3225. func CreatePsnNCDSRecord(record *models.GdybPsnNcdsRecord) {
  3226. writeDb.Save(&record)
  3227. return
  3228. }
  3229. func GetPsnNCDSRecordById(id int64) (record models.GdybPsnNcdsRecord, err error) {
  3230. err = readDb.Model(&models.GdybPsnNcdsRecord{}).Where("id = ?", id).First(&record).Error
  3231. return
  3232. }
  3233. func GetPatientsByIds(ids []string, current_org_id int64) (patients []*models.Patients, err error) {
  3234. err = readDb.Model(&models.Patients{}).Where("id IN (?) AND user_org_id = ?", ids, current_org_id).Find(&patients).Error
  3235. return
  3236. }
  3237. func Gdyb2601(psnNo string, omsgid string, oinfno string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  3238. // 生成签名
  3239. nonce := GetRandomString(32)
  3240. timestamp := time.Now().Unix()
  3241. signature := setSignature(timestamp, nonce, secret_key)
  3242. // 生成输入报文
  3243. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3244. input := make(map[string]interface{})
  3245. inputData := make(map[string]interface{})
  3246. inputMessage["infno"] = "2601" // 交易编码
  3247. inputData["psn_no"] = psnNo
  3248. inputData["omsgid"] = omsgid
  3249. inputData["oinfno"] = oinfno
  3250. input["data"] = inputData
  3251. inputMessage["input"] = input //交易输入
  3252. bytesData, err := json.Marshal(inputMessage)
  3253. fmt.Println(string(bytesData))
  3254. if err != nil {
  3255. fmt.Println(err.Error())
  3256. return err.Error()
  3257. }
  3258. reader := bytes.NewReader(bytesData)
  3259. gdyb_url := beego.AppConfig.String("gdyb_url")
  3260. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3261. url := gdyb_url + "2601"
  3262. request, err := http.NewRequest("POST", url, reader)
  3263. if err != nil {
  3264. fmt.Println(err.Error())
  3265. return err.Error()
  3266. }
  3267. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3268. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3269. request.Header.Set("x-tif-signature", signature)
  3270. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3271. request.Header.Set("x-tif-nonce", nonce)
  3272. client := http.Client{}
  3273. resp, err := client.Do(request)
  3274. if err != nil {
  3275. fmt.Println(err.Error())
  3276. return err.Error()
  3277. }
  3278. respBytes, err := ioutil.ReadAll(resp.Body)
  3279. if err != nil {
  3280. fmt.Println(err.Error())
  3281. return err.Error()
  3282. }
  3283. str := string(respBytes)
  3284. fmt.Println(str)
  3285. return str
  3286. }
  3287. //人员信息版本3
  3288. func Gdyb1101B(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, card_sn string, certificates int64) string {
  3289. //生成签名
  3290. nonce := GetRandomString(32)
  3291. timestamp := time.Now().Unix()
  3292. signature := setSignature(timestamp, nonce, secret_key)
  3293. //生成输入报文
  3294. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3295. input := make(map[string]interface{})
  3296. inputData := make(map[string]interface{})
  3297. inputMessage["infno"] = "1101" // 交易编码
  3298. if certificates == 3 {
  3299. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  3300. inputData["certno"] = certNo // 证件号码
  3301. inputData["psn_cert_type"] = "99" // 人员证件类型
  3302. } else {
  3303. if certificates == 1 {
  3304. if id_card_type == 1 {
  3305. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  3306. inputData["card_sn"] = "" // 卡识别码
  3307. inputData["certno"] = certNo // 证件号码
  3308. inputData["psn_cert_type"] = "01" // 人员证件类型
  3309. } else {
  3310. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  3311. inputData["card_sn"] = "" // 卡识别码
  3312. inputData["certno"] = certNo // 证件号码
  3313. inputData["psn_cert_type"] = "01" // 人员证件类型
  3314. }
  3315. } else if certificates == 6 {
  3316. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  3317. inputData["card_sn"] = "" // 卡识别码
  3318. inputData["certno"] = certNo // 证件号码
  3319. inputData["psn_cert_type"] = "17" // 人员证件类型
  3320. }
  3321. }
  3322. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  3323. inputData["begntime"] = "" // 开始时间
  3324. inputData["psn_name"] = "" // 人员姓名
  3325. input["data"] = inputData
  3326. inputMessage["input"] = input //交易输入
  3327. bytesData, err := json.Marshal(inputMessage)
  3328. fmt.Println(string(bytesData))
  3329. if err != nil {
  3330. fmt.Println(err.Error())
  3331. return err.Error()
  3332. }
  3333. reader := bytes.NewReader(bytesData)
  3334. gdyb_url := beego.AppConfig.String("gdyb_url")
  3335. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3336. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  3337. //url := gdyb_url + "1101"
  3338. var url string
  3339. if fixmedins_code == "H15049901371" {
  3340. url = gdyb_url
  3341. } else {
  3342. url = gdyb_url + "1101"
  3343. }
  3344. fmt.Println(url)
  3345. fmt.Println(gdyb_paasid)
  3346. fmt.Println(secret_key)
  3347. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  3348. request, err := http.NewRequest("POST", url, reader)
  3349. if err != nil {
  3350. fmt.Println(err.Error())
  3351. return err.Error()
  3352. }
  3353. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3354. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3355. request.Header.Set("x-tif-signature", signature)
  3356. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3357. request.Header.Set("x-tif-nonce", nonce)
  3358. client := http.Client{}
  3359. resp, err := client.Do(request)
  3360. if err != nil {
  3361. fmt.Println(err.Error())
  3362. return err.Error()
  3363. }
  3364. respBytes, err := ioutil.ReadAll(resp.Body)
  3365. if err != nil {
  3366. fmt.Println(err.Error())
  3367. return err.Error()
  3368. }
  3369. fmt.Println(string(respBytes))
  3370. str := string(respBytes)
  3371. return str
  3372. }
  3373. func Gdyb1101G(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, card_sn string, certificates int64, name string, cardNumber string) string {
  3374. //生成签名
  3375. nonce := GetRandomString(32)
  3376. timestamp := time.Now().Unix()
  3377. signature := setSignature(timestamp, nonce, secret_key)
  3378. //生成输入报文
  3379. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3380. input := make(map[string]interface{})
  3381. inputData := make(map[string]interface{})
  3382. inputMessage["infno"] = "1101" // 交易编码
  3383. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  3384. inputData["card_sn"] = card_sn // 卡识别码
  3385. inputData["certno"] = certNo // 证件号码
  3386. inputData["psn_cert_type"] = "01" // 人员证件类型
  3387. inputData["mdtrt_cert_no"] = cardNumber // 就诊凭证编号
  3388. inputData["begntime"] = "" // 开始时间
  3389. inputData["psn_name"] = name // 人员姓名
  3390. input["data"] = inputData
  3391. inputMessage["input"] = input //交易输入
  3392. bytesData, err := json.Marshal(inputMessage)
  3393. fmt.Println(string(bytesData))
  3394. if err != nil {
  3395. fmt.Println(err.Error())
  3396. return err.Error()
  3397. }
  3398. reader := bytes.NewReader(bytesData)
  3399. gdyb_url := beego.AppConfig.String("gdyb_url")
  3400. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3401. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  3402. //url := gdyb_url + "1101"
  3403. var url string
  3404. if fixmedins_code == "H15049901371" {
  3405. url = gdyb_url
  3406. } else {
  3407. url = gdyb_url + "1101"
  3408. }
  3409. fmt.Println(url)
  3410. fmt.Println(gdyb_paasid)
  3411. fmt.Println(secret_key)
  3412. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  3413. request, err := http.NewRequest("POST", url, reader)
  3414. if err != nil {
  3415. fmt.Println(err.Error())
  3416. return err.Error()
  3417. }
  3418. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3419. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3420. request.Header.Set("x-tif-signature", signature)
  3421. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3422. request.Header.Set("x-tif-nonce", nonce)
  3423. client := http.Client{}
  3424. resp, err := client.Do(request)
  3425. if err != nil {
  3426. fmt.Println(err.Error())
  3427. return err.Error()
  3428. }
  3429. respBytes, err := ioutil.ReadAll(resp.Body)
  3430. if err != nil {
  3431. fmt.Println(err.Error())
  3432. return err.Error()
  3433. }
  3434. fmt.Println(string(respBytes))
  3435. str := string(respBytes)
  3436. return str
  3437. }
  3438. func Gdyb1101ForEleCert(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, token string) (string, string) {
  3439. //生成签名
  3440. nonce := GetRandomString(32)
  3441. timestamp := time.Now().Unix()
  3442. signature := setSignature(timestamp, nonce, secret_key)
  3443. //生成输入报文
  3444. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3445. input := make(map[string]interface{})
  3446. inputData := make(map[string]interface{})
  3447. inputMessage["infno"] = "1101" // 交易编码
  3448. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  3449. inputData["card_sn"] = "" // 卡识别码
  3450. inputData["certno"] = "" // 证件号码
  3451. inputData["psn_cert_type"] = "01" // 人员证件类型
  3452. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  3453. inputData["begntime"] = "" // 开始时间
  3454. inputData["psn_name"] = "" // 人员姓名
  3455. input["data"] = inputData
  3456. inputMessage["input"] = input //交易输入
  3457. bytesData, err := json.Marshal(inputMessage)
  3458. fmt.Println(string(bytesData))
  3459. if err != nil {
  3460. fmt.Println(err.Error())
  3461. return err.Error(), ""
  3462. }
  3463. reader := bytes.NewReader(bytesData)
  3464. gdyb_url := beego.AppConfig.String("gdyb_url")
  3465. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3466. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  3467. //url := gdyb_url + "1101"
  3468. var url string
  3469. if fixmedins_code == "H15049901371" {
  3470. url = gdyb_url
  3471. } else {
  3472. url = gdyb_url + "1101"
  3473. }
  3474. fmt.Println(url)
  3475. fmt.Println(gdyb_paasid)
  3476. fmt.Println(secret_key)
  3477. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  3478. request, err := http.NewRequest("POST", url, reader)
  3479. if err != nil {
  3480. fmt.Println(err.Error())
  3481. return err.Error(), ""
  3482. }
  3483. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3484. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3485. request.Header.Set("x-tif-signature", signature)
  3486. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3487. request.Header.Set("x-tif-nonce", nonce)
  3488. client := http.Client{}
  3489. resp, err := client.Do(request)
  3490. if err != nil {
  3491. fmt.Println(err.Error())
  3492. return err.Error(), ""
  3493. }
  3494. respBytes, err := ioutil.ReadAll(resp.Body)
  3495. if err != nil {
  3496. fmt.Println(err.Error())
  3497. return err.Error(), ""
  3498. }
  3499. fmt.Println(string(respBytes))
  3500. str := string(respBytes)
  3501. return str, string(bytesData)
  3502. }
  3503. func Gdyb6101(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) (string, string) {
  3504. //生成签名
  3505. nonce := GetRandomString(32)
  3506. timestamp := time.Now().Unix()
  3507. signature := setSignature(timestamp, nonce, secret_key)
  3508. //生成输入报文
  3509. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3510. input := make(map[string]interface{})
  3511. inputData := make(map[string]interface{})
  3512. inputMessage["infno"] = "6101" // 交易编码
  3513. inputData["orgId"] = fixmedins_code // 就诊凭证类型
  3514. inputData["businessType"] = "01101" // 卡识别码
  3515. inputData["businessInfo"] = "" // 证件号码
  3516. inputData["operateorId"] = "01" // 人员证件类型
  3517. inputData["operateornName"] = doctor // 就诊凭证编号
  3518. inputData["officeId"] = "01" // 开始时间
  3519. inputData["officeName"] = "血透" // 人员姓名
  3520. inputData["deviceType"] = "" // 人员姓名
  3521. input["InData"] = inputData
  3522. inputMessage["input"] = input //交易输入
  3523. bytesData, err := json.Marshal(inputMessage)
  3524. fmt.Println(string(bytesData))
  3525. if err != nil {
  3526. fmt.Println(err.Error())
  3527. return err.Error(), ""
  3528. }
  3529. reader := bytes.NewReader(bytesData)
  3530. gdyb_url := beego.AppConfig.String("gdyb_url")
  3531. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3532. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  3533. //url := gdyb_url + "1101"
  3534. var url string
  3535. if fixmedins_code == "H15049901371" {
  3536. url = gdyb_url
  3537. } else {
  3538. url = gdyb_url + "1101"
  3539. }
  3540. fmt.Println(url)
  3541. fmt.Println(gdyb_paasid)
  3542. fmt.Println(secret_key)
  3543. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  3544. request, err := http.NewRequest("POST", url, reader)
  3545. if err != nil {
  3546. fmt.Println(err.Error())
  3547. return err.Error(), ""
  3548. }
  3549. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3550. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3551. request.Header.Set("x-tif-signature", signature)
  3552. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3553. request.Header.Set("x-tif-nonce", nonce)
  3554. client := http.Client{}
  3555. resp, err := client.Do(request)
  3556. if err != nil {
  3557. fmt.Println(err.Error())
  3558. return err.Error(), ""
  3559. }
  3560. respBytes, err := ioutil.ReadAll(resp.Body)
  3561. if err != nil {
  3562. fmt.Println(err.Error())
  3563. return err.Error(), ""
  3564. }
  3565. fmt.Println(string(respBytes))
  3566. str := string(respBytes)
  3567. return str, string(bytesData)
  3568. }
  3569. //人员信息版本4
  3570. func Gdyb1101C(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, card_sn string, certificates int64) (string, string) {
  3571. //生成签名
  3572. nonce := GetRandomString(32)
  3573. timestamp := time.Now().Unix()
  3574. //signature := setSignature(timestamp, nonce, secret_key)
  3575. //生成输入报文
  3576. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3577. input := make(map[string]interface{})
  3578. inputData := make(map[string]interface{})
  3579. inputMessage["infno"] = "1101" // 交易编码
  3580. if certificates == 3 {
  3581. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  3582. inputData["certno"] = certNo // 证件号码
  3583. inputData["psn_cert_type"] = "99" // 人员证件类型
  3584. } else {
  3585. if id_card_type == 1 {
  3586. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  3587. inputData["card_sn"] = "" // 卡识别码
  3588. inputData["certno"] = "" // 证件号码
  3589. inputData["psn_cert_type"] = "" // 人员证件类型
  3590. } else {
  3591. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  3592. inputData["card_sn"] = "" // 卡识别码
  3593. inputData["certno"] = certNo // 证件号码
  3594. inputData["psn_cert_type"] = "1" // 人员证件类型
  3595. }
  3596. }
  3597. inputData["mdtrt_cert_no"] = "" // 就诊凭证编号
  3598. inputData["begntime"] = "" // 开始时间
  3599. inputData["psn_name"] = "" // 人员姓名
  3600. input["data"] = inputData
  3601. inputMessage["input"] = input //交易输入
  3602. bytesData, err := json.Marshal(inputMessage)
  3603. fmt.Println(string(bytesData))
  3604. if err != nil {
  3605. fmt.Println(err.Error())
  3606. return err.Error(), ""
  3607. }
  3608. var json2 string
  3609. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  3610. out, err := cmd.Output()
  3611. if err != nil {
  3612. fmt.Println("error:", err.Error())
  3613. }
  3614. fmt.Println(string(out))
  3615. return string(out), string(bytesData)
  3616. }
  3617. func StrPtr(s string) uintptr {
  3618. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  3619. }
  3620. func Gdyb90991(psn_no string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, pwd string, card_number string) string {
  3621. //生成签名
  3622. nonce := GetRandomString(32)
  3623. timestamp := time.Now().Unix()
  3624. signature := setSignature(timestamp, nonce, secret_key)
  3625. //生成输入报文
  3626. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3627. input := make(map[string]interface{})
  3628. inputData := make(map[string]interface{})
  3629. inputMessage["infno"] = "90991" // 交易编码
  3630. inputData["fixmedins_code"] = fixmedins_code // 就诊凭证编号
  3631. inputData["psn_no"] = psn_no // 开始时间
  3632. inputData["card_pwd"] = pwd // 人员姓名
  3633. inputData["sscno"] = card_number // 人员姓名
  3634. input["data"] = inputData
  3635. inputMessage["input"] = input //交易输入
  3636. bytesData, err := json.Marshal(inputMessage)
  3637. fmt.Println(string(bytesData))
  3638. if err != nil {
  3639. fmt.Println(err.Error())
  3640. return err.Error()
  3641. }
  3642. reader := bytes.NewReader(bytesData)
  3643. gdyb_url := beego.AppConfig.String("gdyb_url")
  3644. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3645. url := gdyb_url + "90991"
  3646. request, err := http.NewRequest("POST", url, reader)
  3647. if err != nil {
  3648. fmt.Println(err.Error())
  3649. return err.Error()
  3650. }
  3651. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3652. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3653. request.Header.Set("x-tif-signature", signature)
  3654. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3655. request.Header.Set("x-tif-nonce", nonce)
  3656. client := http.Client{}
  3657. resp, err := client.Do(request)
  3658. if err != nil {
  3659. fmt.Println(err.Error())
  3660. return err.Error()
  3661. }
  3662. respBytes, err := ioutil.ReadAll(resp.Body)
  3663. if err != nil {
  3664. fmt.Println(err.Error())
  3665. return err.Error()
  3666. }
  3667. fmt.Println(string(respBytes))
  3668. str := string(respBytes)
  3669. return str
  3670. }
  3671. func Gdyb90100(psn_no string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  3672. //生成签名
  3673. nonce := GetRandomString(32)
  3674. timestamp := time.Now().Unix()
  3675. signature := setSignature(timestamp, nonce, secret_key)
  3676. //生成输入报文
  3677. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3678. input := make(map[string]interface{})
  3679. inputData := make(map[string]interface{})
  3680. inputMessage["infno"] = "90100" // 交易编码
  3681. inputData["psn_no"] = psn_no // 开始时间
  3682. input["data"] = inputData
  3683. inputMessage["input"] = input //交易输入
  3684. bytesData, err := json.Marshal(inputMessage)
  3685. fmt.Println(string(bytesData))
  3686. if err != nil {
  3687. fmt.Println(err.Error())
  3688. return err.Error()
  3689. }
  3690. reader := bytes.NewReader(bytesData)
  3691. gdyb_url := beego.AppConfig.String("gdyb_url")
  3692. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3693. url := gdyb_url + "90100"
  3694. request, err := http.NewRequest("POST", url, reader)
  3695. if err != nil {
  3696. fmt.Println(err.Error())
  3697. return err.Error()
  3698. }
  3699. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3700. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3701. request.Header.Set("x-tif-signature", signature)
  3702. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3703. request.Header.Set("x-tif-nonce", nonce)
  3704. client := http.Client{}
  3705. resp, err := client.Do(request)
  3706. if err != nil {
  3707. fmt.Println(err.Error())
  3708. return err.Error()
  3709. }
  3710. respBytes, err := ioutil.ReadAll(resp.Body)
  3711. if err != nil {
  3712. fmt.Println(err.Error())
  3713. return err.Error()
  3714. }
  3715. fmt.Println(string(respBytes))
  3716. str := string(respBytes)
  3717. return str
  3718. }
  3719. func Gdyb3260(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, year string, month string, sign string) (string, string) {
  3720. //生成签名
  3721. nonce := GetRandomString(32)
  3722. timestamp := time.Now().Unix()
  3723. signature := setSignature(timestamp, nonce, secret_key)
  3724. //生成输入报文
  3725. inputMessage := SetInputMessageTwo(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, sign)
  3726. input := make(map[string]interface{})
  3727. inputData := make(map[string]interface{})
  3728. inputMessage["infno"] = "3260" // 交易编码
  3729. inputData["trt_year"] = year // 就诊凭证编号
  3730. inputData["trt_month"] = month // 开始时间
  3731. inputData["startrow"] = "100" // 人员姓名
  3732. input["data"] = inputData
  3733. inputMessage["input"] = input //交易输入
  3734. var inputLog string
  3735. bytesData, err := json.Marshal(inputMessage)
  3736. inputLog = string(bytesData)
  3737. fmt.Println(string(bytesData))
  3738. if err != nil {
  3739. fmt.Println(err.Error())
  3740. return err.Error(), ""
  3741. }
  3742. reader := bytes.NewReader(bytesData)
  3743. gdyb_url := beego.AppConfig.String("gdyb_url")
  3744. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3745. var url string
  3746. if fixmedins_code == "H15049901371" {
  3747. url = gdyb_url
  3748. } else {
  3749. url = gdyb_url + "3260"
  3750. }
  3751. if insuplc_admdvs == "421300" {
  3752. var json2 string
  3753. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  3754. out, err := cmd.Output()
  3755. if err != nil {
  3756. fmt.Println("error:", err.Error())
  3757. }
  3758. fmt.Println(string(out))
  3759. return hex.EncodeToString(out), inputLog
  3760. } else {
  3761. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  3762. request, err := http.NewRequest("POST", url, reader)
  3763. if err != nil {
  3764. fmt.Println(err.Error())
  3765. return err.Error(), ""
  3766. }
  3767. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3768. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3769. request.Header.Set("x-tif-signature", signature)
  3770. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3771. request.Header.Set("x-tif-nonce", nonce)
  3772. client := http.Client{}
  3773. resp, err := client.Do(request)
  3774. if err != nil {
  3775. fmt.Println(err.Error())
  3776. return err.Error(), ""
  3777. }
  3778. respBytes, err := ioutil.ReadAll(resp.Body)
  3779. if err != nil {
  3780. fmt.Println(err.Error())
  3781. return err.Error(), ""
  3782. }
  3783. fmt.Println(string(respBytes))
  3784. str := string(respBytes)
  3785. return str, inputLog
  3786. }
  3787. }
  3788. func Gdyb3261(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, year string, month string, result3260 models.Result3260) (string, string, string) {
  3789. //生成签名
  3790. nonce := GetRandomString(32)
  3791. timestamp := time.Now().Unix()
  3792. signature := setSignature(timestamp, nonce, secret_key)
  3793. msg_month := time.Unix(1557042972, 0).Format("1")
  3794. msg_year := time.Now().Format("2006")
  3795. msg_month = time.Now().Format("01")
  3796. day := time.Now().Format("02")
  3797. hour := time.Now().Format("15")
  3798. min := time.Now().Format("04")
  3799. sec := time.Now().Format("05")
  3800. msec := time.Now().Format("000")
  3801. msg_id := fixmedins_code + msg_year + msg_month + day + hour + min + sec + msec + "0"
  3802. //生成输入报文
  3803. inputMessage := SetInputMessageThree(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, msg_id)
  3804. input := make(map[string]interface{})
  3805. inputData := make(map[string]interface{})
  3806. inputMessage["infno"] = "3261" // 交易编码
  3807. inputData["trt_year"] = year // 就诊凭证编号
  3808. inputData["trt_month"] = month // 开始时间
  3809. inputData["startrow"] = len(result3260.Output.Data) // 人员姓名
  3810. feedetail := make([]map[string]interface{}, 0)
  3811. for _, item := range result3260.Output.Data {
  3812. feedetailInfo := make(map[string]interface{})
  3813. feedetailInfo["certno"] = item.Certno
  3814. feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  3815. feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  3816. feedetailInfo["setl_no"] = item.SetlNo // 收费批次号
  3817. feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  3818. feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  3819. feedetail = append(feedetail, feedetailInfo)
  3820. }
  3821. inputData["detail"] = feedetail // 人员姓名
  3822. input["data"] = inputData
  3823. inputMessage["input"] = input //交易输入
  3824. var inputLog string
  3825. bytesData, err := json.Marshal(inputMessage)
  3826. inputLog = string(bytesData)
  3827. fmt.Println(string(bytesData))
  3828. if err != nil {
  3829. fmt.Println(err.Error())
  3830. return err.Error(), "", ""
  3831. }
  3832. reader := bytes.NewReader(bytesData)
  3833. gdyb_url := beego.AppConfig.String("gdyb_url")
  3834. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3835. var url string
  3836. if fixmedins_code == "H15049901371" {
  3837. url = gdyb_url
  3838. } else {
  3839. url = gdyb_url + "3261"
  3840. }
  3841. if insuplc_admdvs == "421300" {
  3842. var json2 string
  3843. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  3844. out, err := cmd.Output()
  3845. if err != nil {
  3846. fmt.Println("error:", err.Error())
  3847. }
  3848. fmt.Println(string(out))
  3849. return hex.EncodeToString(out), inputLog, ""
  3850. } else {
  3851. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  3852. request, err := http.NewRequest("POST", url, reader)
  3853. if err != nil {
  3854. fmt.Println(err.Error())
  3855. return err.Error(), "", ""
  3856. }
  3857. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3858. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3859. request.Header.Set("x-tif-signature", signature)
  3860. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3861. request.Header.Set("x-tif-nonce", nonce)
  3862. client := http.Client{}
  3863. resp, err := client.Do(request)
  3864. if err != nil {
  3865. fmt.Println(err.Error())
  3866. return err.Error(), "", ""
  3867. }
  3868. respBytes, err := ioutil.ReadAll(resp.Body)
  3869. if err != nil {
  3870. fmt.Println(err.Error())
  3871. return err.Error(), "", ""
  3872. }
  3873. fmt.Println(string(respBytes))
  3874. str := string(respBytes)
  3875. return str, inputLog, msg_id
  3876. }
  3877. }
  3878. func Gdyb3262(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, year string, month string, otransid string) (string, string) {
  3879. //生成签名
  3880. nonce := GetRandomString(32)
  3881. timestamp := time.Now().Unix()
  3882. signature := setSignature(timestamp, nonce, secret_key)
  3883. //生成输入报文
  3884. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3885. input := make(map[string]interface{})
  3886. inputData := make(map[string]interface{})
  3887. inputMessage["infno"] = "3262" // 交易编码
  3888. inputData["trt_year"] = year // 就诊凭证编号
  3889. inputData["trt_month"] = "" // 开始时间
  3890. inputData["otransid"] = otransid // 开始时间
  3891. input["data"] = inputData
  3892. inputMessage["input"] = input //交易输入
  3893. var inputLog string
  3894. bytesData, err := json.Marshal(inputMessage)
  3895. inputLog = string(bytesData)
  3896. fmt.Println(string(bytesData))
  3897. if err != nil {
  3898. fmt.Println(err.Error())
  3899. return err.Error(), ""
  3900. }
  3901. reader := bytes.NewReader(bytesData)
  3902. gdyb_url := beego.AppConfig.String("gdyb_url")
  3903. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3904. var url string
  3905. if fixmedins_code == "H15049901371" {
  3906. url = gdyb_url
  3907. } else {
  3908. url = gdyb_url + "3261"
  3909. }
  3910. if insuplc_admdvs == "421300" {
  3911. var json2 string
  3912. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  3913. out, err := cmd.Output()
  3914. if err != nil {
  3915. fmt.Println("error:", err.Error())
  3916. }
  3917. fmt.Println(string(out))
  3918. return hex.EncodeToString(out), inputLog
  3919. } else {
  3920. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  3921. request, err := http.NewRequest("POST", url, reader)
  3922. if err != nil {
  3923. fmt.Println(err.Error())
  3924. return err.Error(), ""
  3925. }
  3926. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3927. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3928. request.Header.Set("x-tif-signature", signature)
  3929. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3930. request.Header.Set("x-tif-nonce", nonce)
  3931. client := http.Client{}
  3932. resp, err := client.Do(request)
  3933. if err != nil {
  3934. fmt.Println(err.Error())
  3935. return err.Error(), ""
  3936. }
  3937. respBytes, err := ioutil.ReadAll(resp.Body)
  3938. if err != nil {
  3939. fmt.Println(err.Error())
  3940. return err.Error(), ""
  3941. }
  3942. fmt.Println(string(respBytes))
  3943. str := string(respBytes)
  3944. return str, inputLog
  3945. }
  3946. }
  3947. func Gdyb9001(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, admin_user_id int64) (string, string) {
  3948. //生成签名
  3949. nonce := GetRandomString(32)
  3950. timestamp := time.Now().Unix()
  3951. signature := setSignature(timestamp, nonce, secret_key)
  3952. //生成输入报文
  3953. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3954. input := make(map[string]interface{})
  3955. inputData := make(map[string]interface{})
  3956. inputMessage["infno"] = "9001" // 交易编码
  3957. inputData["opter_no"] = admin_user_id // 就诊凭证编号
  3958. inputData["mac"] = "11-11-11-11-11" // 开始时间
  3959. inputData["ip"] = "11.11.11.11"
  3960. inputData["userid"] = "H44010400081"
  3961. month := time.Unix(1557042972, 0).Format("1")
  3962. year := time.Now().Format("2006")
  3963. month = time.Now().Format("01")
  3964. day := time.Now().Format("02")
  3965. hour := time.Now().Format("15")
  3966. min := time.Now().Format("04")
  3967. sec := time.Now().Format("05")
  3968. custom_time := year + month + day + hour + min + sec
  3969. inputData["currenttime"] = custom_time
  3970. var psd string
  3971. psd = custom_time + "Gzyb$867"
  3972. h := md5.New()
  3973. h.Write([]byte(psd))
  3974. inputData["password"] = strings.ToUpper(hex.EncodeToString(h.Sum(nil)))
  3975. input["data"] = inputData
  3976. inputMessage["input"] = input //交易输入
  3977. var inputLog string
  3978. bytesData, err := json.Marshal(inputMessage)
  3979. inputLog = string(bytesData)
  3980. fmt.Println(string(bytesData))
  3981. if err != nil {
  3982. fmt.Println(err.Error())
  3983. return err.Error(), ""
  3984. }
  3985. reader := bytes.NewReader(bytesData)
  3986. gdyb_url := beego.AppConfig.String("gdyb_url")
  3987. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3988. var url string
  3989. if fixmedins_code == "H15049901371" {
  3990. url = gdyb_url
  3991. } else {
  3992. url = gdyb_url + "9001"
  3993. }
  3994. if insuplc_admdvs == "421300" {
  3995. var json2 string
  3996. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  3997. out, err := cmd.Output()
  3998. if err != nil {
  3999. fmt.Println("error:", err.Error())
  4000. }
  4001. fmt.Println(string(out))
  4002. return hex.EncodeToString(out), inputLog
  4003. } else {
  4004. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4005. request, err := http.NewRequest("POST", url, reader)
  4006. if err != nil {
  4007. fmt.Println(err.Error())
  4008. return err.Error(), ""
  4009. }
  4010. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4011. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4012. request.Header.Set("x-tif-signature", signature)
  4013. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4014. request.Header.Set("x-tif-nonce", nonce)
  4015. fmt.Println(string(bytesData))
  4016. fmt.Println(gdyb_url)
  4017. fmt.Println(gdyb_paasid)
  4018. fmt.Println(request.Header)
  4019. client := http.Client{}
  4020. resp, err := client.Do(request)
  4021. if err != nil {
  4022. fmt.Println(err.Error())
  4023. return err.Error(), ""
  4024. }
  4025. respBytes, err := ioutil.ReadAll(resp.Body)
  4026. if err != nil {
  4027. fmt.Println(err.Error())
  4028. return err.Error(), ""
  4029. }
  4030. fmt.Println(string(respBytes))
  4031. str := string(respBytes)
  4032. return str, inputLog
  4033. }
  4034. }
  4035. //获取本机ip
  4036. func GetLocalIp() string {
  4037. addrs, err := net.InterfaceAddrs()
  4038. if err != nil {
  4039. fmt.Println("get local ip failed")
  4040. }
  4041. for _, address := range addrs {
  4042. if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
  4043. if ipnet.IP.To4() != nil {
  4044. return ipnet.IP.String()
  4045. }
  4046. }
  4047. }
  4048. return ""
  4049. }
  4050. //获取本机Mac
  4051. func GetMac() string {
  4052. interfaces, err := net.Interfaces()
  4053. if err != nil {
  4054. fmt.Println("Get loacl Mac failed")
  4055. }
  4056. for _, inter := range interfaces {
  4057. mac := inter.HardwareAddr
  4058. fmt.Println("+======" + mac.String())
  4059. if mac.String() != "" {
  4060. return mac.String()
  4061. }
  4062. }
  4063. return ""
  4064. }
  4065. // 人员基本信息
  4066. func Gdyb1101D(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, card_sn string, certificates string, psn_name string, record_date string) (string, string) {
  4067. //生成签名
  4068. nonce := GetRandomString(32)
  4069. timestamp := time.Now().Unix()
  4070. signature := setSignature(timestamp, nonce, secret_key)
  4071. //生成输入报文
  4072. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4073. input := make(map[string]interface{})
  4074. inputData := make(map[string]interface{})
  4075. inputMessage["infno"] = "1101" // 交易编码
  4076. if certificates == "3" {
  4077. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  4078. inputData["certno"] = certNo // 证件号码
  4079. inputData["psn_cert_type"] = "99" // 人员证件类型
  4080. } else {
  4081. if certificates == "1" {
  4082. if id_card_type == 1 {
  4083. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  4084. inputData["card_sn"] = "" // 卡识别码
  4085. inputData["certno"] = certNo // 证件号码
  4086. inputData["psn_cert_type"] = "01" // 人员证件类型
  4087. } else if id_card_type == 4 {
  4088. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  4089. inputData["certno"] = certNo // 证件号码
  4090. inputData["psn_cert_type"] = "01" // 人员证件类型
  4091. } else {
  4092. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  4093. inputData["card_sn"] = "" // 卡识别码
  4094. inputData["certno"] = certNo // 证件号码
  4095. inputData["psn_cert_type"] = "01" // 人员证件类型
  4096. }
  4097. } else if certificates == "6" {
  4098. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  4099. inputData["card_sn"] = "" // 卡识别码
  4100. inputData["certno"] = certNo // 证件号码
  4101. inputData["psn_cert_type"] = "17" // 人员证件类型
  4102. }
  4103. }
  4104. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  4105. inputData["begntime"] = "" // 开始时间
  4106. inputData["psn_name"] = "" // 人员姓名
  4107. input["data"] = inputData
  4108. inputMessage["input"] = input //交易输入
  4109. var inputLog string
  4110. bytesData, err := json.Marshal(inputMessage)
  4111. inputLog = string(bytesData)
  4112. fmt.Println(string(bytesData))
  4113. if err != nil {
  4114. fmt.Println(err.Error())
  4115. return err.Error(), ""
  4116. }
  4117. reader := bytes.NewReader(bytesData)
  4118. gdyb_url := beego.AppConfig.String("gdyb_url")
  4119. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4120. //DllDef := syscall.MustLoadDLL("yh_hb_sctrl.dll")
  4121. //Iinit := DllDef.MustFindProc("yh_hb_call")
  4122. //var str3 string
  4123. //ret, _, _ := Iinit.Call(StrPtr("1101"), StrPtr(string(bytesData)), StrPtr(str3))
  4124. //fmt.Println(ret)
  4125. //fmt.Println(str3)
  4126. //
  4127. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4128. var url string
  4129. if fixmedins_code == "H15049901371" {
  4130. url = gdyb_url
  4131. } else {
  4132. url = gdyb_url + "1101"
  4133. }
  4134. if insuplc_admdvs == "421300" {
  4135. var json2 string
  4136. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  4137. out, err := cmd.Output()
  4138. if err != nil {
  4139. fmt.Println("error:", err.Error())
  4140. }
  4141. fmt.Println(string(out))
  4142. return hex.EncodeToString(out), inputLog
  4143. } else {
  4144. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4145. request, err := http.NewRequest("POST", url, reader)
  4146. if err != nil {
  4147. fmt.Println(err.Error())
  4148. return err.Error(), ""
  4149. }
  4150. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4151. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4152. request.Header.Set("x-tif-signature", signature)
  4153. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4154. request.Header.Set("x-tif-nonce", nonce)
  4155. client := http.Client{}
  4156. resp, err := client.Do(request)
  4157. if err != nil {
  4158. fmt.Println(err.Error())
  4159. return err.Error(), ""
  4160. }
  4161. respBytes, err := ioutil.ReadAll(resp.Body)
  4162. if err != nil {
  4163. fmt.Println(err.Error())
  4164. return err.Error(), ""
  4165. }
  4166. fmt.Println(string(respBytes))
  4167. str := string(respBytes)
  4168. return str, inputLog
  4169. }
  4170. }
  4171. //func SetInputMessageFour(nonce string, timestamp int64, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) map[string]interface{} {
  4172. // // 生成签名
  4173. // //tempTime := time.Unix(timestamp, 0)
  4174. // //timeFormat := tempTime.Format("20060102150405")
  4175. // //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  4176. // //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  4177. //
  4178. // msec := time.Now().Format("000")
  4179. // fmt.Println(utils.GetNetTime())
  4180. // // 生成输入报文
  4181. // inputMessage := make(map[string]interface{})
  4182. // inputMessage["msgid"] = fixmedins_code + utils.GetNetTime() + msec + "0" // 发送方报文 ID
  4183. // inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  4184. // inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  4185. // inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  4186. // inputMessage["dev_no"] = "" // 设备编号
  4187. // inputMessage["dev_safe_info"] = "" // 设备安全信息
  4188. // inputMessage["cainfo"] = "" // 数字签名信息
  4189. // inputMessage["signtype"] = "SM3" // 签名类型
  4190. // inputMessage["infver"] = "V1.0" // 接收方系统代码
  4191. // inputMessage["opter_type"] = "1" // 经办人类别
  4192. // inputMessage["opter"] = doctor // 经办人
  4193. // inputMessage["opter_name"] = doctor // 经办人姓名
  4194. // inputMessage["inf_time"] = utils.GetNetTime() // 交易时间
  4195. // inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  4196. // inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  4197. // inputMessage["sign_no"] = "" //交易签到流水号
  4198. // return inputMessage
  4199. //}
  4200. func Gdyb5302(psnNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  4201. // 生成签名
  4202. nonce := GetRandomString(32)
  4203. timestamp := time.Now().Unix()
  4204. signature := setSignature(timestamp, nonce, secret_key)
  4205. // 生成输入报文
  4206. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4207. input := make(map[string]interface{})
  4208. inputData := make(map[string]interface{})
  4209. inputMessage["infno"] = "5302" // 交易编码
  4210. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  4211. inputData["biz_appy_type"] = "03" // 人员编号 (来自1101接口返回)
  4212. input["data"] = inputData
  4213. inputMessage["input"] = input //交易输入
  4214. bytesData, err := json.Marshal(inputMessage)
  4215. fmt.Println(string(bytesData))
  4216. if err != nil {
  4217. fmt.Println(err.Error())
  4218. return err.Error()
  4219. }
  4220. reader := bytes.NewReader(bytesData)
  4221. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  4222. gdyb_url := beego.AppConfig.String("gdyb_url")
  4223. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4224. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4225. url := gdyb_url + "5302"
  4226. request, err := http.NewRequest("POST", url, reader)
  4227. if err != nil {
  4228. fmt.Println(err.Error())
  4229. return err.Error()
  4230. }
  4231. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4232. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4233. request.Header.Set("x-tif-signature", signature)
  4234. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4235. request.Header.Set("x-tif-nonce", nonce)
  4236. client := http.Client{}
  4237. resp, err := client.Do(request)
  4238. if err != nil {
  4239. fmt.Println(err.Error())
  4240. return err.Error()
  4241. }
  4242. respBytes, err := ioutil.ReadAll(resp.Body)
  4243. if err != nil {
  4244. fmt.Println(err.Error())
  4245. return err.Error()
  4246. }
  4247. str := string(respBytes)
  4248. fmt.Println(str)
  4249. return str
  4250. }
  4251. func CreateSignIn(record *models.HisSignIn) (err error) {
  4252. err = writeDb.Save(&record).Error
  4253. return
  4254. }
  4255. func GetSignInInfo(code string) string {
  4256. var sign models.HisSignIn
  4257. err = readDb.Model(&models.HisSignIn{}).Where("fixmedins_code = ? AND status = 1", code).Last(&sign).Error
  4258. return sign.SignNo
  4259. }