gdyb_service.go 223KB

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