gdyb_service.go 371KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405
  1. package service
  2. import (
  3. "bytes"
  4. "regexp"
  5. //"crypto/md5"
  6. "crypto/sha256"
  7. "encoding/hex"
  8. "encoding/json"
  9. "fmt"
  10. "gdyb/models"
  11. "strings"
  12. //"gdyb/utils"
  13. "github.com/astaxie/beego"
  14. "github.com/axgle/mahonia"
  15. "io"
  16. "io/ioutil"
  17. "math/rand"
  18. "mime/multipart"
  19. "net"
  20. "net/http"
  21. "os"
  22. "os/exec"
  23. "path/filepath"
  24. "strconv"
  25. "syscall"
  26. "time"
  27. "unsafe"
  28. )
  29. const (
  30. SceretKey = "RhaDw4H0RUbWYyTxmRKM1eSeN0qyGLds" // secretKey 私钥
  31. )
  32. // 机构信息
  33. 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 {
  34. // 生成签名
  35. nonce := GetRandomString(32)
  36. timestamp := time.Now().Unix()
  37. signature := setSignature(timestamp, nonce, secret_key)
  38. // 生成输入报文
  39. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  40. input := make(map[string]interface{})
  41. inputData := make(map[string]interface{})
  42. inputMessage["infno"] = "1201" // 交易编码
  43. inputData["fixmedins_type"] = "1"
  44. inputData["fixmedins_name"] = org_name
  45. inputData["fixmedins_code"] = fixmedins_code
  46. input["medinsinfo"] = inputData
  47. inputMessage["input"] = input //交易输入
  48. bytesData, err := json.Marshal(inputMessage)
  49. fmt.Println(string(bytesData))
  50. if err != nil {
  51. fmt.Println(err.Error())
  52. return err.Error()
  53. }
  54. reader := bytes.NewReader(bytesData)
  55. gdyb_url := beego.AppConfig.String("gdyb_url")
  56. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  57. url := gdyb_url + "1201"
  58. request, err := http.NewRequest("POST", url, reader)
  59. if err != nil {
  60. fmt.Println(err.Error())
  61. return err.Error()
  62. }
  63. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  64. request.Header.Set("x-tif-paasid", gdyb_paasid)
  65. request.Header.Set("x-tif-signature", signature)
  66. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  67. request.Header.Set("x-tif-nonce", nonce)
  68. client := http.Client{}
  69. resp, err := client.Do(request)
  70. if err != nil {
  71. fmt.Println(err.Error())
  72. return err.Error()
  73. }
  74. respBytes, err := ioutil.ReadAll(resp.Body)
  75. if err != nil {
  76. fmt.Println(err.Error())
  77. return err.Error()
  78. }
  79. fmt.Println(string(respBytes))
  80. str2 := string(respBytes)
  81. return str2
  82. }
  83. // 人员基本信息
  84. 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) {
  85. //生成签名
  86. nonce := GetRandomString(32)
  87. timestamp := time.Now().Unix()
  88. signature := setSignature(timestamp, nonce, secret_key)
  89. //生成输入报文
  90. inputMessage := SetInputMessagenosign(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  91. input := make(map[string]interface{})
  92. inputData := make(map[string]interface{})
  93. inputMessage["infno"] = "1101" // 交易编码
  94. if certificates == "3" {
  95. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  96. inputData["certno"] = certNo // 证件号码
  97. inputData["psn_cert_type"] = "06" // 人员证件类型
  98. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  99. } else {
  100. if id_card_type == 1 {
  101. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  102. inputData["card_sn"] = card_sn // 卡识别码
  103. inputData["certno"] = certNo // 证件号码
  104. inputData["psn_cert_type"] = "" // 人员证件类型
  105. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  106. } else {
  107. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  108. inputData["card_sn"] = "" // 卡识别码
  109. inputData["certno"] = certNo // 证件号码
  110. inputData["psn_cert_type"] = "" // 人员证件类型
  111. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  112. }
  113. }
  114. inputData["begntime"] = "" // 开始时间
  115. inputData["psn_name"] = "" // 人员姓名
  116. input["data"] = inputData
  117. inputMessage["input"] = input //交易输入
  118. var inputLog string
  119. bytesData, err := json.Marshal(inputMessage)
  120. inputLog = string(bytesData)
  121. fmt.Println(string(bytesData))
  122. if err != nil {
  123. fmt.Println(err.Error())
  124. return err.Error(), ""
  125. }
  126. reader := bytes.NewReader(bytesData)
  127. gdyb_url := beego.AppConfig.String("gdyb_url")
  128. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  129. var url string
  130. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  131. url = gdyb_url
  132. } else {
  133. url = gdyb_url + "1101"
  134. }
  135. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  136. request, err := http.NewRequest("POST", url, reader)
  137. if err != nil {
  138. fmt.Println(err.Error())
  139. return err.Error(), ""
  140. }
  141. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  142. request.Header.Set("x-tif-paasid", gdyb_paasid)
  143. request.Header.Set("x-tif-signature", signature)
  144. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  145. request.Header.Set("x-tif-nonce", nonce)
  146. client := http.Client{}
  147. resp, err := client.Do(request)
  148. if err != nil {
  149. fmt.Println(err.Error())
  150. return err.Error(), ""
  151. }
  152. respBytes, err := ioutil.ReadAll(resp.Body)
  153. if err != nil {
  154. fmt.Println(err.Error())
  155. return err.Error(), ""
  156. }
  157. fmt.Println(string(respBytes))
  158. str := string(respBytes)
  159. return str, inputLog
  160. }
  161. func Gdyb1101A(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, name string) string {
  162. //生成签名
  163. nonce := GetRandomString(32)
  164. timestamp := time.Now().Unix()
  165. signature := setSignature(timestamp, nonce, secret_key)
  166. //生成输入报文
  167. inputMessage := SetInputMessagenosign(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  168. input := make(map[string]interface{})
  169. inputData := make(map[string]interface{})
  170. inputMessage["infno"] = "1101" // 交易编码
  171. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  172. inputData["card_sn"] = "" // 卡识别码
  173. inputData["certno"] = certNo // 证件号码
  174. inputData["psn_cert_type"] = "01" // 人员证件类型
  175. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  176. inputData["begntime"] = "" // 开始时间
  177. inputData["psn_name"] = name // 人员姓名
  178. input["data"] = inputData
  179. inputMessage["input"] = input //交易输入
  180. bytesData, err := json.Marshal(inputMessage)
  181. fmt.Println(string(bytesData))
  182. if err != nil {
  183. fmt.Println(err.Error())
  184. return err.Error()
  185. }
  186. reader := bytes.NewReader(bytesData)
  187. gdyb_url := beego.AppConfig.String("gdyb_url")
  188. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  189. var url string
  190. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  191. url = gdyb_url
  192. } else {
  193. url = gdyb_url + "1101"
  194. }
  195. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  196. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  197. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  198. {
  199. request, err := http.NewRequest("POST", url, reader)
  200. if err != nil {
  201. fmt.Println(err.Error())
  202. return err.Error()
  203. }
  204. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  205. request.Header.Set("x-tif-paasid", gdyb_paasid)
  206. request.Header.Set("x-tif-signature", signature)
  207. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  208. request.Header.Set("x-tif-nonce", nonce)
  209. client := http.Client{}
  210. resp, err := client.Do(request)
  211. if err != nil {
  212. fmt.Println(err.Error())
  213. return err.Error()
  214. }
  215. respBytes, err := ioutil.ReadAll(resp.Body)
  216. if err != nil {
  217. fmt.Println(err.Error())
  218. return err.Error()
  219. }
  220. fmt.Println(string(respBytes))
  221. str := string(respBytes)
  222. return str
  223. }
  224. }
  225. // 门诊挂号
  226. 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) {
  227. fmt.Println(opera)
  228. // 生成签名
  229. nonce := GetRandomString(32)
  230. timestamp := time.Now().Unix()
  231. signature := setSignature(timestamp, nonce, secret_key)
  232. tempTime := time.Unix(timestamp, 0)
  233. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  234. // 生成输入报文
  235. inputMessage := SetInputMessagenosign(nonce, timestamp, org_name, opera, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  236. input := make(map[string]interface{})
  237. inputData := make(map[string]interface{})
  238. inputMessage["infno"] = "2201" // 交易编码
  239. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  240. inputData["insutype"] = insutype // 险种类型(来自1101接口返回)
  241. inputData["begntime"] = timeFormatOne // 开始时间
  242. if id_card_type == 1 {
  243. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  244. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  245. } else {
  246. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  247. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  248. }
  249. inputData["ipt_otp_no"] = ipt_otp_no // 住院/门诊号
  250. inputData["atddr_no"] = doctor_id // 医师编码
  251. inputData["dr_name"] = doctor_name // 医师姓名
  252. inputData["dept_code"] = dept_code // 科室编码
  253. inputData["dept_name"] = dept // 科室名称
  254. inputData["caty"] = "A03.06" // 科别
  255. input["data"] = inputData
  256. inputMessage["input"] = input //交易输入
  257. var requestLog string
  258. bytesData, err := json.Marshal(inputMessage)
  259. requestLog = string(bytesData)
  260. fmt.Println(string(bytesData))
  261. if err != nil {
  262. fmt.Println(err.Error())
  263. return err.Error(), ""
  264. }
  265. reader := bytes.NewReader(bytesData)
  266. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2201"
  267. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2201"
  268. gdyb_url := beego.AppConfig.String("gdyb_url")
  269. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  270. var url string
  271. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  272. url = gdyb_url
  273. } else {
  274. url = gdyb_url + "2201"
  275. }
  276. {
  277. request, err := http.NewRequest("POST", url, reader)
  278. if err != nil {
  279. fmt.Println(err.Error())
  280. return err.Error(), ""
  281. }
  282. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  283. request.Header.Set("x-tif-paasid", gdyb_paasid)
  284. request.Header.Set("x-tif-signature", signature)
  285. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  286. request.Header.Set("x-tif-nonce", nonce)
  287. client := http.Client{}
  288. resp, err := client.Do(request)
  289. if err != nil {
  290. fmt.Println(err.Error())
  291. return err.Error(), ""
  292. }
  293. respBytes, err := ioutil.ReadAll(resp.Body)
  294. if err != nil {
  295. fmt.Println(err.Error())
  296. return err.Error(), ""
  297. }
  298. str := string(respBytes)
  299. fmt.Println(str)
  300. return str, requestLog
  301. }
  302. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2201"
  303. }
  304. 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, admin_user_id int64) (string, string) {
  305. fmt.Println(opera)
  306. // 生成签名
  307. nonce := GetRandomString(32)
  308. timestamp := time.Now().Unix()
  309. signature := setSignature(timestamp, nonce, secret_key)
  310. //tempTime := time.Unix(timestamp, 0)
  311. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  312. inputMessage := make(map[string]interface{})
  313. //tempTime := time.Unix(timestamp, 0)
  314. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  315. // 生成输入报文
  316. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  317. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, opera)
  318. } else {
  319. inputMessage = SetInputMessage(nonce, timestamp, org_name, opera, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  320. }
  321. // 生成输入报文
  322. //inputMessage := SetInputMessagenosign(nonce, timestamp, org_name, opera, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  323. input := make(map[string]interface{})
  324. inputData := make(map[string]interface{})
  325. inputMessage["infno"] = "2201" // 交易编码
  326. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  327. inputData["insutype"] = insutype // 险种类型(来自1101接口返回)
  328. inputData["begntime"] = record_time // 开始时间
  329. if id_card_type == 1 {
  330. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  331. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  332. } else if id_card_type == 4 {
  333. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  334. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  335. } else {
  336. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  337. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  338. }
  339. inputData["ipt_otp_no"] = ipt_otp_no // 住院/门诊号
  340. inputData["atddr_no"] = doctor_id // 医师编码
  341. inputData["dr_name"] = doctor_name // 医师姓名
  342. inputData["dept_code"] = dept_code // 科室编码
  343. inputData["dept_name"] = dept // 科室名称
  344. inputData["caty"] = "A03.06" // 科别
  345. input["data"] = inputData
  346. inputMessage["input"] = input //交易输入
  347. var requestLog string
  348. bytesData, err := json.Marshal(inputMessage)
  349. requestLog = string(bytesData)
  350. fmt.Println(string(bytesData))
  351. if err != nil {
  352. fmt.Println(err.Error())
  353. return err.Error(), ""
  354. }
  355. reader := bytes.NewReader(bytesData)
  356. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2201"
  357. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2201"
  358. gdyb_url := beego.AppConfig.String("gdyb_url")
  359. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  360. var url string
  361. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  362. url = gdyb_url
  363. } else {
  364. url = gdyb_url + "2201"
  365. }
  366. {
  367. fmt.Println(url)
  368. fmt.Println(gdyb_paasid)
  369. fmt.Println(secret_key)
  370. request, err := http.NewRequest("POST", url, reader)
  371. if err != nil {
  372. fmt.Println(err.Error())
  373. return err.Error(), ""
  374. }
  375. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  376. request.Header.Set("x-tif-paasid", gdyb_paasid)
  377. request.Header.Set("x-tif-signature", signature)
  378. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  379. request.Header.Set("x-tif-nonce", nonce)
  380. client := http.Client{}
  381. resp, err := client.Do(request)
  382. if err != nil {
  383. fmt.Println(err.Error())
  384. return err.Error(), ""
  385. }
  386. respBytes, err := ioutil.ReadAll(resp.Body)
  387. if err != nil {
  388. fmt.Println(err.Error())
  389. return err.Error(), ""
  390. }
  391. str := string(respBytes)
  392. fmt.Println(str)
  393. return str, requestLog
  394. }
  395. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2201"
  396. }
  397. // 门诊挂号撤销
  398. 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, admin_user_id int64) (string, string) {
  399. // 生成签名
  400. nonce := GetRandomString(32)
  401. timestamp := time.Now().Unix()
  402. signature := setSignature(timestamp, nonce, secret_key)
  403. // 生成输入报文
  404. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  405. inputMessage := make(map[string]interface{})
  406. //tempTime := time.Unix(timestamp, 0)
  407. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  408. // 生成输入报文
  409. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  410. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  411. } else {
  412. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  413. }
  414. input := make(map[string]interface{})
  415. inputData := make(map[string]interface{})
  416. inputMessage["infno"] = "2202" // 交易编码
  417. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  418. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  419. inputData["ipt_otp_no"] = ipt_otp_no // 住院/门诊号
  420. input["data"] = inputData
  421. inputMessage["input"] = input //交易输入
  422. var requestLog string
  423. bytesData, err := json.Marshal(inputMessage)
  424. fmt.Println(string(bytesData))
  425. requestLog = string(bytesData)
  426. if err != nil {
  427. fmt.Println(err.Error())
  428. return err.Error(), ""
  429. }
  430. reader := bytes.NewReader(bytesData)
  431. gdyb_url := beego.AppConfig.String("gdyb_url")
  432. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  433. var url string
  434. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  435. url = gdyb_url
  436. } else {
  437. url = gdyb_url + "2202"
  438. }
  439. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2202"
  440. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2202"
  441. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2202"
  442. {
  443. request, err := http.NewRequest("POST", url, reader)
  444. if err != nil {
  445. fmt.Println(err.Error())
  446. return err.Error(), ""
  447. }
  448. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  449. request.Header.Set("x-tif-paasid", gdyb_paasid)
  450. request.Header.Set("x-tif-signature", signature)
  451. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  452. request.Header.Set("x-tif-nonce", nonce)
  453. client := http.Client{}
  454. resp, err := client.Do(request)
  455. if err != nil {
  456. fmt.Println(err.Error())
  457. return err.Error(), ""
  458. }
  459. respBytes, err := ioutil.ReadAll(resp.Body)
  460. if err != nil {
  461. fmt.Println(err.Error())
  462. return err.Error(), ""
  463. }
  464. str := string(respBytes)
  465. fmt.Println(str)
  466. return str, requestLog
  467. }
  468. }
  469. // 门诊就诊信息上传
  470. 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, doctor_name string, op_id int64, op_name string) (string, string) {
  471. // 生成签名
  472. nonce := GetRandomString(32)
  473. timestamp := time.Now().Unix()
  474. signature := setSignature(timestamp, nonce, secret_key)
  475. inputMessage := make(map[string]interface{})
  476. //tempTime := time.Unix(timestamp, 0)
  477. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  478. // 生成输入报文
  479. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  480. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, op_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, op_name)
  481. } else {
  482. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  483. }
  484. //inputMessage := SetInputMessage1111(nonce, timestamp, org_name, op_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs,op_name)
  485. input := make(map[string]interface{})
  486. inputData := make(map[string]interface{})
  487. diseinfo := make([]map[string]interface{}, 0)
  488. if med_type == "1111" || med_type == "1112" {
  489. med_type = "11"
  490. }
  491. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  492. inputMessage["infno"] = "2203" // 交易编码
  493. } else {
  494. inputMessage["infno"] = "2203" // 交易编码
  495. }
  496. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  497. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  498. inputData["med_type"] = med_type // 医疗类别 16门诊特殊病
  499. inputData["begntime"] = begin_time // 开始时间
  500. //inputData["begntime"] = // 开始时间
  501. inputData["main_cond_dscr"] = "" // 主要病情描述
  502. inputData["dise_codg"] = sick_code // 病种编码
  503. inputData["dise_name"] = sick_name // 病种名称
  504. if med_type == "12" {
  505. inputData["dise_codg"] = "" // 病种编码
  506. inputData["dise_name"] = "" // 病种名称
  507. }
  508. inputData["birctrl_type"] = "" // 计划生育手术类别
  509. inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
  510. for index, item := range config {
  511. diseinfo_sun := make(map[string]interface{})
  512. diseinfo_sun["diag_type"] = "1" // 诊断类别
  513. diseinfo_sun["diag_srt_no"] = index + 1 // 诊断排序号
  514. diseinfo_sun["diag_code"] = item.CountryCode // 诊断代码
  515. diseinfo_sun["diag_name"] = item.ClassName // 诊断名称
  516. diseinfo_sun["diag_dept"] = department // 诊断科室
  517. diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
  518. diseinfo_sun["dise_dor_name"] = doctor_name // 诊断医生姓名
  519. diseinfo_sun["diag_time"] = begin_time // 诊断时间
  520. diseinfo_sun["vali_flag"] = "1" // 有效标志
  521. diseinfo = append(diseinfo, diseinfo_sun)
  522. }
  523. input["diseinfo"] = diseinfo
  524. input["mdtrtinfo"] = inputData
  525. inputMessage["input"] = input //交易输入
  526. var requestLog string
  527. bytesData, err := json.Marshal(inputMessage)
  528. fmt.Println(string(bytesData))
  529. requestLog = string(bytesData)
  530. if err != nil {
  531. fmt.Println(err.Error())
  532. return err.Error(), ""
  533. }
  534. reader := bytes.NewReader(bytesData)
  535. gdyb_url := beego.AppConfig.String("gdyb_url")
  536. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  537. var url string
  538. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  539. url = gdyb_url
  540. } else {
  541. url = gdyb_url + "2203"
  542. }
  543. {
  544. request, err := http.NewRequest("POST", url, reader)
  545. if err != nil {
  546. fmt.Println(err.Error())
  547. return err.Error(), ""
  548. }
  549. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  550. request.Header.Set("x-tif-paasid", gdyb_paasid)
  551. request.Header.Set("x-tif-signature", signature)
  552. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  553. request.Header.Set("x-tif-nonce", nonce)
  554. client := http.Client{}
  555. resp, err := client.Do(request)
  556. if err != nil {
  557. fmt.Println(err.Error())
  558. return err.Error(), ""
  559. }
  560. respBytes, err := ioutil.ReadAll(resp.Body)
  561. if err != nil {
  562. fmt.Println(err.Error())
  563. return err.Error(), ""
  564. }
  565. str := string(respBytes)
  566. fmt.Println(str)
  567. return str, requestLog
  568. }
  569. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2203"
  570. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  571. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  572. }
  573. func Gdyb2203c(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, doctor_name string) (string, string) {
  574. // 生成签名
  575. nonce := GetRandomString(32)
  576. timestamp := time.Now().Unix()
  577. signature := setSignature(timestamp, nonce, secret_key)
  578. //tempTime := time.Unix(timestamp, 0)
  579. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  580. // 生成输入报文
  581. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  582. input := make(map[string]interface{})
  583. inputData := make(map[string]interface{})
  584. diseinfo := make([]map[string]interface{}, 0)
  585. if med_type == "1111" || med_type == "1112" {
  586. med_type = "11"
  587. }
  588. inputMessage["infno"] = "2203" // 交易编码
  589. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  590. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  591. inputData["med_type"] = med_type // 医疗类别 16门诊特殊病
  592. inputData["begntime"] = begin_time // 开始时间
  593. //inputData["begntime"] = // 开始时间
  594. inputData["main_cond_dscr"] = "" // 主要病情描述
  595. inputData["dise_codg"] = sick_code // 病种编码
  596. inputData["dise_name"] = sick_name // 病种名称
  597. if med_type == "12" {
  598. inputData["dise_codg"] = "" // 病种编码
  599. inputData["dise_name"] = "" // 病种名称
  600. }
  601. inputData["birctrl_type"] = "" // 计划生育手术类别
  602. inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
  603. for index, item := range config {
  604. diseinfo_sun := make(map[string]interface{})
  605. diseinfo_sun["diag_type"] = "1" // 诊断类别
  606. diseinfo_sun["diag_srt_no"] = index // 诊断排序号
  607. diseinfo_sun["diag_code"] = item.CountryCode // 诊断代码
  608. diseinfo_sun["diag_name"] = item.ClassName // 诊断名称
  609. diseinfo_sun["diag_dept"] = department // 诊断科室
  610. diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
  611. diseinfo_sun["dise_dor_name"] = doctor_name // 诊断医生姓名
  612. diseinfo_sun["diag_time"] = begin_time // 诊断时间
  613. diseinfo_sun["vali_flag"] = "1" // 有效标志
  614. diseinfo = append(diseinfo, diseinfo_sun)
  615. }
  616. input["diseinfo"] = diseinfo
  617. input["mdtrtinfo"] = inputData
  618. inputMessage["input"] = input //交易输入
  619. var requestLog string
  620. bytesData, err := json.Marshal(inputMessage)
  621. fmt.Println(string(bytesData))
  622. requestLog = string(bytesData)
  623. if err != nil {
  624. fmt.Println(err.Error())
  625. return err.Error(), ""
  626. }
  627. reader := bytes.NewReader(bytesData)
  628. gdyb_url := beego.AppConfig.String("gdyb_url")
  629. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  630. var url string
  631. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  632. url = gdyb_url
  633. } else {
  634. url = gdyb_url + "2203"
  635. }
  636. {
  637. request, err := http.NewRequest("POST", url, reader)
  638. if err != nil {
  639. fmt.Println(err.Error())
  640. return err.Error(), ""
  641. }
  642. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  643. request.Header.Set("x-tif-paasid", gdyb_paasid)
  644. request.Header.Set("x-tif-signature", signature)
  645. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  646. request.Header.Set("x-tif-nonce", nonce)
  647. client := http.Client{}
  648. resp, err := client.Do(request)
  649. if err != nil {
  650. fmt.Println(err.Error())
  651. return err.Error(), ""
  652. }
  653. respBytes, err := ioutil.ReadAll(resp.Body)
  654. if err != nil {
  655. fmt.Println(err.Error())
  656. return err.Error(), ""
  657. }
  658. str := string(respBytes)
  659. fmt.Println(str)
  660. return str, requestLog
  661. }
  662. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2203"
  663. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  664. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  665. }
  666. // 门诊就诊信息上传
  667. 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) {
  668. // 生成签名
  669. nonce := GetRandomString(32)
  670. timestamp := time.Now().Unix()
  671. signature := setSignature(timestamp, nonce, secret_key)
  672. tempTime := time.Unix(timestamp, 0)
  673. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  674. // 生成输入报文
  675. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  676. input := make(map[string]interface{})
  677. inputData := make(map[string]interface{})
  678. diseinfo := make([]map[string]interface{}, 0)
  679. if med_type == "1111" || med_type == "1112" {
  680. med_type = "11"
  681. }
  682. inputMessage["infno"] = "2203A" // 交易编码
  683. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  684. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  685. inputData["med_type"] = med_type // 医疗类别 16门诊特殊病
  686. inputData["begntime"] = begin_time // 开始时间
  687. inputData["main_cond_dscr"] = "" // 主要病情描述
  688. inputData["dise_codg"] = sick_code // 病种编码
  689. inputData["dise_name"] = sick_name // 病种名称
  690. inputData["birctrl_type"] = "" // 计划生育手术类别
  691. inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
  692. inputData["matn_type"] = "" // 生育类别
  693. inputData["geso_val"] = "" // 孕周数
  694. for index, item := range config {
  695. diseinfo_sun := make(map[string]interface{})
  696. diseinfo_sun["diag_type"] = "1" // 诊断类别
  697. diseinfo_sun["diag_srt_no"] = index // 诊断排序号
  698. diseinfo_sun["diag_code"] = item.CountryCode // 诊断代码
  699. diseinfo_sun["diag_name"] = item.ClassName // 诊断名称
  700. diseinfo_sun["diag_dept"] = department // 诊断科室
  701. diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
  702. diseinfo_sun["dise_dor_name"] = doctor // 诊断医生姓名
  703. diseinfo_sun["diag_time"] = timeFormatOne // 诊断时间
  704. diseinfo_sun["vali_flag"] = "1" // 有效标志
  705. diseinfo = append(diseinfo, diseinfo_sun)
  706. }
  707. input["diseinfo"] = diseinfo
  708. input["mdtrtinfo"] = inputData
  709. inputMessage["input"] = input //交易输入
  710. var requestLog string
  711. bytesData, err := json.Marshal(inputMessage)
  712. fmt.Println(string(bytesData))
  713. requestLog = string(bytesData)
  714. if err != nil {
  715. fmt.Println(err.Error())
  716. return err.Error(), ""
  717. }
  718. reader := bytes.NewReader(bytesData)
  719. gdyb_url := beego.AppConfig.String("gdyb_url")
  720. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  721. var url string
  722. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  723. url = gdyb_url
  724. } else {
  725. url = gdyb_url + "2203"
  726. }
  727. {
  728. request, err := http.NewRequest("POST", url, reader)
  729. if err != nil {
  730. fmt.Println(err.Error())
  731. return err.Error(), ""
  732. }
  733. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  734. request.Header.Set("x-tif-paasid", gdyb_paasid)
  735. request.Header.Set("x-tif-signature", signature)
  736. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  737. request.Header.Set("x-tif-nonce", nonce)
  738. client := http.Client{}
  739. resp, err := client.Do(request)
  740. if err != nil {
  741. fmt.Println(err.Error())
  742. return err.Error(), ""
  743. }
  744. respBytes, err := ioutil.ReadAll(resp.Body)
  745. if err != nil {
  746. fmt.Println(err.Error())
  747. return err.Error(), ""
  748. }
  749. str := string(respBytes)
  750. fmt.Println(str)
  751. return str, requestLog
  752. }
  753. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2203A"
  754. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  755. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  756. }
  757. func Gdyb2203d(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) {
  758. // 生成签名
  759. nonce := GetRandomString(32)
  760. timestamp := time.Now().Unix()
  761. signature := setSignature(timestamp, nonce, secret_key)
  762. tempTime := time.Unix(timestamp, 0)
  763. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  764. // 生成输入报文
  765. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  766. input := make(map[string]interface{})
  767. inputData := make(map[string]interface{})
  768. diseinfo := make([]map[string]interface{}, 0)
  769. inputMessage["infno"] = "2203" // 交易编码
  770. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  771. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  772. inputData["med_type"] = "14" // 医疗类别 16门诊特殊病
  773. inputData["begntime"] = begin_time // 开始时间
  774. inputData["main_cond_dscr"] = "" // 主要病情描述
  775. inputData["dise_codg"] = sick_code // 病种编码
  776. inputData["dise_name"] = sick_name // 病种名称
  777. inputData["birctrl_type"] = "" // 计划生育手术类别
  778. inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
  779. inputData["matn_type"] = "" // 生育类别
  780. inputData["geso_val"] = "" // 孕周数
  781. for index, item := range config {
  782. diseinfo_sun := make(map[string]interface{})
  783. diseinfo_sun["diag_type"] = "1" // 诊断类别
  784. diseinfo_sun["diag_srt_no"] = index // 诊断排序号
  785. diseinfo_sun["diag_code"] = item.CountryCode // 诊断代码
  786. diseinfo_sun["diag_name"] = item.ClassName // 诊断名称
  787. diseinfo_sun["diag_dept"] = department // 诊断科室
  788. diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
  789. diseinfo_sun["dise_dor_name"] = doctor // 诊断医生姓名
  790. diseinfo_sun["diag_time"] = timeFormatOne // 诊断时间
  791. diseinfo_sun["vali_flag"] = "1" // 有效标志
  792. diseinfo = append(diseinfo, diseinfo_sun)
  793. }
  794. input["diseinfo"] = diseinfo
  795. input["mdtrtinfo"] = inputData
  796. inputMessage["input"] = input //交易输入
  797. var requestLog string
  798. bytesData, err := json.Marshal(inputMessage)
  799. fmt.Println(string(bytesData))
  800. requestLog = string(bytesData)
  801. if err != nil {
  802. fmt.Println(err.Error())
  803. return err.Error(), ""
  804. }
  805. reader := bytes.NewReader(bytesData)
  806. gdyb_url := beego.AppConfig.String("gdyb_url")
  807. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  808. var url string
  809. url = gdyb_url + "2203"
  810. {
  811. request, err := http.NewRequest("POST", url, reader)
  812. if err != nil {
  813. fmt.Println(err.Error())
  814. return err.Error(), ""
  815. }
  816. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  817. request.Header.Set("x-tif-paasid", gdyb_paasid)
  818. request.Header.Set("x-tif-signature", signature)
  819. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  820. request.Header.Set("x-tif-nonce", nonce)
  821. client := http.Client{}
  822. resp, err := client.Do(request)
  823. if err != nil {
  824. fmt.Println(err.Error())
  825. return err.Error(), ""
  826. }
  827. respBytes, err := ioutil.ReadAll(resp.Body)
  828. if err != nil {
  829. fmt.Println(err.Error())
  830. return err.Error(), ""
  831. }
  832. str := string(respBytes)
  833. fmt.Println(str)
  834. return str, requestLog
  835. }
  836. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2203A"
  837. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  838. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  839. }
  840. type Custom struct {
  841. DetItemFeeSumamt string
  842. Cut string
  843. FeedetlSn string
  844. Price string
  845. MedListCodg string
  846. LmtUsedFlag int64
  847. HospApprFlag int64
  848. DoctorNumber string
  849. DoctorName string
  850. ProvinceDrugMedListCodg string
  851. ProvinceGoodMedListCodg string
  852. IsUser int64
  853. FeeOcurTime string
  854. Unit string
  855. }
  856. type RequestResult struct {
  857. Output Output `json:"output" form:"output"`
  858. Infcode int64 `gorm:"column:infcode" json:"infcode" form:"infcode"`
  859. WarnMsg string `gorm:"column:warn_msg" json:"warn_msg" form:"warn_msg"`
  860. Cainfo string `gorm:"column:cainfo" json:"cainfo" form:"cainfo"`
  861. ErrMsg string `gorm:"column:err_msg" json:"err_msg" form:"err_msg"`
  862. RespondTime string `gorm:"column:respond_time" json:"respond_time" form:"respond_time"`
  863. InfRefmsgid string `gorm:"column:inf_refmsgid" json:"inf_refmsgid" form:"inf_refmsgid"`
  864. }
  865. type Output struct {
  866. Result Result `json:"result" form:"result"`
  867. }
  868. type Result struct {
  869. BasMednFlag string `json:"bas_medn_flag" form:"bas_medn_flag"`
  870. MedChrgitmType string `json:"med_chrgitm_type" form:"med_chrgitm_type"`
  871. DetItemFeeSumamt int64 `json:"det_item_fee_sumamt" form:"det_item_fee_sumamt"`
  872. HiNegoDrugFlag string `json:"hi_nego_drug_flag" form:"hi_nego_drug_flag"`
  873. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
  874. FeedtlSn int64 `json:"feedtl_sn" form:"feedtl_sn"`
  875. UploadDate int64 `json:"upload_date" form:"upload_date"`
  876. AdviceId int64 `json:"advice_id" form:"advice_id"`
  877. Cnt int64 `json:"cnt" form:"cnt"`
  878. Pric float64 `json:"pric" form:"pric"`
  879. PatientId int64 `json:"patient_id" form:"patient_id"`
  880. PricUplmtAmt float64 `json:"pric_uplmt_amt" form:"pric_uplmt_amt"`
  881. SelfpayProp float64 `json:"selfpay_prop" form:"selfpay_prop"`
  882. OverlmtAmt float64 `json:"overlmt_amt" form:"overlmt_amt"`
  883. PreselfpayAmt float64 `json:"preselfpay_amt" form:"preselfpay_amt"`
  884. Status int64 `json:"status" form:"status"`
  885. Memo string `json:"memo" form:"memo"`
  886. FeedetlSn string `json:"feedetl_sn" form:"feedetl_sn"`
  887. Mtime int64 `json:"mtime" form:"mtime"`
  888. InscpScpAmt float64 `json:"inscp_scp_amt" form:"inscp_scp_amt"`
  889. DrtReimFlag string `json:"drt_reim_flag" form:"drt_reim_flag"`
  890. Ctime int64 `json:"ctime" form:"ctime"`
  891. ListSpItemFlag string `json:"list_sp_item_flag" form:"list_sp_item_flag"`
  892. ChldMedcFlag string `json:"chld_medc_flag" form:"chld_medc_flag"`
  893. LmtUsedFlag string `json:"lmt_used_flag" form:"lmt_used_flag"`
  894. ChrgitmLv string `json:"chrgitm_lv" form:"chrgitm_lv"`
  895. UserOrgId int64 `json:"user_org_id" form:"user_org_id"`
  896. HisPatientId int64 `json:"his_patient_id" form:"his_patient_id"`
  897. OrderId int64 `json:"order_id" form:"order_id"`
  898. }
  899. // 门诊费用明细信息上传
  900. 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, admin_user_id int64) (string, string) {
  901. // 生成签名
  902. nonce := GetRandomString(32)
  903. timestamp := time.Now().Unix()
  904. signature := setSignature(timestamp, nonce, secret_key)
  905. //tempTime := time.Unix(timestamp, 0)
  906. //timeFormat := tempTime.Format("20060102150405")
  907. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  908. //chrgBchno := rand.Intn(100000) + 10000
  909. var customs []*Custom
  910. inputMessage := make(map[string]interface{})
  911. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  912. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  913. } else {
  914. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  915. }
  916. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  917. for _, item := range hisPrescription {
  918. role, _ := GetAdminUserInfoByID(item.UserOrgId, new_doctor_id)
  919. tm := time.Unix(item.PreTime, 0)
  920. if item.Type == 1 { //药品
  921. for _, subItem := range item.HisDoctorAdviceInfo {
  922. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 && subItem.BaseDrugLib.IsUser != 1 {
  923. //var randNum int
  924. //randNum = rand.Intn(10000) + 1000
  925. role, _ := GetAdminUserInfoByID(item.UserOrgId, new_doctor_id)
  926. cus := &Custom{
  927. DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  928. Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  929. FeedetlSn: subItem.FeedetlSn,
  930. Price: fmt.Sprintf("%.2f", subItem.Price),
  931. MedListCodg: subItem.BaseDrugLib.MedicalInsuranceNumber,
  932. HospApprFlag: subItem.HospApprFlag,
  933. DoctorNumber: role.DoctorNumber,
  934. DoctorName: role.UserName,
  935. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  936. }
  937. customs = append(customs, cus)
  938. }
  939. }
  940. }
  941. if item.Type == 2 { //项目
  942. for _, subItem := range item.HisPrescriptionProject {
  943. //var randNum int
  944. //randNum = rand.Intn(10000) + 1000
  945. if subItem.Type == 2 {
  946. if len(subItem.HisProject.MedicalCode) > 0 {
  947. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  948. cus := &Custom{
  949. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  950. Cut: fmt.Sprintf("%.4f", cnt),
  951. FeedetlSn: subItem.FeedetlSn,
  952. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  953. MedListCodg: subItem.HisProject.MedicalCode,
  954. DoctorNumber: role.DoctorNumber,
  955. DoctorName: role.UserName,
  956. HospApprFlag: -1,
  957. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  958. }
  959. customs = append(customs, cus)
  960. }
  961. } else if subItem.Type == 3 {
  962. if len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  963. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  964. cus := &Custom{
  965. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  966. Cut: fmt.Sprintf("%.4f", cnt),
  967. FeedetlSn: subItem.FeedetlSn,
  968. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  969. MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
  970. HospApprFlag: -1,
  971. DoctorNumber: role.DoctorNumber,
  972. DoctorName: role.UserName,
  973. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  974. }
  975. customs = append(customs, cus)
  976. }
  977. }
  978. }
  979. }
  980. for _, subItem := range item.HisAdditionalCharge {
  981. if len(subItem.XtHisAddtionConfig.Code) > 0 {
  982. cus := &Custom{
  983. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*float64(subItem.Count)),
  984. Cut: fmt.Sprintf("%.4f", float64(subItem.Count)),
  985. FeedetlSn: subItem.FeedetlSn,
  986. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  987. MedListCodg: subItem.XtHisAddtionConfig.Code,
  988. HospApprFlag: -1,
  989. DoctorNumber: role.DoctorNumber,
  990. DoctorName: role.UserName,
  991. }
  992. customs = append(customs, cus)
  993. }
  994. }
  995. }
  996. // 生成输入报文
  997. input := make(map[string]interface{})
  998. feedetail := make([]map[string]interface{}, 0)
  999. inputMessage["infno"] = "2204" // 交易编码
  1000. //chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  1001. for _, item := range customs {
  1002. feedetailInfo := make(map[string]interface{})
  1003. feedetailInfo["feedetl_sn"] = item.FeedetlSn
  1004. feedetailInfo["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1005. feedetailInfo["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1006. feedetailInfo["chrg_bchno"] = chrg_bchno // 收费批次号
  1007. feedetailInfo["dise_codg"] = diag_code // 病种编码
  1008. feedetailInfo["rxno"] = "" // 处方号
  1009. feedetailInfo["rx_circ_flag"] = "0" // 外购处方标志
  1010. feedetailInfo["fee_ocur_time"] = item.FeeOcurTime // 费用发生时间
  1011. feedetailInfo["med_list_codg"] = item.MedListCodg // 医疗目录编码
  1012. feedetailInfo["medins_list_codg"] = item.MedListCodg // 医药机构目录编码
  1013. feedetailInfo["det_item_fee_sumamt"] = item.DetItemFeeSumamt // 明细项目费用总额
  1014. feedetailInfo["cnt"] = item.Cut // 数量
  1015. feedetailInfo["pric"] = item.Price // 单价
  1016. feedetailInfo["sin_dos_dscr"] = "1" // 单次剂量描述
  1017. feedetailInfo["used_frqu_dscr"] = "" // 使用频次描述
  1018. feedetailInfo["prd_days"] = "0" // 周期天数
  1019. feedetailInfo["medc_way_dscr"] = "" // 用药途径描述
  1020. feedetailInfo["bilg_dept_codg"] = dept_code // 开单科室编码
  1021. feedetailInfo["bilg_dept_name"] = dept // 开单科室名称
  1022. feedetailInfo["bilg_dr_codg"] = item.DoctorNumber // 开单医生编码
  1023. feedetailInfo["bilg_dr_name"] = item.DoctorName // 开单医师姓名
  1024. feedetailInfo["acord_dept_codg"] = "" // 受单科室编码
  1025. feedetailInfo["acord_dept_name"] = "" // 受单科室名称
  1026. feedetailInfo["orders_dr_code"] = item.DoctorNumber // 受单医生编码
  1027. feedetailInfo["orders_dr_name"] = item.DoctorName // 受单医生姓名
  1028. if balance_accounts_type == "8" {
  1029. feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
  1030. } else {
  1031. if item.HospApprFlag != -1 {
  1032. if item.HospApprFlag == 1 {
  1033. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  1034. } else if item.HospApprFlag == 2 {
  1035. feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
  1036. } else if item.HospApprFlag == 3 {
  1037. feedetailInfo["hosp_appr_flag"] = "0" // 医院审批标志
  1038. } else {
  1039. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  1040. }
  1041. } else {
  1042. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  1043. }
  1044. }
  1045. //feedetailInfo["tcmdrug_used_way"] = "" // 中药使用方式
  1046. feedetailInfo["etip_flag"] = "0" // 外检标志
  1047. feedetailInfo["etip_hosp_code"] = "" // 外检医院编码
  1048. feedetailInfo["dscg_tkdrug_flag"] = "" // 出院带药标志
  1049. feedetailInfo["matn_fee_flag"] = "" // 生育费用标志
  1050. feedetail = append(feedetail, feedetailInfo)
  1051. }
  1052. input["feedetail"] = feedetail
  1053. inputMessage["input"] = input //交易输入
  1054. var requestLog string
  1055. bytesData, err := json.Marshal(inputMessage)
  1056. fmt.Println("----------")
  1057. fmt.Println(string(bytesData))
  1058. fmt.Println("----------")
  1059. requestLog = string(bytesData)
  1060. if err != nil {
  1061. fmt.Println(err.Error())
  1062. return "", ""
  1063. }
  1064. reader := bytes.NewReader(bytesData)
  1065. gdyb_url := beego.AppConfig.String("gdyb_url")
  1066. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1067. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1068. var url string
  1069. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  1070. url = gdyb_url
  1071. } else {
  1072. url = gdyb_url + "2204"
  1073. }
  1074. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2204"
  1075. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2204"
  1076. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2204"
  1077. {
  1078. request, err := http.NewRequest("POST", url, reader)
  1079. if err != nil {
  1080. fmt.Println(err.Error())
  1081. return "", ""
  1082. }
  1083. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1084. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1085. request.Header.Set("x-tif-signature", signature)
  1086. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1087. request.Header.Set("x-tif-nonce", nonce)
  1088. client := http.Client{}
  1089. resp, err := client.Do(request)
  1090. if err != nil {
  1091. fmt.Println(err.Error())
  1092. return "", ""
  1093. }
  1094. respBytes, err := ioutil.ReadAll(resp.Body)
  1095. if err != nil {
  1096. fmt.Println(err.Error())
  1097. return "", ""
  1098. }
  1099. return string(respBytes), requestLog
  1100. }
  1101. //var result RequestResult
  1102. //json.Unmarshal(respBytes, &result)
  1103. //return &result
  1104. }
  1105. func Gdyb2204For441799(psnNo string, mdtrtId string, hisPrescription []*models.HisPrescription, chrg_bchno string, org_name string, doctor string, dept string, fixmedins_code string, dept_code string, new_doctor_name string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, balance_accounts_type string, new_doctor_id string, diag_code string) (string, string) {
  1106. // 生成签名
  1107. nonce := GetRandomString(32)
  1108. timestamp := time.Now().Unix()
  1109. signature := setSignature(timestamp, nonce, secret_key)
  1110. //tempTime := time.Unix(timestamp, 0)
  1111. //timeFormat := tempTime.Format("20060102150405")
  1112. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  1113. //chrgBchno := rand.Intn(100000) + 10000
  1114. var customs []*Custom
  1115. for _, item := range hisPrescription {
  1116. tm := time.Unix(item.PreTime, 0)
  1117. if item.Type == 1 { //药品
  1118. for _, subItem := range item.HisDoctorAdviceInfo {
  1119. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 && subItem.BaseDrugLib.IsUser != 1 {
  1120. //var randNum int
  1121. //randNum = rand.Intn(10000) + 1000
  1122. cus := &Custom{
  1123. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber),
  1124. Cut: fmt.Sprintf("%.4f", subItem.PrescribingNumber),
  1125. FeedetlSn: subItem.FeedetlSn,
  1126. Price: fmt.Sprintf("%.4f", subItem.Price),
  1127. MedListCodg: subItem.BaseDrugLib.MedicalInsuranceNumber,
  1128. HospApprFlag: subItem.HospApprFlag,
  1129. DoctorNumber: new_doctor_id,
  1130. DoctorName: new_doctor_name,
  1131. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  1132. }
  1133. customs = append(customs, cus)
  1134. }
  1135. }
  1136. }
  1137. if item.Type == 2 { //项目
  1138. for _, subItem := range item.HisPrescriptionProject {
  1139. //var randNum int
  1140. //randNum = rand.Intn(10000) + 1000
  1141. if subItem.Type == 2 {
  1142. if len(subItem.HisProject.MedicalCode) > 0 {
  1143. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1144. cus := &Custom{
  1145. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  1146. Cut: fmt.Sprintf("%.4f", cnt),
  1147. FeedetlSn: subItem.FeedetlSn,
  1148. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  1149. MedListCodg: subItem.HisProject.MedicalCode,
  1150. DoctorNumber: new_doctor_id,
  1151. DoctorName: new_doctor_name,
  1152. HospApprFlag: -1,
  1153. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  1154. }
  1155. customs = append(customs, cus)
  1156. }
  1157. } else if subItem.Type == 3 {
  1158. if len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  1159. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1160. cus := &Custom{
  1161. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  1162. Cut: fmt.Sprintf("%.4f", cnt),
  1163. FeedetlSn: subItem.FeedetlSn,
  1164. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  1165. MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
  1166. HospApprFlag: -1,
  1167. DoctorNumber: new_doctor_id,
  1168. DoctorName: new_doctor_name,
  1169. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  1170. }
  1171. customs = append(customs, cus)
  1172. }
  1173. }
  1174. }
  1175. }
  1176. for _, subItem := range item.HisAdditionalCharge {
  1177. if len(subItem.XtHisAddtionConfig.Code) > 0 {
  1178. cus := &Custom{
  1179. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*float64(subItem.Count)),
  1180. Cut: fmt.Sprintf("%.4f", float64(subItem.Count)),
  1181. FeedetlSn: subItem.FeedetlSn,
  1182. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  1183. MedListCodg: subItem.XtHisAddtionConfig.Code,
  1184. HospApprFlag: -1,
  1185. DoctorNumber: new_doctor_id,
  1186. DoctorName: new_doctor_name,
  1187. }
  1188. customs = append(customs, cus)
  1189. }
  1190. }
  1191. }
  1192. // 生成输入报文
  1193. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1194. input := make(map[string]interface{})
  1195. feedetail := make([]map[string]interface{}, 0)
  1196. inputMessage["infno"] = "2204" // 交易编码
  1197. //chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  1198. for _, item := range customs {
  1199. feedetailInfo := make(map[string]interface{})
  1200. feedetailInfo["feedetl_sn"] = item.FeedetlSn
  1201. feedetailInfo["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1202. feedetailInfo["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1203. feedetailInfo["chrg_bchno"] = chrg_bchno // 收费批次号
  1204. feedetailInfo["dise_codg"] = diag_code // 病种编码
  1205. feedetailInfo["rxno"] = "" // 处方号
  1206. feedetailInfo["rx_circ_flag"] = "0" // 外购处方标志
  1207. feedetailInfo["fee_ocur_time"] = item.FeeOcurTime // 费用发生时间
  1208. feedetailInfo["med_list_codg"] = item.MedListCodg // 医疗目录编码
  1209. feedetailInfo["medins_list_codg"] = fixmedins_code // 医药机构目录编码
  1210. feedetailInfo["det_item_fee_sumamt"] = item.DetItemFeeSumamt // 明细项目费用总额
  1211. feedetailInfo["cnt"] = item.Cut // 数量
  1212. feedetailInfo["pric"] = item.Price // 单价
  1213. feedetailInfo["sin_dos_dscr"] = "" // 单次剂量描述
  1214. feedetailInfo["used_frqu_dscr"] = "" // 使用频次描述
  1215. feedetailInfo["prd_days"] = "0" // 周期天数
  1216. feedetailInfo["medc_way_dscr"] = "" // 用药途径描述
  1217. feedetailInfo["bilg_dept_codg"] = dept_code // 开单科室编码
  1218. feedetailInfo["bilg_dept_name"] = dept // 开单科室名称
  1219. feedetailInfo["bilg_dr_codg"] = item.DoctorNumber // 开单医生编码
  1220. feedetailInfo["bilg_dr_name"] = item.DoctorName // 开单医师姓名
  1221. feedetailInfo["acord_dept_codg"] = "" // 受单科室编码
  1222. feedetailInfo["acord_dept_name"] = "" // 受单科室名称
  1223. feedetailInfo["orders_dr_code"] = item.DoctorNumber // 受单医生编码
  1224. feedetailInfo["orders_dr_name"] = item.DoctorName // 受单医生姓名
  1225. if balance_accounts_type == "8" {
  1226. feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
  1227. } else {
  1228. if item.HospApprFlag != -1 {
  1229. if item.HospApprFlag == 1 {
  1230. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  1231. } else if item.HospApprFlag == 2 {
  1232. feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
  1233. } else if item.HospApprFlag == 3 {
  1234. feedetailInfo["hosp_appr_flag"] = "0" // 医院审批标志
  1235. } else {
  1236. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  1237. }
  1238. } else {
  1239. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  1240. }
  1241. }
  1242. //feedetailInfo["tcmdrug_used_way"] = "" // 中药使用方式
  1243. feedetailInfo["etip_flag"] = "" // 外检标志
  1244. feedetailInfo["etip_hosp_code"] = "" // 外检医院编码
  1245. feedetailInfo["dscg_tkdrug_flag"] = "" // 出院带药标志
  1246. feedetailInfo["matn_fee_flag"] = "" // 生育费用标志
  1247. feedetail = append(feedetail, feedetailInfo)
  1248. }
  1249. input["feedetail"] = feedetail
  1250. inputMessage["input"] = input //交易输入
  1251. var requestLog string
  1252. bytesData, err := json.Marshal(inputMessage)
  1253. fmt.Println("----------")
  1254. fmt.Println(string(bytesData))
  1255. fmt.Println("----------")
  1256. requestLog = string(bytesData)
  1257. if err != nil {
  1258. fmt.Println(err.Error())
  1259. return "", ""
  1260. }
  1261. reader := bytes.NewReader(bytesData)
  1262. gdyb_url := beego.AppConfig.String("gdyb_url")
  1263. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1264. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1265. var url string
  1266. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  1267. url = gdyb_url
  1268. } else {
  1269. url = gdyb_url + "2204"
  1270. }
  1271. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2204"
  1272. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2204"
  1273. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2204"
  1274. {
  1275. request, err := http.NewRequest("POST", url, reader)
  1276. if err != nil {
  1277. fmt.Println(err.Error())
  1278. return "", ""
  1279. }
  1280. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1281. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1282. request.Header.Set("x-tif-signature", signature)
  1283. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1284. request.Header.Set("x-tif-nonce", nonce)
  1285. client := http.Client{}
  1286. resp, err := client.Do(request)
  1287. if err != nil {
  1288. fmt.Println(err.Error())
  1289. return "", ""
  1290. }
  1291. respBytes, err := ioutil.ReadAll(resp.Body)
  1292. if err != nil {
  1293. fmt.Println(err.Error())
  1294. return "", ""
  1295. }
  1296. return string(respBytes), requestLog
  1297. }
  1298. //var result RequestResult
  1299. //json.Unmarshal(respBytes, &result)
  1300. //return &result
  1301. }
  1302. // 门诊费用明细信息撤销
  1303. 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, admin_user_id int64) (string, string) {
  1304. // 生成签名
  1305. nonce := GetRandomString(32)
  1306. timestamp := time.Now().Unix()
  1307. signature := setSignature(timestamp, nonce, secret_key)
  1308. inputMessage := make(map[string]interface{})
  1309. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  1310. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  1311. } else {
  1312. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1313. }
  1314. // 生成输入报文
  1315. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1316. input := make(map[string]interface{})
  1317. inputData := make(map[string]interface{})
  1318. inputMessage["infno"] = "2205" // 交易编码
  1319. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1320. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  1321. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1322. input["data"] = inputData
  1323. inputMessage["input"] = input //交易输入
  1324. bytesData, err := json.Marshal(inputMessage)
  1325. fmt.Println(string(bytesData))
  1326. var requestLog string
  1327. requestLog = string(bytesData)
  1328. if err != nil {
  1329. fmt.Println(err.Error())
  1330. return err.Error(), ""
  1331. }
  1332. reader := bytes.NewReader(bytesData)
  1333. gdyb_url := beego.AppConfig.String("gdyb_url")
  1334. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1335. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1336. //url := gdyb_url + "2205"
  1337. var url string
  1338. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  1339. url = gdyb_url
  1340. } else {
  1341. url = gdyb_url + "2205"
  1342. }
  1343. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2205"
  1344. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2205"
  1345. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2205"
  1346. {
  1347. request, err := http.NewRequest("POST", url, reader)
  1348. fmt.Println(err)
  1349. fmt.Println(request)
  1350. if err != nil {
  1351. fmt.Println(err.Error())
  1352. return err.Error(), ""
  1353. }
  1354. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1355. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1356. request.Header.Set("x-tif-signature", signature)
  1357. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1358. request.Header.Set("x-tif-nonce", nonce)
  1359. client := http.Client{}
  1360. resp, err := client.Do(request)
  1361. if err != nil {
  1362. fmt.Println(err.Error())
  1363. return err.Error(), ""
  1364. }
  1365. respBytes, err := ioutil.ReadAll(resp.Body)
  1366. if err != nil {
  1367. fmt.Println(err.Error())
  1368. return err.Error(), ""
  1369. }
  1370. str := string(respBytes)
  1371. fmt.Println(str)
  1372. return str, requestLog
  1373. }
  1374. }
  1375. // 门诊预结算
  1376. //
  1377. // func Gdyb2206(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string, total string, org_name string, doctor string, secret_key string) string {
  1378. 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, admin_user_id int64) (string, string) {
  1379. // 生成签名
  1380. nonce := GetRandomString(32)
  1381. timestamp := time.Now().Unix()
  1382. signature := setSignature(timestamp, nonce, secret_key)
  1383. inputMessage := make(map[string]interface{})
  1384. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  1385. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  1386. } else {
  1387. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1388. }
  1389. // 生成输入报文
  1390. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1391. input := make(map[string]interface{})
  1392. inputData := make(map[string]interface{})
  1393. inputMessage["infno"] = "2206" // 交易编码
  1394. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1395. if certificates == 3 {
  1396. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  1397. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1398. } else {
  1399. if id_card_type == 1 {
  1400. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  1401. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1402. } else if id_card_type == 4 {
  1403. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  1404. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1405. } else {
  1406. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  1407. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1408. }
  1409. }
  1410. {
  1411. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  1412. }
  1413. inputData["medfee_sumamt"] = total // 医疗费总额
  1414. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  1415. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1416. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  1417. inputData["acct_used_flag"] = "0" // 个人账户使用标志 0否 1是
  1418. inputData["insutype"] = insutype // 险种类型
  1419. inputData["invono"] = "" // 发票号
  1420. input["data"] = inputData
  1421. inputMessage["input"] = input //交易输入
  1422. var requestLog string
  1423. bytesData, err := json.Marshal(inputMessage)
  1424. requestLog = string(bytesData)
  1425. fmt.Println(string(bytesData))
  1426. if err != nil {
  1427. fmt.Println(err.Error())
  1428. return err.Error(), ""
  1429. }
  1430. reader := bytes.NewReader(bytesData)
  1431. gdyb_url := beego.AppConfig.String("gdyb_url")
  1432. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1433. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1434. //url := gdyb_url + "2206"
  1435. var url string
  1436. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  1437. url = gdyb_url
  1438. } else {
  1439. url = gdyb_url + "2206"
  1440. }
  1441. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2206"
  1442. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2206"
  1443. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2206"
  1444. {
  1445. request, err := http.NewRequest("POST", url, reader)
  1446. if err != nil {
  1447. fmt.Println(err.Error())
  1448. return err.Error(), ""
  1449. }
  1450. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1451. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1452. request.Header.Set("x-tif-signature", signature)
  1453. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1454. request.Header.Set("x-tif-nonce", nonce)
  1455. client := http.Client{}
  1456. resp, err := client.Do(request)
  1457. if err != nil {
  1458. fmt.Println(err.Error())
  1459. return err.Error(), ""
  1460. }
  1461. respBytes, err := ioutil.ReadAll(resp.Body)
  1462. if err != nil {
  1463. fmt.Println(err.Error())
  1464. return err.Error(), ""
  1465. }
  1466. str := string(respBytes)
  1467. fmt.Println(str)
  1468. return str, requestLog
  1469. }
  1470. }
  1471. // 门诊结算
  1472. 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, admin_user_id int64) (string, string) {
  1473. // 生成签名
  1474. nonce := GetRandomString(32)
  1475. timestamp := time.Now().Unix()
  1476. signature := setSignature(timestamp, nonce, secret_key)
  1477. // 生成输入报文
  1478. inputMessage := make(map[string]interface{})
  1479. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  1480. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  1481. } else {
  1482. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1483. }
  1484. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1485. input := make(map[string]interface{})
  1486. inputData := make(map[string]interface{})
  1487. inputMessage["infno"] = "2207" // 交易编码
  1488. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1489. if certificates == 3 {
  1490. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  1491. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1492. } else {
  1493. if id_card_type == 1 {
  1494. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  1495. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1496. } else if id_card_type == 4 {
  1497. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  1498. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  1499. } else {
  1500. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  1501. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1502. }
  1503. }
  1504. if med_type == "1111" || med_type == "1112" {
  1505. med_type = "11"
  1506. }
  1507. {
  1508. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  1509. }
  1510. inputData["medfee_sumamt"] = total // 医疗费总额
  1511. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  1512. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1513. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  1514. inputData["acct_used_flag"] = acct_used_flag // 个人账户使用标志 0否 1是
  1515. inputData["insutype"] = insutype // 险种类型
  1516. inputData["invono"] = "" // 发票号
  1517. inputData["fulamt_ownpay_amt"] = fulamt_ownpay_amt //
  1518. inputData["overlmt_selfpay"] = overlmt_selfpay //
  1519. inputData["preselfpay_amt"] = preselfpay_amt //
  1520. inputData["inscp_scp_amt"] = inscp_scp_amt //
  1521. input["data"] = inputData
  1522. inputMessage["input"] = input //交易输入
  1523. bytesData, err := json.Marshal(inputMessage)
  1524. fmt.Println(string(bytesData))
  1525. if err != nil {
  1526. fmt.Println(err.Error())
  1527. return err.Error(), ""
  1528. }
  1529. reader := bytes.NewReader(bytesData)
  1530. gdyb_url := beego.AppConfig.String("gdyb_url")
  1531. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1532. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1533. //url := gdyb_url + "2207"
  1534. var url string
  1535. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  1536. url = gdyb_url
  1537. } else {
  1538. url = gdyb_url + "2207"
  1539. }
  1540. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2207"
  1541. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  1542. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  1543. {
  1544. request, err := http.NewRequest("POST", url, reader)
  1545. if err != nil {
  1546. fmt.Println(err.Error())
  1547. return err.Error(), ""
  1548. }
  1549. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1550. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1551. request.Header.Set("x-tif-signature", signature)
  1552. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1553. request.Header.Set("x-tif-nonce", nonce)
  1554. client := http.Client{}
  1555. resp, err := client.Do(request)
  1556. if err != nil {
  1557. fmt.Println(err.Error())
  1558. return err.Error(), ""
  1559. }
  1560. respBytes, err := ioutil.ReadAll(resp.Body)
  1561. if err != nil {
  1562. fmt.Println(err.Error())
  1563. return err.Error(), ""
  1564. }
  1565. str := string(respBytes)
  1566. fmt.Println(str)
  1567. mjson, _ := json.Marshal(inputMessage)
  1568. str2 := string(mjson)
  1569. return str, str2
  1570. }
  1571. }
  1572. 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) {
  1573. // 生成签名
  1574. nonce := GetRandomString(32)
  1575. timestamp := time.Now().Unix()
  1576. signature := setSignature(timestamp, nonce, secret_key)
  1577. // 生成输入报文
  1578. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1579. input := make(map[string]interface{})
  1580. inputData := make(map[string]interface{})
  1581. inputMessage["infno"] = "2207A" // 交易编码
  1582. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1583. if certificates == 3 {
  1584. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  1585. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1586. } else {
  1587. if id_card_type == 1 {
  1588. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  1589. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1590. } else {
  1591. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  1592. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1593. }
  1594. }
  1595. if med_type == "1111" || med_type == "1112" {
  1596. med_type = "11"
  1597. }
  1598. {
  1599. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  1600. }
  1601. inputData["medfee_sumamt"] = total // 医疗费总额
  1602. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  1603. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1604. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  1605. inputData["acct_used_flag"] = acct_used_flag // 个人账户使用标志 0否 1是
  1606. inputData["insutype"] = insutype // 险种类型
  1607. inputData["invono"] = "" // 发票号
  1608. inputData["fulamt_ownpay_amt"] = fulamt_ownpay_amt //
  1609. inputData["overlmt_selfpay"] = overlmt_selfpay //
  1610. inputData["preselfpay_amt"] = preselfpay_amt //
  1611. inputData["inscp_scp_amt"] = inscp_scp_amt //
  1612. input["data"] = inputData
  1613. inputMessage["input"] = input //交易输入
  1614. bytesData, err := json.Marshal(inputMessage)
  1615. fmt.Println(string(bytesData))
  1616. if err != nil {
  1617. fmt.Println(err.Error())
  1618. return err.Error(), ""
  1619. }
  1620. reader := bytes.NewReader(bytesData)
  1621. gdyb_url := beego.AppConfig.String("gdyb_url")
  1622. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1623. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1624. //url := gdyb_url + "2207"
  1625. var url string
  1626. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  1627. url = gdyb_url
  1628. } else {
  1629. url = gdyb_url + "2207"
  1630. }
  1631. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2207"
  1632. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  1633. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  1634. {
  1635. request, err := http.NewRequest("POST", url, reader)
  1636. if err != nil {
  1637. fmt.Println(err.Error())
  1638. return err.Error(), ""
  1639. }
  1640. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1641. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1642. request.Header.Set("x-tif-signature", signature)
  1643. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1644. request.Header.Set("x-tif-nonce", nonce)
  1645. client := http.Client{}
  1646. resp, err := client.Do(request)
  1647. if err != nil {
  1648. fmt.Println(err.Error())
  1649. return err.Error(), ""
  1650. }
  1651. respBytes, err := ioutil.ReadAll(resp.Body)
  1652. if err != nil {
  1653. fmt.Println(err.Error())
  1654. return err.Error(), ""
  1655. }
  1656. str := string(respBytes)
  1657. fmt.Println(str)
  1658. mjson, _ := json.Marshal(inputMessage)
  1659. str2 := string(mjson)
  1660. return str, str2
  1661. }
  1662. }
  1663. // 门诊结算撤销
  1664. 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, admin_user_id int64) (string, string) {
  1665. // 生成签名
  1666. nonce := GetRandomString(32)
  1667. timestamp := time.Now().Unix()
  1668. signature := setSignature(timestamp, nonce, secret_key)
  1669. inputMessage := make(map[string]interface{})
  1670. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  1671. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  1672. } else {
  1673. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1674. }
  1675. // 生成输入报文
  1676. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1677. input := make(map[string]interface{})
  1678. inputData := make(map[string]interface{})
  1679. inputMessage["infno"] = "2208" // 交易编码
  1680. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1681. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1682. inputData["setl_id"] = setlId // 结算 ID
  1683. input["data"] = inputData
  1684. inputMessage["input"] = input //交易输入
  1685. bytesData, err := json.Marshal(inputMessage)
  1686. fmt.Println(string(bytesData))
  1687. if err != nil {
  1688. fmt.Println(err.Error())
  1689. return err.Error(), ""
  1690. }
  1691. reader := bytes.NewReader(bytesData)
  1692. gdyb_url := beego.AppConfig.String("gdyb_url")
  1693. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1694. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1695. //url := gdyb_url + "2208"
  1696. var url string
  1697. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  1698. url = gdyb_url
  1699. } else {
  1700. url = gdyb_url + "2208"
  1701. }
  1702. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2208"
  1703. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2208"
  1704. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2208"
  1705. {
  1706. request, err := http.NewRequest("POST", url, reader)
  1707. if err != nil {
  1708. fmt.Println(err.Error())
  1709. return err.Error(), ""
  1710. }
  1711. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1712. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1713. request.Header.Set("x-tif-signature", signature)
  1714. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1715. request.Header.Set("x-tif-nonce", nonce)
  1716. client := http.Client{}
  1717. resp, err := client.Do(request)
  1718. if err != nil {
  1719. fmt.Println(err.Error())
  1720. return err.Error(), ""
  1721. }
  1722. respBytes, err := ioutil.ReadAll(resp.Body)
  1723. if err != nil {
  1724. fmt.Println(err.Error())
  1725. return err.Error(), ""
  1726. }
  1727. str := string(respBytes)
  1728. fmt.Println(str)
  1729. mjson, _ := json.Marshal(inputMessage)
  1730. str2 := string(mjson)
  1731. return str, str2
  1732. }
  1733. }
  1734. // 确认订单
  1735. func Gdyb6201(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, order models.HisOrder) string {
  1736. // 生成签名
  1737. nonce := GetRandomString(32)
  1738. timestamp := time.Now().Unix()
  1739. signature := setSignature(timestamp, nonce, secret_key)
  1740. // 生成输入报文
  1741. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1742. input := make(map[string]interface{})
  1743. inputData := make(map[string]interface{})
  1744. inputMessage["infno"] = "6201" // 交易编码
  1745. inputData["mdtrt_id"] = order.MdtrtId
  1746. inputData["chrg_bchno"] = order.Number
  1747. inputData["psn_no"] = order.PsnNo
  1748. inputData["psn_name"] = order.PsnName
  1749. inputData["psn_cert_type"] = order.PsnCertType
  1750. inputData["certno"] = order.Certno
  1751. inputData["insutype"] = order.Insutype
  1752. inputData["med_type"] = order.MedType
  1753. inputData["medfee_sumamt"] = order.MedfeeSumamt
  1754. inputData["fulamt_ownpay_amt"] = order.FulamtOwnpayAmt
  1755. inputData["overlmt_selfpay"] = order.OverlmtSelfPay
  1756. inputData["preselfpay_amt"] = order.PreselfpayAmt
  1757. inputData["inscp_scp_amt"] = order.InscpScpAmt
  1758. inputData["act_pay_dedc"] = order.ActPayDedc
  1759. inputData["hifp_pay"] = order.HifpPay
  1760. inputData["pool_prop_selfpay"] = order.PoolPropSelfpay
  1761. inputData["cvlserv_pay"] = order.CvlservPay
  1762. inputData["hifes_pay"] = order.HifesPay
  1763. inputData["hifmi_pay"] = order.HifmiPay
  1764. inputData["hifob_pay"] = order.HifobPay
  1765. inputData["maf_pay"] = order.MafPay
  1766. inputData["oth_pay"] = order.OthPay
  1767. inputData["fund_pay_sumamt"] = order.FundPaySumamt
  1768. inputData["psn_part_amt"] = order.PsnPartAmt
  1769. inputData["acct_pay"] = order.AcctPay
  1770. inputData["psn_cash_pay"] = order.PsnCashPay
  1771. inputData["hosp_part_amt"] = order.HospPartAmt
  1772. inputData["acct_mulaid_pay"] = order.AcctMulaidPay
  1773. input["data"] = inputData
  1774. inputMessage["input"] = input //交易输入
  1775. bytesData, err := json.Marshal(inputMessage)
  1776. fmt.Println(string(bytesData))
  1777. if err != nil {
  1778. fmt.Println(err.Error())
  1779. return err.Error()
  1780. }
  1781. reader := bytes.NewReader(bytesData)
  1782. gdyb_url := beego.AppConfig.String("gdyb_url")
  1783. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1784. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1785. url := gdyb_url + "6201"
  1786. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/6201"
  1787. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/6201"
  1788. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  1789. request, err := http.NewRequest("POST", url, reader)
  1790. if err != nil {
  1791. fmt.Println(err.Error())
  1792. return err.Error()
  1793. }
  1794. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1795. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1796. request.Header.Set("x-tif-signature", signature)
  1797. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1798. request.Header.Set("x-tif-nonce", nonce)
  1799. client := http.Client{}
  1800. resp, err := client.Do(request)
  1801. if err != nil {
  1802. fmt.Println(err.Error())
  1803. return err.Error()
  1804. }
  1805. respBytes, err := ioutil.ReadAll(resp.Body)
  1806. if err != nil {
  1807. fmt.Println(err.Error())
  1808. return err.Error()
  1809. }
  1810. str := string(respBytes)
  1811. fmt.Println(str)
  1812. return str
  1813. }
  1814. // 医药机构费用结算对总账 func Gdyb3201( org_name string, doctor string, secret_key string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) string {
  1815. func Gdyb3201(baseParams models.BaseParams, businessParams models.BusinessParams, admin_user_id int64) string {
  1816. fmt.Println("11222333-----")
  1817. fmt.Println(baseParams)
  1818. fmt.Println(businessParams)
  1819. // 生成签名
  1820. nonce := GetRandomString(32)
  1821. timestamp := time.Now().Unix()
  1822. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1823. inputMessage := make(map[string]interface{})
  1824. if baseParams.MdtrtareaAdmvs == "450721" || baseParams.MdtrtareaAdmvs == "450127" {
  1825. inputMessage = SetInputMessage1111(nonce, timestamp, baseParams.OrgName, admin_user_id, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.Doctor)
  1826. } else {
  1827. inputMessage = SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1828. //inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1829. }
  1830. // 生成输入报文
  1831. input := make(map[string]interface{})
  1832. inputData := make(map[string]interface{})
  1833. inputMessage["infno"] = "3201" // 交易编码
  1834. inputData["insutype"] = businessParams.Insutype // 险种
  1835. if baseParams.MdtrtareaAdmvs == "450721" {
  1836. if businessParams.Insutype == "390" {
  1837. inputData["clr_type"] = "99971" // 就诊 ID(来自2201接口返回)
  1838. } else {
  1839. inputData["clr_type"] = "99970" // 就诊 ID(来自2201接口返回)
  1840. }
  1841. } else {
  1842. inputData["clr_type"] = businessParams.ClrType // 就诊 ID(来自2201接口返回)
  1843. }
  1844. inputData["setl_optins"] = businessParams.SetlOptins // 结算经办机构
  1845. inputData["stmt_begndate"] = businessParams.StmtBegndate // 对帐开始时间
  1846. inputData["stmt_enddate"] = businessParams.StmtEnddate //对帐结束时间
  1847. inputData["medfee_sumamt"] = businessParams.MedfeeSumamt //医疗费总额
  1848. inputData["fund_pay_sumamt"] = businessParams.FundPaySumamt //基金支付总额
  1849. inputData["acct_pay"] = businessParams.AcctPay //个人账户支付金额
  1850. inputData["fixmedins_setl_cnt"] = businessParams.FixmedinsSetlCnt //定点医药机构结算笔数
  1851. inputData["refd_setl_flag"] = 0 // 就诊 ID(来自2201接口返回)
  1852. input["data"] = inputData
  1853. inputMessage["input"] = input //交易输入
  1854. bytesData, err := json.Marshal(inputMessage)
  1855. fmt.Println(string(bytesData))
  1856. if err != nil {
  1857. fmt.Println(err.Error())
  1858. return err.Error()
  1859. }
  1860. reader := bytes.NewReader(bytesData)
  1861. gdyb_url := beego.AppConfig.String("gdyb_url")
  1862. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1863. var url string
  1864. if baseParams.MdtrtareaAdmvs == "150499" || baseParams.MdtrtareaAdmvs == "450721" {
  1865. url = gdyb_url
  1866. } else {
  1867. url = gdyb_url + "3201"
  1868. }
  1869. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1870. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3201"
  1871. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3201"
  1872. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3201"
  1873. request, err := http.NewRequest("POST", url, reader)
  1874. if err != nil {
  1875. fmt.Println(err.Error())
  1876. return err.Error()
  1877. }
  1878. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1879. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1880. request.Header.Set("x-tif-signature", signature)
  1881. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1882. request.Header.Set("x-tif-nonce", nonce)
  1883. client := http.Client{}
  1884. resp, err := client.Do(request)
  1885. if err != nil {
  1886. fmt.Println(err.Error())
  1887. return err.Error()
  1888. }
  1889. respBytes, err := ioutil.ReadAll(resp.Body)
  1890. if err != nil {
  1891. fmt.Println(err.Error())
  1892. return err.Error()
  1893. }
  1894. str := string(respBytes)
  1895. fmt.Println(str)
  1896. return str
  1897. }
  1898. type Params struct {
  1899. FileName string `json:"file_name"` //产品ID
  1900. In []byte `json:"in"` //
  1901. FixmedinsCode string `json:"fixmedins_code"` //调用环境生产为1 沙盒2
  1902. }
  1903. // 文件上传
  1904. func Gdyb9101(baseParams models.BaseParams, file_name string, file_byte []byte) string {
  1905. // 生成签名
  1906. nonce := GetRandomString(32)
  1907. timestamp := time.Now().Unix()
  1908. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1909. //buf := new(bytes.Buffer)
  1910. //buf.ReadFrom(strings.NewReader(string(file_byte)))
  1911. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1912. input := make(map[string]interface{})
  1913. inputData := make(map[string]interface{})
  1914. inputMessage["infno"] = "9101" // 交易编码
  1915. inputData["file_name"] = file_name //文件名
  1916. inputData["in"] = file_byte //文件数据
  1917. inputData["fixmedins_code"] = baseParams.FixmedinsCode //编码
  1918. input["fsUploadIn"] = inputData
  1919. inputMessage["input"] = input //交易输入
  1920. bytesData, err := json.Marshal(inputMessage)
  1921. fmt.Println(string(bytesData))
  1922. if err != nil {
  1923. fmt.Println(err.Error())
  1924. return err.Error()
  1925. }
  1926. reader := bytes.NewReader(bytesData)
  1927. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/9101"
  1928. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9101"
  1929. gdyb_url := beego.AppConfig.String("gdyb_url")
  1930. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1931. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1932. url := gdyb_url + "9101"
  1933. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9101"
  1934. request, err := http.NewRequest("POST", url, reader)
  1935. if err != nil {
  1936. fmt.Println(err.Error())
  1937. return err.Error()
  1938. }
  1939. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1940. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1941. request.Header.Set("x-tif-signature", signature)
  1942. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1943. request.Header.Set("x-tif-nonce", nonce)
  1944. client := http.Client{}
  1945. resp, err := client.Do(request)
  1946. if err != nil {
  1947. fmt.Println(err.Error())
  1948. return err.Error()
  1949. }
  1950. respBytes, err := ioutil.ReadAll(resp.Body)
  1951. if err != nil {
  1952. fmt.Println(err.Error())
  1953. return err.Error()
  1954. }
  1955. str := string(respBytes)
  1956. fmt.Println(str)
  1957. return str
  1958. }
  1959. func Gdyb9102(baseParams models.BaseParams, file_name string, file_qury_no string) string {
  1960. // 生成签名
  1961. nonce := GetRandomString(32)
  1962. timestamp := time.Now().Unix()
  1963. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1964. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1965. input := make(map[string]interface{})
  1966. inputData := make(map[string]interface{})
  1967. inputMessage["infno"] = "9102" // 交易编码
  1968. inputData["file_name"] = file_name //文件名
  1969. inputData["file_qury_no"] = file_qury_no //文件数据
  1970. inputData["fixmedins_code"] = baseParams.FixmedinsCode //编码
  1971. input["fsDownloadIn"] = inputData
  1972. inputMessage["input"] = input //交易输入
  1973. bytesData, err := json.Marshal(inputMessage)
  1974. fmt.Println(string(bytesData))
  1975. if err != nil {
  1976. fmt.Println(err.Error())
  1977. return err.Error()
  1978. }
  1979. reader := bytes.NewReader(bytesData)
  1980. gdyb_url := beego.AppConfig.String("gdyb_url")
  1981. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1982. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1983. url := gdyb_url + "9102"
  1984. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/9102"
  1985. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9102"
  1986. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9102"
  1987. request, err := http.NewRequest("POST", url, reader)
  1988. if err != nil {
  1989. fmt.Println(err.Error())
  1990. return err.Error()
  1991. }
  1992. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1993. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1994. request.Header.Set("x-tif-signature", signature)
  1995. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1996. request.Header.Set("x-tif-nonce", nonce)
  1997. client := http.Client{}
  1998. resp, err := client.Do(request)
  1999. if err != nil {
  2000. fmt.Println(err.Error())
  2001. return err.Error()
  2002. }
  2003. respBytes, err := ioutil.ReadAll(resp.Body)
  2004. if err != nil {
  2005. fmt.Println(err.Error())
  2006. return err.Error()
  2007. }
  2008. str := string(respBytes)
  2009. enc := mahonia.NewEncoder("gbk")
  2010. //output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  2011. fmt.Println(enc.ConvertString(str))
  2012. return str
  2013. }
  2014. func Gdyb3202(baseParams models.BaseParams, businessParams models.BusinessParams) string {
  2015. // 生成签名
  2016. nonce := GetRandomString(32)
  2017. timestamp := time.Now().Unix()
  2018. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  2019. // 生成输入报文
  2020. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  2021. input := make(map[string]interface{})
  2022. inputData := make(map[string]interface{})
  2023. inputMessage["infno"] = "3202" // 交易编码
  2024. inputData["file_qury_no"] = businessParams.FileQuryNo // 险种
  2025. inputData["setl_optins"] = baseParams.InsuplcAdmdvs // 结算经办机构
  2026. inputData["stmt_begndate"] = businessParams.StmtBegndate // 对帐开始时间
  2027. inputData["stmt_enddate"] = businessParams.StmtEnddate //对帐结束时间
  2028. inputData["medfee_sumamt"] = businessParams.MedfeeSumamt //医疗费总额
  2029. inputData["fund_pay_sumamt"] = businessParams.FundPaySumamt //基金支付总额
  2030. inputData["cash_payamt"] = businessParams.CashPayamt //现金支付金额
  2031. inputData["fixmedins_setl_cnt"] = businessParams.FixmedinsSetlCnt //定点医药机构结算笔数
  2032. inputData["clr_type"] = "11" // 就诊 ID(来自2201接口返回)
  2033. inputData["refd_setl_flag"] = 1 // 就诊 ID(来自2201接口返回)
  2034. input["data"] = inputData
  2035. inputMessage["input"] = input //交易输入
  2036. bytesData, err := json.Marshal(inputMessage)
  2037. fmt.Println(string(bytesData))
  2038. if err != nil {
  2039. fmt.Println(err.Error())
  2040. return err.Error()
  2041. }
  2042. reader := bytes.NewReader(bytesData)
  2043. gdyb_url := beego.AppConfig.String("gdyb_url")
  2044. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2045. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2046. url := gdyb_url + "3202"
  2047. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3202"
  2048. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3202"
  2049. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3202"
  2050. request, err := http.NewRequest("POST", url, reader)
  2051. if err != nil {
  2052. fmt.Println(err.Error())
  2053. return err.Error()
  2054. }
  2055. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2056. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2057. request.Header.Set("x-tif-signature", signature)
  2058. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2059. request.Header.Set("x-tif-nonce", nonce)
  2060. client := http.Client{}
  2061. resp, err := client.Do(request)
  2062. if err != nil {
  2063. fmt.Println(err.Error())
  2064. return err.Error()
  2065. }
  2066. respBytes, err := ioutil.ReadAll(resp.Body)
  2067. if err != nil {
  2068. fmt.Println(err.Error())
  2069. return err.Error()
  2070. }
  2071. str := string(respBytes)
  2072. fmt.Println(str)
  2073. return str
  2074. }
  2075. func Gdyb5203(baseParams models.BaseParams, businessParams models.BusinessParams) string {
  2076. fmt.Println("~~~~~~1")
  2077. fmt.Println(baseParams)
  2078. fmt.Println(businessParams)
  2079. // 生成签名
  2080. nonce := GetRandomString(32)
  2081. timestamp := time.Now().Unix()
  2082. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  2083. fmt.Println("~~~~~~2")
  2084. // 生成输入报文
  2085. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  2086. input := make(map[string]interface{})
  2087. inputData := make(map[string]interface{})
  2088. inputMessage["infno"] = "5203" // 交易编码
  2089. inputData["psn_no"] = businessParams.PsnNo
  2090. inputData["setl_id"] = businessParams.SetlId
  2091. inputData["mdtrt_id"] = businessParams.MdtrtId
  2092. input["data"] = inputData
  2093. inputMessage["input"] = input //交易输入
  2094. bytesData, err := json.Marshal(inputMessage)
  2095. fmt.Println(string(bytesData))
  2096. fmt.Println("~~~~~~")
  2097. fmt.Println("~~~~~~")
  2098. fmt.Println(string(bytesData))
  2099. if err != nil {
  2100. fmt.Println(err.Error())
  2101. return err.Error()
  2102. }
  2103. reader := bytes.NewReader(bytesData)
  2104. gdyb_url := beego.AppConfig.String("gdyb_url")
  2105. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2106. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2107. //url := gdyb_url + "5203"
  2108. var url string
  2109. if baseParams.FixmedinsCode == "H15049901371" || baseParams.MdtrtareaAdmvs == "450127" || baseParams.MdtrtareaAdmvs == "450721" {
  2110. url = gdyb_url
  2111. } else {
  2112. url = gdyb_url + "5203"
  2113. }
  2114. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5203"
  2115. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
  2116. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
  2117. request, err := http.NewRequest("POST", url, reader)
  2118. if err != nil {
  2119. fmt.Println(err.Error())
  2120. return err.Error()
  2121. }
  2122. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2123. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2124. request.Header.Set("x-tif-signature", signature)
  2125. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2126. request.Header.Set("x-tif-nonce", nonce)
  2127. client := http.Client{}
  2128. resp, err := client.Do(request)
  2129. if err != nil {
  2130. fmt.Println(err.Error())
  2131. return err.Error()
  2132. }
  2133. respBytes, err := ioutil.ReadAll(resp.Body)
  2134. if err != nil {
  2135. fmt.Println(err.Error())
  2136. return err.Error()
  2137. }
  2138. str := string(respBytes)
  2139. fmt.Println(str)
  2140. return str
  2141. }
  2142. func Gdyb5204(baseParams models.BaseParams, businessParams models.BusinessParams) string {
  2143. // 生成签名
  2144. nonce := GetRandomString(32)
  2145. timestamp := time.Now().Unix()
  2146. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  2147. // 生成输入报文
  2148. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  2149. input := make(map[string]interface{})
  2150. inputData := make(map[string]interface{})
  2151. inputMessage["infno"] = "5204" // 交易编码
  2152. inputData["psn_no"] = businessParams.PsnNo
  2153. inputData["setl_id"] = businessParams.SetlId
  2154. inputData["mdtrt_id"] = businessParams.MdtrtId
  2155. input["data"] = inputData
  2156. inputMessage["input"] = input //交易输入
  2157. bytesData, err := json.Marshal(inputMessage)
  2158. fmt.Println(string(bytesData))
  2159. if err != nil {
  2160. fmt.Println(err.Error())
  2161. return err.Error()
  2162. }
  2163. reader := bytes.NewReader(bytesData)
  2164. gdyb_url := beego.AppConfig.String("gdyb_url")
  2165. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2166. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2167. //url := gdyb_url + "5203"
  2168. var url string
  2169. if baseParams.FixmedinsCode == "H15049901371" || baseParams.MdtrtareaAdmvs == "450127" || baseParams.MdtrtareaAdmvs == "450721" {
  2170. url = gdyb_url
  2171. } else {
  2172. url = gdyb_url + "5204"
  2173. }
  2174. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5203"
  2175. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
  2176. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
  2177. request, err := http.NewRequest("POST", url, reader)
  2178. if err != nil {
  2179. fmt.Println(err.Error())
  2180. return err.Error()
  2181. }
  2182. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2183. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2184. request.Header.Set("x-tif-signature", signature)
  2185. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2186. request.Header.Set("x-tif-nonce", nonce)
  2187. client := http.Client{}
  2188. resp, err := client.Do(request)
  2189. if err != nil {
  2190. fmt.Println(err.Error())
  2191. return err.Error()
  2192. }
  2193. respBytes, err := ioutil.ReadAll(resp.Body)
  2194. if err != nil {
  2195. fmt.Println(err.Error())
  2196. return err.Error()
  2197. }
  2198. str := string(respBytes)
  2199. fmt.Println(str)
  2200. return str
  2201. }
  2202. func Gdyb2001(baseParams models.BaseParams, psn_no string, insutype string, med_type string) string {
  2203. if med_type == "1111" || med_type == "1112" {
  2204. med_type = "11"
  2205. }
  2206. // 生成签名
  2207. nonce := GetRandomString(32)
  2208. timestamp := time.Now().Unix()
  2209. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  2210. // 生成输入报文
  2211. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  2212. input := make(map[string]interface{})
  2213. inputData := make(map[string]interface{})
  2214. inputMessage["infno"] = "2001" // 交易编码
  2215. inputData["psn_no"] = psn_no
  2216. inputData["insutype"] = insutype
  2217. inputData["fixmedins_code"] = baseParams.FixmedinsCode
  2218. inputData["med_type"] = med_type
  2219. inputData["begntime"] = "2021-01-01 00:00:00"
  2220. input["data"] = inputData
  2221. inputMessage["input"] = input //交易输入
  2222. bytesData, err := json.Marshal(inputMessage)
  2223. fmt.Println(string(bytesData))
  2224. if err != nil {
  2225. fmt.Println(err.Error())
  2226. return err.Error()
  2227. }
  2228. reader := bytes.NewReader(bytesData)
  2229. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3301"
  2230. gdyb_url := beego.AppConfig.String("gdyb_url")
  2231. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2232. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2233. url := gdyb_url
  2234. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3301"
  2235. request, err := http.NewRequest("POST", url, reader)
  2236. if err != nil {
  2237. fmt.Println(err.Error())
  2238. return err.Error()
  2239. }
  2240. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2241. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2242. request.Header.Set("x-tif-signature", signature)
  2243. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2244. request.Header.Set("x-tif-nonce", nonce)
  2245. client := http.Client{}
  2246. resp, err := client.Do(request)
  2247. if err != nil {
  2248. fmt.Println(err.Error())
  2249. return err.Error()
  2250. }
  2251. respBytes, err := ioutil.ReadAll(resp.Body)
  2252. if err != nil {
  2253. fmt.Println(err.Error())
  2254. return err.Error()
  2255. }
  2256. str := string(respBytes)
  2257. fmt.Println(str)
  2258. return str
  2259. }
  2260. func Gdyb3301(baseParams models.BaseParams, name string, codg string, list_type_code string, start_time string, ent_time string, list_type string, admin_user_id int64) string {
  2261. // 生成签名
  2262. nonce := GetRandomString(32)
  2263. timestamp := time.Now().Unix()
  2264. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  2265. inputMessage := make(map[string]interface{})
  2266. if baseParams.MdtrtareaAdmvs == "450721" {
  2267. inputMessage = SetInputMessage1111(nonce, timestamp, baseParams.OrgName, admin_user_id, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.Doctor)
  2268. //inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs,doctor)
  2269. } else {
  2270. inputMessage = SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  2271. //inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2272. }
  2273. // 生成输入报文
  2274. input := make(map[string]interface{})
  2275. //input2 := make([]map[string]interface{})
  2276. feedetail := make([]map[string]interface{}, 0)
  2277. inputData := make(map[string]interface{})
  2278. inputMessage["infno"] = "3301A" // 交易编码
  2279. inputData["fixmedins_hilist_id"] = codg
  2280. inputData["fixmedins_hilist_name"] = name
  2281. inputData["list_type"] = list_type
  2282. inputData["med_list_codg"] = codg
  2283. inputData["begndate"] = start_time
  2284. inputData["enddate"] = ent_time
  2285. inputData["aprvno"] = ""
  2286. inputData["dosform"] = ""
  2287. inputData["exct_cont"] = ""
  2288. inputData["item_cont"] = ""
  2289. inputData["prcunt"] = ""
  2290. inputData["spec"] = ""
  2291. inputData["pacspec"] = ""
  2292. inputData["memo"] = ""
  2293. feedetail = append(feedetail, inputData)
  2294. input["data"] = feedetail
  2295. inputMessage["input"] = input //交易输入
  2296. bytesData, err := json.Marshal(inputMessage)
  2297. fmt.Println(string(bytesData))
  2298. if err != nil {
  2299. fmt.Println(err.Error())
  2300. return err.Error()
  2301. }
  2302. reader := bytes.NewReader(bytesData)
  2303. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3301"
  2304. //
  2305. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3301"
  2306. gdyb_url := beego.AppConfig.String("gdyb_url")
  2307. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2308. url := ""
  2309. if baseParams.MdtrtareaAdmvs == "450721" {
  2310. url = gdyb_url
  2311. } else {
  2312. url = gdyb_url + "3301"
  2313. }
  2314. request, err := http.NewRequest("POST", url, reader)
  2315. if err != nil {
  2316. fmt.Println(err.Error())
  2317. return err.Error()
  2318. }
  2319. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2320. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2321. request.Header.Set("x-tif-signature", signature)
  2322. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2323. request.Header.Set("x-tif-nonce", nonce)
  2324. client := http.Client{}
  2325. resp, err := client.Do(request)
  2326. if err != nil {
  2327. fmt.Println(err.Error())
  2328. return err.Error()
  2329. }
  2330. respBytes, err := ioutil.ReadAll(resp.Body)
  2331. if err != nil {
  2332. fmt.Println(err.Error())
  2333. return err.Error()
  2334. }
  2335. str := string(respBytes)
  2336. fmt.Println(str)
  2337. return str
  2338. }
  2339. func Gdyb3302(baseParams *models.BaseParams, name string, codg string, list_type_code string) string {
  2340. // 生成签名
  2341. nonce := GetRandomString(32)
  2342. timestamp := time.Now().Unix()
  2343. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  2344. // 生成输入报文
  2345. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  2346. input := make(map[string]interface{})
  2347. inputData := make(map[string]interface{})
  2348. inputMessage["infno"] = "3302" // 交易编码
  2349. inputData["fixmedins_code"] = baseParams.FixmedinsCode
  2350. inputData["fixmedins_hilist_id"] = codg
  2351. inputData["list_type"] = list_type_code
  2352. inputData["med_list_codg"] = codg
  2353. input["data"] = inputData
  2354. inputMessage["input"] = input //交易输入
  2355. bytesData, err := json.Marshal(inputMessage)
  2356. fmt.Println(string(bytesData))
  2357. if err != nil {
  2358. fmt.Println(err.Error())
  2359. return err.Error()
  2360. }
  2361. reader := bytes.NewReader(bytesData)
  2362. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3302"
  2363. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3302"
  2364. gdyb_url := beego.AppConfig.String("gdyb_url")
  2365. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2366. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2367. url := gdyb_url + "3302"
  2368. request, err := http.NewRequest("POST", url, reader)
  2369. if err != nil {
  2370. fmt.Println(err.Error())
  2371. return err.Error()
  2372. }
  2373. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2374. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2375. request.Header.Set("x-tif-signature", signature)
  2376. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2377. request.Header.Set("x-tif-nonce", nonce)
  2378. client := http.Client{}
  2379. resp, err := client.Do(request)
  2380. if err != nil {
  2381. fmt.Println(err.Error())
  2382. return err.Error()
  2383. }
  2384. respBytes, err := ioutil.ReadAll(resp.Body)
  2385. if err != nil {
  2386. fmt.Println(err.Error())
  2387. return err.Error()
  2388. }
  2389. str := string(respBytes)
  2390. fmt.Println(str)
  2391. return str
  2392. }
  2393. 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, admin_user_id int64) string {
  2394. // 生成签名
  2395. nonce := GetRandomString(32)
  2396. timestamp := time.Now().Unix()
  2397. signature := setSignature(timestamp, nonce, secret_key)
  2398. inputMessage := make(map[string]interface{})
  2399. //tempTime := time.Unix(timestamp, 0)
  2400. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2401. // 生成输入报文
  2402. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  2403. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  2404. } else {
  2405. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2406. }
  2407. // 生成输入报文
  2408. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2409. input := make(map[string]interface{})
  2410. inputData := make(map[string]interface{})
  2411. inputMessage["infno"] = "2505"
  2412. inputData["psn_no"] = psnNo
  2413. inputData["biz_appy_type"] = "01"
  2414. inputData["begndate"] = start_time
  2415. inputData["enddate"] = end_time
  2416. inputData["fixmedins_code"] = fixmedins_code
  2417. inputData["fixmedins_name"] = org_name
  2418. inputData["tel"] = ""
  2419. inputData["addr"] = ""
  2420. inputData["agnter_name"] = ""
  2421. inputData["agnter_cert_type"] = ""
  2422. inputData["agnter_certno"] = ""
  2423. inputData["agnter_tel"] = ""
  2424. inputData["agnter_addr"] = ""
  2425. inputData["agnter_rlts"] = ""
  2426. inputData["fix_srt_no"] = "1"
  2427. inputData["memo"] = ""
  2428. input["data"] = inputData
  2429. inputMessage["input"] = input //交易输入
  2430. bytesData, err := json.Marshal(inputMessage)
  2431. if err != nil {
  2432. fmt.Println(err.Error())
  2433. return err.Error()
  2434. }
  2435. reader := bytes.NewReader(bytesData)
  2436. //fmt.Println(String(bytesData))
  2437. fmt.Println(string(bytesData))
  2438. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2505"
  2439. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2505"
  2440. gdyb_url := beego.AppConfig.String("gdyb_url")
  2441. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2442. url := ""
  2443. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  2444. url = gdyb_url
  2445. } else {
  2446. url = gdyb_url + "2505"
  2447. }
  2448. request, err := http.NewRequest("POST", url, reader)
  2449. if err != nil {
  2450. fmt.Println(err.Error())
  2451. return err.Error()
  2452. }
  2453. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2454. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2455. request.Header.Set("x-tif-signature", signature)
  2456. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2457. request.Header.Set("x-tif-nonce", nonce)
  2458. client := http.Client{}
  2459. resp, err := client.Do(request)
  2460. if err != nil {
  2461. fmt.Println(err.Error())
  2462. return err.Error()
  2463. }
  2464. respBytes, err := ioutil.ReadAll(resp.Body)
  2465. if err != nil {
  2466. fmt.Println(err.Error())
  2467. return err.Error()
  2468. }
  2469. str := string(respBytes)
  2470. fmt.Println(str)
  2471. return str
  2472. }
  2473. 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 {
  2474. // 生成签名
  2475. nonce := GetRandomString(32)
  2476. timestamp := time.Now().Unix()
  2477. signature := setSignature(timestamp, nonce, secret_key)
  2478. // 生成输入报文
  2479. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2480. input := make(map[string]interface{})
  2481. inputData := make(map[string]interface{})
  2482. inputMessage["infno"] = "2506"
  2483. inputData["psn_no"] = psnNo
  2484. inputData["trt_dcla_detl_sn"] = trt_dcla_detl_sn
  2485. inputData["memo"] = ""
  2486. input["data"] = inputData
  2487. inputMessage["input"] = input //交易输入
  2488. bytesData, err := json.Marshal(inputMessage)
  2489. fmt.Println(string(bytesData))
  2490. if err != nil {
  2491. fmt.Println(err.Error())
  2492. return err.Error()
  2493. }
  2494. reader := bytes.NewReader(bytesData)
  2495. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2506"
  2496. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2506"
  2497. gdyb_url := beego.AppConfig.String("gdyb_url")
  2498. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2499. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2500. url := gdyb_url + "2506"
  2501. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  2502. request, err := http.NewRequest("POST", url, reader)
  2503. if err != nil {
  2504. fmt.Println(err.Error())
  2505. return err.Error()
  2506. }
  2507. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2508. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2509. request.Header.Set("x-tif-signature", signature)
  2510. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2511. request.Header.Set("x-tif-nonce", nonce)
  2512. client := http.Client{}
  2513. resp, err := client.Do(request)
  2514. if err != nil {
  2515. fmt.Println(err.Error())
  2516. return err.Error()
  2517. }
  2518. respBytes, err := ioutil.ReadAll(resp.Body)
  2519. if err != nil {
  2520. fmt.Println(err.Error())
  2521. return err.Error()
  2522. }
  2523. str := string(respBytes)
  2524. fmt.Println(str)
  2525. return str
  2526. }
  2527. 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 {
  2528. // 生成签名
  2529. nonce := GetRandomString(32)
  2530. timestamp := time.Now().Unix()
  2531. signature := setSignature(timestamp, nonce, secret_key)
  2532. //tempTime := time.Unix(timestamp, 0)
  2533. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2534. //timeFormatTwo := tempTime.Format("2006-01-02")
  2535. //t := time.Now()
  2536. //last := time.Date(t.Year(), time.December, 31, 0, 0, 0, 0, time.UTC)
  2537. //tm := time.Unix(last.Unix(), 0)
  2538. // 生成输入报文
  2539. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2540. input := make(map[string]interface{})
  2541. inputData := make(map[string]interface{})
  2542. inputMessage["infno"] = "2503" // 交易编码
  2543. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  2544. inputData["insutype"] = insutype // 险种类型(来自1101接口返回)
  2545. inputData["opsp_dise_code"] = sick_code // 险种类型(来自1101接口返回)
  2546. inputData["opsp_dise_name"] = sick_name // 险种类型(来自1101接口返回)
  2547. inputData["insu_optins"] = insuplc_admdvs // 险种类型(来自1101接口返回)
  2548. inputData["ide_fixmedins_no"] = hospital_code // 险种类型(来自1101接口返回)
  2549. inputData["ide_fixmedins_name"] = hospital_name // 险种类型(来自1101接口返回)
  2550. inputData["hosp_ide_date"] = check_time // 险种类型(来自1101接口返回)
  2551. inputData["diag_dr_codg"] = doctor_id // 开始时间
  2552. inputData["diag_dr_name"] = doctor // 开始时间
  2553. inputData["begndate"] = start_time // 医师编码
  2554. inputData["tel"] = "" // 医师编码
  2555. inputData["addr"] = "" // 医师编码
  2556. inputData["enddate"] = end_time // 医师编码
  2557. input["data"] = inputData
  2558. inputMessage["input"] = input //交易输入
  2559. bytesData, err := json.Marshal(inputMessage)
  2560. fmt.Println(string(bytesData))
  2561. if err != nil {
  2562. fmt.Println(err.Error())
  2563. return err.Error()
  2564. }
  2565. reader := bytes.NewReader(bytesData)
  2566. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2503"
  2567. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2503"
  2568. gdyb_url := beego.AppConfig.String("gdyb_url")
  2569. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2570. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2571. //url := gdyb_url + "2503"
  2572. var url string
  2573. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  2574. url = gdyb_url
  2575. } else {
  2576. url = gdyb_url + "2503"
  2577. }
  2578. request, err := http.NewRequest("POST", url, reader)
  2579. if err != nil {
  2580. fmt.Println(err.Error())
  2581. return err.Error()
  2582. }
  2583. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2584. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2585. request.Header.Set("x-tif-signature", signature)
  2586. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2587. request.Header.Set("x-tif-nonce", nonce)
  2588. client := http.Client{}
  2589. resp, err := client.Do(request)
  2590. if err != nil {
  2591. fmt.Println(err.Error())
  2592. return err.Error()
  2593. }
  2594. respBytes, err := ioutil.ReadAll(resp.Body)
  2595. if err != nil {
  2596. fmt.Println(err.Error())
  2597. return err.Error()
  2598. }
  2599. str := string(respBytes)
  2600. fmt.Println(str)
  2601. return str
  2602. }
  2603. 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 {
  2604. // 生成签名
  2605. nonce := GetRandomString(32)
  2606. timestamp := time.Now().Unix()
  2607. signature := setSignature(timestamp, nonce, secret_key)
  2608. // 生成输入报文
  2609. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2610. input := make(map[string]interface{})
  2611. inputData := make(map[string]interface{})
  2612. inputMessage["infno"] = "2504" // 交易编码
  2613. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  2614. inputData["trt_dcla_detl_sn"] = trt_dcla_detl_sn // 人员编号 (来自1101接口返回)
  2615. inputData["memo"] = "撤销备案" // 人员编号 (来自1101接口返回)
  2616. input["data"] = inputData
  2617. inputMessage["input"] = input //交易输入
  2618. bytesData, err := json.Marshal(inputMessage)
  2619. fmt.Println(string(bytesData))
  2620. if err != nil {
  2621. fmt.Println(err.Error())
  2622. return err.Error()
  2623. }
  2624. reader := bytes.NewReader(bytesData)
  2625. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2504"
  2626. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2504"
  2627. gdyb_url := beego.AppConfig.String("gdyb_url")
  2628. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2629. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2630. url := gdyb_url + "2504"
  2631. request, err := http.NewRequest("POST", url, reader)
  2632. if err != nil {
  2633. fmt.Println(err.Error())
  2634. return err.Error()
  2635. }
  2636. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2637. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2638. request.Header.Set("x-tif-signature", signature)
  2639. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2640. request.Header.Set("x-tif-nonce", nonce)
  2641. client := http.Client{}
  2642. resp, err := client.Do(request)
  2643. if err != nil {
  2644. fmt.Println(err.Error())
  2645. return err.Error()
  2646. }
  2647. respBytes, err := ioutil.ReadAll(resp.Body)
  2648. if err != nil {
  2649. fmt.Println(err.Error())
  2650. return err.Error()
  2651. }
  2652. str := string(respBytes)
  2653. fmt.Println(str)
  2654. return str
  2655. }
  2656. //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 {
  2657. // // 生成签名
  2658. // nonce := GetRandomString(32)
  2659. // timestamp := time.Now().Unix()
  2660. // signature := setSignature(timestamp, nonce, secret_key)
  2661. // tempTime := time.Unix(timestamp, 0)
  2662. // timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2663. //
  2664. // // 生成输入报文
  2665. // inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2666. // input := make(map[string]interface{})
  2667. // inputData := make(map[string]interface{})
  2668. // diseinfo := make([]map[string]interface{}, 0)
  2669. //
  2670. // inputMessage["infno"] = "2203" // 交易编码
  2671. // inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  2672. // inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  2673. // inputData["med_type"] = med_type // 医疗类别 16门诊特殊病
  2674. // inputData["begntime"] = timeFormatOne // 开始时间
  2675. // inputData["main_cond_dscr"] = "" // 主要病情描述
  2676. // inputData["dise_codg"] = sick_code // 病种编码
  2677. // inputData["dise_name"] = sick_name // 病种名称
  2678. // inputData["birctrl_type"] = "" // 计划生育手术类别
  2679. // inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
  2680. //
  2681. // diseinfo_sun := make(map[string]interface{})
  2682. // diseinfo_sun["diag_type"] = "1" // 诊断类别
  2683. // diseinfo_sun["diag_srt_no"] = "1" // 诊断排序号
  2684. // diseinfo_sun["diag_code"] = diag_code // 诊断代码
  2685. // diseinfo_sun["diag_name"] = diag // 诊断名称
  2686. // diseinfo_sun["diag_dept"] = department // 诊断科室
  2687. // diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
  2688. // diseinfo_sun["dise_dor_name"] = doctor // 诊断医生姓名
  2689. // diseinfo_sun["diag_time"] = timeFormatOne // 诊断时间
  2690. // diseinfo_sun["vali_flag"] = "1" // 有效标志
  2691. //
  2692. // diseinfo = append(diseinfo, diseinfo_sun)
  2693. // input["diseinfo"] = diseinfo
  2694. // input["mdtrtinfo"] = inputData
  2695. // inputMessage["input"] = input //交易输入
  2696. //
  2697. // bytesData, err := json.Marshal(inputMessage)
  2698. // fmt.Println(string(bytesData))
  2699. // if err != nil {
  2700. // fmt.Println(err.Error())
  2701. // return err.Error()
  2702. // }
  2703. // reader := bytes.NewReader(bytesData)
  2704. //
  2705. // url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2203"
  2706. //
  2707. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  2708. // request, err := http.NewRequest("POST", url, reader)
  2709. // if err != nil {
  2710. // fmt.Println(err.Error())
  2711. // return err.Error()
  2712. // }
  2713. //
  2714. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2715. // request.Header.Set("x-tif-paasid", "sg03_prd")
  2716. // request.Header.Set("x-tif-signature", signature)
  2717. // request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2718. // request.Header.Set("x-tif-nonce", nonce)
  2719. //
  2720. // client := http.Client{}
  2721. // resp, err := client.Do(request)
  2722. // if err != nil {
  2723. // fmt.Println(err.Error())
  2724. // return err.Error()
  2725. // }
  2726. // respBytes, err := ioutil.ReadAll(resp.Body)
  2727. // if err != nil {
  2728. // fmt.Println(err.Error())
  2729. // return err.Error()
  2730. // }
  2731. // str := string(respBytes)
  2732. // fmt.Println(str)
  2733. // return str
  2734. //}
  2735. func Gdyb5301(psnNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, admin_user_id int64) string {
  2736. // 生成签名
  2737. nonce := GetRandomString(32)
  2738. timestamp := time.Now().Unix()
  2739. //timestamp := time.Now().UnixNano() / 1e6
  2740. signature := setSignature(timestamp, nonce, secret_key)
  2741. //tempTime := time.Unix(timestamp, 0)
  2742. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2743. //timeFormatTwo := tempTime.Format("2006-01-02")
  2744. inputMessage := make(map[string]interface{})
  2745. //tempTime := time.Unix(timestamp, 0)
  2746. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2747. // 生成输入报文
  2748. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  2749. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  2750. } else {
  2751. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2752. }
  2753. // 生成输入报文
  2754. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2755. input := make(map[string]interface{})
  2756. inputData := make(map[string]interface{})
  2757. inputMessage["infno"] = "5301" // 交易编码
  2758. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  2759. input["data"] = inputData
  2760. inputMessage["input"] = input //交易输入
  2761. bytesData, err := json.Marshal(inputMessage)
  2762. fmt.Println(string(bytesData))
  2763. if err != nil {
  2764. fmt.Println(err.Error())
  2765. return err.Error()
  2766. }
  2767. reader := bytes.NewReader(bytesData)
  2768. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  2769. gdyb_url := beego.AppConfig.String("gdyb_url")
  2770. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2771. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2772. var url string
  2773. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  2774. url = gdyb_url
  2775. } else {
  2776. url = gdyb_url + "5301"
  2777. }
  2778. request, err := http.NewRequest("POST", url, reader)
  2779. if err != nil {
  2780. fmt.Println(err.Error())
  2781. return err.Error()
  2782. }
  2783. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2784. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2785. request.Header.Set("x-tif-signature", signature)
  2786. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2787. request.Header.Set("x-tif-nonce", nonce)
  2788. client := http.Client{}
  2789. resp, err := client.Do(request)
  2790. if err != nil {
  2791. fmt.Println(err.Error())
  2792. return err.Error()
  2793. }
  2794. respBytes, err := ioutil.ReadAll(resp.Body)
  2795. if err != nil {
  2796. fmt.Println(err.Error())
  2797. return err.Error()
  2798. }
  2799. str := string(respBytes)
  2800. fmt.Println(str)
  2801. return str
  2802. }
  2803. func Gdyb5301Two(psnNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  2804. // 生成签名
  2805. nonce := GetRandomString(32)
  2806. timestamp := time.Now().Unix()
  2807. signature := setSignature(timestamp, nonce, secret_key)
  2808. //tempTime := time.Unix(timestamp, 0)
  2809. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2810. //timeFormatTwo := tempTime.Format("2006-01-02")
  2811. // 生成输入报文
  2812. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2813. input := make(map[string]interface{})
  2814. inputData := make(map[string]interface{})
  2815. inputMessage["infno"] = "5301" // 交易编码
  2816. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  2817. input["data"] = inputData
  2818. inputMessage["input"] = input //交易输入
  2819. bytesData, err := json.Marshal(inputMessage)
  2820. fmt.Println(string(bytesData))
  2821. if err != nil {
  2822. fmt.Println(err.Error())
  2823. return err.Error()
  2824. }
  2825. reader := bytes.NewReader(bytesData)
  2826. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  2827. gdyb_url := beego.AppConfig.String("gdyb_url")
  2828. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2829. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2830. url := gdyb_url
  2831. request, err := http.NewRequest("POST", url, reader)
  2832. if err != nil {
  2833. fmt.Println(err.Error())
  2834. return err.Error()
  2835. }
  2836. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2837. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2838. request.Header.Set("x-tif-signature", signature)
  2839. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2840. request.Header.Set("x-tif-nonce", nonce)
  2841. client := http.Client{}
  2842. resp, err := client.Do(request)
  2843. if err != nil {
  2844. fmt.Println(err.Error())
  2845. return err.Error()
  2846. }
  2847. respBytes, err := ioutil.ReadAll(resp.Body)
  2848. if err != nil {
  2849. fmt.Println(err.Error())
  2850. return err.Error()
  2851. }
  2852. str := string(respBytes)
  2853. fmt.Println(str)
  2854. return str
  2855. }
  2856. type CustomStruct struct {
  2857. FundPayType string
  2858. FundPayamt float64
  2859. }
  2860. type OpspdiseinfoStruct struct {
  2861. DiagName string
  2862. DiagCode string
  2863. OprnOprtName string
  2864. OprnOprtCode string
  2865. }
  2866. type DiaginfoStructTwo struct {
  2867. DiagType string
  2868. DiagCode string
  2869. DiagName string
  2870. MaindiagFlag string
  2871. }
  2872. type IteminfoStruct struct {
  2873. MedChrgitm string
  2874. Amt float64
  2875. ClaaSumfee float64
  2876. ClabAmt float64
  2877. FulamtOwnpayAmt float64
  2878. OthAmt float64
  2879. }
  2880. type Struct4101 struct {
  2881. PsnNo string
  2882. MdtrtId string
  2883. SetlId string
  2884. HiSetlLv string
  2885. PsnName string
  2886. Gend string
  2887. Brdy string
  2888. Ntly string
  2889. Naty string
  2890. PatnCertType string
  2891. Certno string
  2892. Prfs string
  2893. ConerName string
  2894. PatnRlts string
  2895. ConerAddr string
  2896. ConerTel string
  2897. HiType string
  2898. Insuplc string
  2899. AdmCaty string
  2900. DscgCaty string
  2901. MaindiagFlag string
  2902. BillCode string
  2903. BillNo string
  2904. BizSn string
  2905. SetlBegnDate string
  2906. SetlEndDate string
  2907. PsnSelfPay float64
  2908. PsnOwnPay float64
  2909. AcctPay float64
  2910. PsnCashpay float64
  2911. HiPaymtd string
  2912. Hsorg string
  2913. HsorgOpter string
  2914. MedinsFillDept string
  2915. MedinsFillPsn string
  2916. IptMedType string
  2917. Age int64
  2918. CustomStruct []CustomStruct
  2919. OpspdiseinfoStruct []OpspdiseinfoStruct
  2920. Diseinfo []DiaginfoStructTwo
  2921. IteminfoStruct []IteminfoStruct
  2922. AdmTime string
  2923. AdmEndTime string
  2924. HisNo string
  2925. DoctorName string
  2926. DoctorCode string
  2927. CurAddr string
  2928. }
  2929. func Gdyb4101(struct4101 Struct4101, secret_key string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, org_id int64, admin_user_id int64) (string, string) {
  2930. // 生成签名
  2931. nonce := GetRandomString(32)
  2932. timestamp := time.Now().Unix()
  2933. signature := setSignature(timestamp, nonce, secret_key)
  2934. inputMessage := make(map[string]interface{})
  2935. //tempTime := time.Unix(timestamp, 0)
  2936. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2937. // 生成输入报文
  2938. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  2939. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  2940. } else {
  2941. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2942. }
  2943. // 生成输入报文
  2944. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2945. input := make(map[string]interface{})
  2946. inputData := make(map[string]interface{})
  2947. if org_id == 10106 || org_id == 10215 || org_id == 10138 || org_id == 9504 {
  2948. inputMessage["infno"] = "4101A" // 交易编码
  2949. } else {
  2950. inputMessage["infno"] = "4101A" // 交易编码
  2951. }
  2952. year := time.Now().Format("2006")
  2953. month := time.Now().Format("01")
  2954. day := time.Now().Format("02")
  2955. inputData["mdtrt_id"] = struct4101.MdtrtId // 就诊 ID 必填(来自2201接口返回)
  2956. inputData["setl_id"] = struct4101.SetlId // 结算 ID 必填
  2957. inputData["psn_no"] = struct4101.PsnNo // 结算 ID 必填
  2958. inputData["fixmedins_name"] = org_name // 定点医药机构名称 必填
  2959. inputData["fixmedins_code"] = fixmedins_code // 定点医药机构编码 必填
  2960. inputData["hi_setl_lv"] = "" // 医保结算等级
  2961. inputData["hi_no"] = struct4101.PsnNo // 医保编号
  2962. inputData["medcasno"] = struct4101.PsnNo // 病案号 必填
  2963. inputData["dcla_time"] = year + "-" + month + "-" + day // 申报时间 必填
  2964. inputData["psn_name"] = struct4101.PsnName // 人员姓名 必填
  2965. inputData["gend"] = struct4101.Gend // 性别 必填
  2966. inputData["brdy"] = struct4101.Brdy // 出生日期 必填
  2967. inputData["age"] = struct4101.Age // 年龄 必填
  2968. inputData["ntly"] = "CHN" // 国籍 必填
  2969. inputData["nwb_age"] = "" // 年龄 必填
  2970. inputData["naty"] = struct4101.Naty // 民族 必填
  2971. inputData["dscg_way"] = "9" // 民族 必填
  2972. //inputData["resp_nurs_code"] = "N441623001432" // 民族 必填
  2973. inputData["patn_cert_type"] = struct4101.PatnCertType // 患者证件类别 必填
  2974. inputData["certno"] = struct4101.Certno // 证件号码 必填
  2975. inputData["prfs"] = struct4101.Prfs // 职业 必填
  2976. inputData["curr_addr"] = "" // 现住址 必填
  2977. inputData["emp_name"] = "" // 单位名称 必填
  2978. inputData["emp_addr"] = "" // 单位地址 必填
  2979. inputData["emp_tel"] = "" // 单位电话 必填
  2980. inputData["poscode"] = "" // 邮编 必填
  2981. inputData["coner_name"] = struct4101.ConerName // 联系人姓名 必填
  2982. inputData["patn_rlts"] = struct4101.PatnRlts // 与患者关系 必填
  2983. inputData["coner_addr"] = struct4101.ConerAddr // 联系人地址 必填
  2984. inputData["coner_tel"] = struct4101.ConerTel // 联系人电话 必填
  2985. inputData["hi_type"] = struct4101.HiType // 医保类型 必填
  2986. inputData["insuplc"] = struct4101.Insuplc // 参保地 必填
  2987. inputData["sp_psn_type"] = "" // 特殊人员类型 必填
  2988. inputData["nwb_adm_type"] = "" // 新生儿入院类型 必填
  2989. inputData["nwb_bir_wt"] = "" // 新生儿出生体重 必填
  2990. inputData["nwb_adm_wt"] = "" // 新生儿入院体重 必填
  2991. inputData["opsp_diag_caty"] = "" // 门诊慢特病诊断 必填
  2992. inputData["opsp_mdtrt_date"] = "" // 门诊慢特病就诊日期 必填
  2993. inputData["ipt_med_type"] = "" // 住院医疗类型 必填
  2994. inputData["adm_way"] = "2" // 入院途径 必填
  2995. inputData["trt_type"] = "1" // 治疗类别 必填
  2996. inputData["adm_time"] = struct4101.SetlEndDate // 入院时间 必填
  2997. inputData["adm_caty"] = "A03.06" // 入院科别 必填
  2998. inputData["refldept_dept"] = "" // 转科科别 必填
  2999. inputData["dscg_time"] = struct4101.SetlBegnDate // 出院时间 必填
  3000. inputData["dscg_caty"] = "A03.06" // 出院科别 必填
  3001. inputData["caty"] = "A03.06" // 出院科别 必填
  3002. inputData["act_ipt_days"] = "" // 实际住院天数 必填
  3003. inputData["otp_wm_dise"] = "" // 门(急) 诊西医诊断 必填
  3004. inputData["wm_dise_code"] = "" // 门(急) 诊中医诊断 必填
  3005. inputData["otp_tcm_dise"] = "" // 西医诊断疾病代码 必填
  3006. inputData["tcm_dise_code"] = "" // 中医诊断代码 必填
  3007. inputData["oprn_oprt_code_cnt"] = "" // 手术操作代码计数 必填
  3008. inputData["vent_used_dura"] = "" // 呼吸机使用时长 必填
  3009. inputData["pwcry_bfadm_coma_dura"] = "" // 颅脑损伤患者入院前昏迷时长 必填
  3010. inputData["pwcry_afadm_coma_dura"] = "" // 颅脑损伤患者入院后昏迷时长 必填
  3011. inputData["bld_cat"] = "" // 输血品种 必填
  3012. inputData["bld_amt"] = "" // 输血量 必填
  3013. inputData["bld_unt"] = "" // 输血计量单位 必填
  3014. inputData["spga_nurscare_days"] = "" // 特级护理天数 必填
  3015. inputData["lv1_nurscare_days"] = "" // 一级护理天数 必填
  3016. inputData["scd_nurscare_days"] = "" // 二级护理天数 必填
  3017. inputData["lv3_nurscare_days"] = "" // 三级护理天数 必填
  3018. inputData["acp_medins_name"] = "" // 拟接收机构名称 必填
  3019. inputData["acp_optins_code"] = "" // 拟接收机构代码 必填
  3020. inputData["bill_code"] = struct4101.BillCode // 票据代码 必填
  3021. inputData["bill_no"] = struct4101.BillNo // 票据号码 必填
  3022. inputData["biz_sn"] = struct4101.BizSn // 业务流水号 必填
  3023. inputData["days_rinp_flag_31"] = "1" // 出院 31 天内再住院计划标志 必填
  3024. inputData["days_rinp_pup_31"] = "1" // 出院 31 天内再住院目的 必填
  3025. inputData["chfpdr_name"] = struct4101.DoctorName // 主诊医师姓名 必填
  3026. inputData["chfpdr_code"] = struct4101.DoctorCode // 主诊医师代码 必填
  3027. inputData["setl_begn_date"] = struct4101.SetlBegnDate // 结算开始日期 必填
  3028. inputData["setl_end_date"] = struct4101.SetlEndDate // 结算结束日期 必填
  3029. inputData["psn_selfpay"] = struct4101.PsnSelfPay // 个人自付 必填
  3030. inputData["psn_ownpay"] = struct4101.PsnOwnPay // 个人自费 必填
  3031. inputData["acct_pay"] = struct4101.AcctPay // 个人账户支出 必填
  3032. inputData["hi_paymtd"] = struct4101.HiPaymtd // 医保支付方式 必填
  3033. inputData["hsorg"] = struct4101.Hsorg // 医保机构 必填
  3034. inputData["hsorg_opter"] = struct4101.HsorgOpter // 医保机构经办人 必填
  3035. inputData["medins_fill_dept"] = struct4101.MedinsFillDept // 医疗机构填报部门 必填
  3036. inputData["medins_fill_psn"] = struct4101.MedinsFillPsn // 医疗机构填报人 必填
  3037. inputData["psn_cashpay"] = struct4101.PsnCashpay // 医疗机构填报人 必填
  3038. inputData["resp_nurs_code"] = "N440307016120" // 民族 必填
  3039. payinfo := make([]map[string]interface{}, 0) // 基金支付信息
  3040. for _, item := range struct4101.CustomStruct {
  3041. payinfotemp := make(map[string]interface{})
  3042. 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" {
  3043. payinfotemp["fund_pay_type"] = item.FundPayType // 基金支付类型 必填
  3044. payinfotemp["fund_payamt"] = item.FundPayamt // 基金支付金额
  3045. payinfo = append(payinfo, payinfotemp)
  3046. }
  3047. }
  3048. opspdiseinfo := make([]map[string]interface{}, 0) // 门诊慢特病诊断信息
  3049. opspdiseinfotemp := make(map[string]interface{})
  3050. opspdiseinfotemp["diag_name"] = "慢性肾功能不全(血透治疗)" // 诊断名称 必填
  3051. opspdiseinfotemp["diag_code"] = "N18.904" // 诊断代码 必填
  3052. opspdiseinfotemp["oprn_oprt_name"] = "血液透析" // 手术操作名称 必填
  3053. opspdiseinfotemp["oprn_oprt_code"] = "39.9500" // 手术操作代码 必填
  3054. opspdiseinfo = append(opspdiseinfo, opspdiseinfotemp)
  3055. diseinfo := make([]map[string]interface{}, 0) // 住院诊断信息
  3056. for _, item := range struct4101.Diseinfo {
  3057. diseinfotemp := make(map[string]interface{})
  3058. diseinfotemp["maindiag_flag"] = item.MaindiagFlag // 手术操作代码 必填
  3059. diseinfotemp["diag_type"] = item.DiagType // 诊断类别 必填
  3060. diseinfotemp["diag_code"] = item.DiagCode // 诊断代码 必填
  3061. diseinfotemp["diag_name"] = item.DiagName // 诊断名称 必填
  3062. diseinfotemp["adm_cond_type"] = "3" // 入院病情类型 必填
  3063. diseinfo = append(diseinfo, diseinfotemp)
  3064. }
  3065. oprninfo := make([]map[string]interface{}, 0) // 手术操作信息
  3066. oprninfotemp := make(map[string]interface{})
  3067. oprninfotemp["oprn_oprt_type"] = "" // 手术操作类别 必填
  3068. oprninfotemp["oprn_oprt_name"] = "" // 手术操作名称 必填
  3069. oprninfotemp["oprn_oprt_code"] = "" // 手术操作代码 必填
  3070. oprninfotemp["oprn_oprt_date"] = "" // 手术操作日期 必填
  3071. oprninfotemp["anst_way"] = "" // 麻醉方式 必填
  3072. oprninfotemp["oper_dr_name"] = "" // 术者医师姓名 必填
  3073. oprninfotemp["oper_dr_code"] = "" // 术者医师代码 必填
  3074. oprninfotemp["anst_dr_name"] = "" // 麻醉医师姓名 必填
  3075. oprninfotemp["anst_dr_code"] = "" // 麻醉医师代码 必填
  3076. oprninfo = append(oprninfo, oprninfotemp)
  3077. icuinfo := make([]map[string]interface{}, 0) // 重症监护信息
  3078. icuinfotemp := make(map[string]interface{})
  3079. icuinfotemp["scs_cutd_ward_type"] = "" // 重症监护病房类型 必填
  3080. icuinfotemp["scs_cutd_inpool_time"] = "" // 重症监护进入时间 必填
  3081. icuinfotemp["scs_cutd_exit_time"] = "" // 重症监护退出时间 必填
  3082. icuinfotemp["scs_cutd_sum_dura"] = "" // 重症监护合计时长 必填
  3083. icuinfo = append(icuinfo, icuinfotemp)
  3084. input["setlinfo"] = inputData
  3085. input["payinfo"] = payinfo
  3086. //input["opspdiseinfo"] = opspdiseinfo
  3087. input["diseinfo"] = diseinfo
  3088. inputMessage["input"] = input //交易输入
  3089. bytesData, err := json.Marshal(inputMessage)
  3090. fmt.Println(string(bytesData))
  3091. if err != nil {
  3092. fmt.Println(err.Error())
  3093. return err.Error(), ""
  3094. }
  3095. reader := bytes.NewReader(bytesData)
  3096. gdyb_url := beego.AppConfig.String("gdyb_url")
  3097. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3098. //url := gdyb_url + "4101"
  3099. var url string
  3100. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  3101. url = gdyb_url
  3102. //inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs,doctor)
  3103. } else {
  3104. //inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3105. url = gdyb_url + "4101A"
  3106. }
  3107. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/4101"
  3108. request, err := http.NewRequest("POST", url, reader)
  3109. if err != nil {
  3110. fmt.Println(err.Error())
  3111. return err.Error(), ""
  3112. }
  3113. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3114. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3115. request.Header.Set("x-tif-signature", signature)
  3116. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3117. request.Header.Set("x-tif-nonce", nonce)
  3118. client := http.Client{}
  3119. resp, err := client.Do(request)
  3120. if err != nil {
  3121. fmt.Println(err.Error())
  3122. return err.Error(), ""
  3123. }
  3124. respBytes, err := ioutil.ReadAll(resp.Body)
  3125. if err != nil {
  3126. fmt.Println(err.Error())
  3127. return err.Error(), ""
  3128. }
  3129. str := string(respBytes)
  3130. fmt.Println(str)
  3131. return str, string(bytesData)
  3132. }
  3133. func Gdyb4101fornm(struct4101 Struct4101, secret_key string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, org_id int64, admin_user_id int64) (string, string) {
  3134. // 生成签名
  3135. nonce := GetRandomString(32)
  3136. timestamp := time.Now().Unix()
  3137. signature := setSignature(timestamp, nonce, secret_key)
  3138. inputMessage := make(map[string]interface{})
  3139. //tempTime := time.Unix(timestamp, 0)
  3140. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  3141. // 生成输入报文
  3142. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  3143. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  3144. } else {
  3145. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3146. }
  3147. // 生成输入报文
  3148. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3149. input := make(map[string]interface{})
  3150. inputData := make(map[string]interface{})
  3151. if org_id == 10106 || org_id == 10215 || org_id == 10138 || org_id == 9504 {
  3152. inputMessage["infno"] = "4101A" // 交易编码
  3153. } else {
  3154. inputMessage["infno"] = "4101A" // 交易编码
  3155. }
  3156. year := time.Now().Format("2006")
  3157. month := time.Now().Format("01")
  3158. day := time.Now().Format("02")
  3159. inputData["mdtrt_id"] = struct4101.MdtrtId // 就诊 ID 必填(来自2201接口返回)
  3160. inputData["setl_id"] = struct4101.SetlId // 结算 ID 必填
  3161. inputData["psn_no"] = struct4101.PsnNo // 结算 ID 必填
  3162. inputData["fixmedins_name"] = org_name // 定点医药机构名称 必填
  3163. inputData["fixmedins_code"] = fixmedins_code // 定点医药机构编码 必填
  3164. inputData["hi_setl_lv"] = "" // 医保结算等级
  3165. inputData["hi_no"] = struct4101.PsnNo // 医保编号
  3166. inputData["medcasno"] = struct4101.PsnNo // 病案号 必填
  3167. inputData["dcla_time"] = year + "-" + month + "-" + day // 申报时间 必填
  3168. inputData["psn_name"] = struct4101.PsnName // 人员姓名 必填
  3169. inputData["gend"] = struct4101.Gend // 性别 必填
  3170. inputData["brdy"] = struct4101.Brdy // 出生日期 必填
  3171. inputData["age"] = struct4101.Age // 年龄 必填
  3172. inputData["ntly"] = struct4101.Ntly // 国籍 必填
  3173. inputData["nwb_age"] = "" // 年龄 必填
  3174. inputData["naty"] = struct4101.Naty // 民族 必填
  3175. //inputData["dscg_way"] = "9" // 民族 必填
  3176. //inputData["resp_nurs_code"] = "N441623001432" // 民族 必填
  3177. inputData["patn_cert_type"] = struct4101.PatnCertType // 患者证件类别 必填
  3178. inputData["certno"] = struct4101.Certno // 证件号码 必填
  3179. inputData["prfs"] = struct4101.Prfs // 职业 必填
  3180. inputData["curr_addr"] = "" // 现住址 必填
  3181. inputData["emp_name"] = "" // 单位名称 必填
  3182. inputData["emp_addr"] = "" // 单位地址 必填
  3183. inputData["emp_tel"] = "" // 单位电话 必填
  3184. inputData["poscode"] = "" // 邮编 必填
  3185. inputData["coner_name"] = struct4101.ConerName // 联系人姓名 必填
  3186. inputData["patn_rlts"] = struct4101.PatnRlts // 与患者关系 必填
  3187. inputData["coner_addr"] = struct4101.ConerAddr // 联系人地址 必填
  3188. inputData["coner_tel"] = struct4101.ConerTel // 联系人电话 必填
  3189. inputData["hi_type"] = struct4101.HiType // 医保类型 必填
  3190. inputData["insuplc"] = struct4101.Insuplc // 参保地 必填
  3191. inputData["sp_psn_type"] = "" // 特殊人员类型 必填
  3192. inputData["nwb_adm_type"] = "" // 新生儿入院类型 必填
  3193. inputData["nwb_bir_wt"] = "" // 新生儿出生体重 必填
  3194. inputData["nwb_adm_wt"] = "" // 新生儿入院体重 必填
  3195. inputData["opsp_diag_caty"] = "" // 门诊慢特病诊断 必填
  3196. inputData["opsp_mdtrt_date"] = "" // 门诊慢特病就诊日期 必填
  3197. inputData["ipt_med_type"] = "" // 住院医疗类型 必填
  3198. inputData["adm_way"] = "" // 入院途径 必填
  3199. inputData["trt_type"] = "10" // 治疗类别 必填
  3200. inputData["adm_time"] = "" // 入院时间 必填
  3201. inputData["adm_caty"] = "A03.06" // 入院科别 必填
  3202. inputData["refldept_dept"] = "" // 转科科别 必填
  3203. inputData["dscg_time"] = "" // 出院时间 必填
  3204. inputData["dscg_caty"] = "A03.06" // 出院科别 必填
  3205. inputData["caty"] = "A03.06" // 出院科别 必填
  3206. inputData["act_ipt_days"] = "" // 实际住院天数 必填
  3207. inputData["otp_wm_dise"] = "" // 门(急) 诊西医诊断 必填
  3208. inputData["wm_dise_code"] = "" // 门(急) 诊中医诊断 必填
  3209. inputData["otp_tcm_dise"] = "" // 西医诊断疾病代码 必填
  3210. inputData["tcm_dise_code"] = "" // 中医诊断代码 必填
  3211. inputData["oprn_oprt_code_cnt"] = "" // 手术操作代码计数 必填
  3212. inputData["vent_used_dura"] = "" // 呼吸机使用时长 必填
  3213. inputData["pwcry_bfadm_coma_dura"] = "" // 颅脑损伤患者入院前昏迷时长 必填
  3214. inputData["pwcry_afadm_coma_dura"] = "" // 颅脑损伤患者入院后昏迷时长 必填
  3215. inputData["bld_cat"] = "" // 输血品种 必填
  3216. inputData["bld_amt"] = "" // 输血量 必填
  3217. inputData["bld_unt"] = "" // 输血计量单位 必填
  3218. inputData["spga_nurscare_days"] = "" // 特级护理天数 必填
  3219. inputData["lv1_nurscare_days"] = "" // 一级护理天数 必填
  3220. inputData["scd_nurscare_days"] = "" // 二级护理天数 必填
  3221. inputData["lv3_nurscare_days"] = "" // 三级护理天数 必填
  3222. inputData["acp_medins_name"] = "" // 拟接收机构名称 必填
  3223. inputData["acp_optins_code"] = "" // 拟接收机构代码 必填
  3224. inputData["bill_code"] = struct4101.BillCode // 票据代码 必填
  3225. inputData["bill_no"] = struct4101.BillNo // 票据号码 必填
  3226. inputData["biz_sn"] = struct4101.BizSn // 业务流水号 必填
  3227. inputData["days_rinp_flag_31"] = "" // 出院 31 天内再住院计划标志 必填
  3228. inputData["days_rinp_pup_31"] = "" // 出院 31 天内再住院目的 必填
  3229. inputData["chfpdr_name"] = struct4101.DoctorName // 主诊医师姓名 必填
  3230. inputData["chfpdr_code"] = struct4101.DoctorCode // 主诊医师代码 必填
  3231. inputData["setl_begn_date"] = struct4101.SetlBegnDate // 结算开始日期 必填
  3232. inputData["setl_end_date"] = struct4101.SetlEndDate // 结算结束日期 必填
  3233. inputData["psn_selfpay"] = struct4101.PsnSelfPay // 个人自付 必填
  3234. inputData["psn_ownpay"] = struct4101.PsnOwnPay // 个人自费 必填
  3235. inputData["acct_pay"] = struct4101.AcctPay // 个人账户支出 必填
  3236. inputData["hi_paymtd"] = struct4101.HiPaymtd // 医保支付方式 必填
  3237. inputData["hsorg"] = struct4101.Hsorg // 医保机构 必填
  3238. inputData["hsorg_opter"] = struct4101.HsorgOpter // 医保机构经办人 必填
  3239. inputData["medins_fill_dept"] = struct4101.MedinsFillDept // 医疗机构填报部门 必填
  3240. inputData["medins_fill_psn"] = struct4101.MedinsFillPsn // 医疗机构填报人 必填
  3241. inputData["psn_cashpay"] = struct4101.PsnCashpay // 医疗机构填报人 必填
  3242. inputData["dscg_way"] = "1" // 医疗机构填报人 必填
  3243. payinfo := make([]map[string]interface{}, 0) // 基金支付信息
  3244. for _, item := range struct4101.CustomStruct {
  3245. payinfotemp := make(map[string]interface{})
  3246. 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" {
  3247. payinfotemp["fund_pay_type"] = item.FundPayType // 基金支付类型 必填
  3248. payinfotemp["fund_payamt"] = item.FundPayamt // 基金支付金额
  3249. payinfo = append(payinfo, payinfotemp)
  3250. }
  3251. }
  3252. opspdiseinfo := make([]map[string]interface{}, 0) // 门诊慢特病诊断信息
  3253. opspdiseinfotemp := make(map[string]interface{})
  3254. opspdiseinfotemp["diag_name"] = "慢性肾功能不全(血透治疗)" // 诊断名称 必填
  3255. opspdiseinfotemp["diag_code"] = "N18.904" // 诊断代码 必填
  3256. opspdiseinfotemp["oprn_oprt_name"] = "血液透析" // 手术操作名称 必填
  3257. opspdiseinfotemp["oprn_oprt_code"] = "39.9500" // 手术操作代码 必填
  3258. opspdiseinfo = append(opspdiseinfo, opspdiseinfotemp)
  3259. diseinfo := make([]map[string]interface{}, 0) // 住院诊断信息
  3260. for _, item := range struct4101.Diseinfo {
  3261. diseinfotemp := make(map[string]interface{})
  3262. diseinfotemp["maindiag_flag"] = item.MaindiagFlag // 手术操作代码 必填
  3263. diseinfotemp["diag_type"] = item.DiagType // 诊断类别 必填
  3264. diseinfotemp["diag_code"] = item.DiagCode // 诊断代码 必填
  3265. diseinfotemp["diag_name"] = item.DiagName // 诊断名称 必填
  3266. diseinfotemp["adm_cond_type"] = "3" // 入院病情类型 必填
  3267. diseinfo = append(diseinfo, diseinfotemp)
  3268. }
  3269. oprninfo := make([]map[string]interface{}, 0) // 手术操作信息
  3270. oprninfotemp := make(map[string]interface{})
  3271. oprninfotemp["oprn_oprt_type"] = "" // 手术操作类别 必填
  3272. oprninfotemp["oprn_oprt_name"] = "" // 手术操作名称 必填
  3273. oprninfotemp["oprn_oprt_code"] = "" // 手术操作代码 必填
  3274. oprninfotemp["oprn_oprt_date"] = "" // 手术操作日期 必填
  3275. oprninfotemp["anst_way"] = "" // 麻醉方式 必填
  3276. oprninfotemp["oper_dr_name"] = "" // 术者医师姓名 必填
  3277. oprninfotemp["oper_dr_code"] = "" // 术者医师代码 必填
  3278. oprninfotemp["anst_dr_name"] = "" // 麻醉医师姓名 必填
  3279. oprninfotemp["anst_dr_code"] = "" // 麻醉医师代码 必填
  3280. oprninfo = append(oprninfo, oprninfotemp)
  3281. icuinfo := make([]map[string]interface{}, 0) // 重症监护信息
  3282. icuinfotemp := make(map[string]interface{})
  3283. icuinfotemp["scs_cutd_ward_type"] = "" // 重症监护病房类型 必填
  3284. icuinfotemp["scs_cutd_inpool_time"] = "" // 重症监护进入时间 必填
  3285. icuinfotemp["scs_cutd_exit_time"] = "" // 重症监护退出时间 必填
  3286. icuinfotemp["scs_cutd_sum_dura"] = "" // 重症监护合计时长 必填
  3287. icuinfo = append(icuinfo, icuinfotemp)
  3288. input["setlinfo"] = inputData
  3289. input["payinfo"] = payinfo
  3290. input["opspdiseinfo"] = opspdiseinfo
  3291. input["diseinfo"] = diseinfo
  3292. inputMessage["input"] = input //交易输入
  3293. bytesData, err := json.Marshal(inputMessage)
  3294. fmt.Println(string(bytesData))
  3295. if err != nil {
  3296. fmt.Println(err.Error())
  3297. return err.Error(), ""
  3298. }
  3299. reader := bytes.NewReader(bytesData)
  3300. gdyb_url := beego.AppConfig.String("gdyb_url")
  3301. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3302. //url := gdyb_url + "4101"
  3303. var url string
  3304. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  3305. url = gdyb_url
  3306. //inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs,doctor)
  3307. } else {
  3308. //inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3309. url = gdyb_url
  3310. }
  3311. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/4101"
  3312. request, err := http.NewRequest("POST", url, reader)
  3313. if err != nil {
  3314. fmt.Println(err.Error())
  3315. return err.Error(), ""
  3316. }
  3317. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3318. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3319. request.Header.Set("x-tif-signature", signature)
  3320. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3321. request.Header.Set("x-tif-nonce", nonce)
  3322. client := http.Client{}
  3323. resp, err := client.Do(request)
  3324. if err != nil {
  3325. fmt.Println(err.Error())
  3326. return err.Error(), ""
  3327. }
  3328. respBytes, err := ioutil.ReadAll(resp.Body)
  3329. if err != nil {
  3330. fmt.Println(err.Error())
  3331. return err.Error(), ""
  3332. }
  3333. str := string(respBytes)
  3334. fmt.Println(str)
  3335. return str, string(bytesData)
  3336. }
  3337. 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) {
  3338. // 生成签名
  3339. nonce := GetRandomString(32)
  3340. timestamp := time.Now().Unix()
  3341. signature := setSignature(timestamp, nonce, secret_key)
  3342. // 生成输入报文
  3343. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3344. input := make(map[string]interface{})
  3345. inputData := make(map[string]interface{})
  3346. inputMessage["infno"] = "4101A" // 交易编码
  3347. year := time.Now().Format("2006")
  3348. month := time.Now().Format("01")
  3349. day := time.Now().Format("02")
  3350. inputData["mdtrt_id"] = struct4101.MdtrtId // 就诊 ID 必填(来自2201接口返回)
  3351. inputData["setl_id"] = struct4101.SetlId // 结算 ID 必填
  3352. inputData["psn_no"] = struct4101.PsnNo // 结算 ID 必填
  3353. inputData["fixmedins_name"] = org_name // 定点医药机构名称 必填
  3354. inputData["fixmedins_code"] = fixmedins_code // 定点医药机构编码 必填
  3355. inputData["hi_setl_lv"] = "" // 医保结算等级
  3356. inputData["hi_no"] = struct4101.PsnNo // 医保编号
  3357. inputData["medcasno"] = struct4101.PsnNo // 病案号 必填
  3358. inputData["dcla_time"] = year + "-" + month + "-" + day // 申报时间 必填
  3359. inputData["psn_name"] = struct4101.PsnName // 人员姓名 必填
  3360. inputData["gend"] = struct4101.Gend // 性别 必填
  3361. inputData["brdy"] = struct4101.Brdy // 出生日期 必填
  3362. inputData["age"] = struct4101.Age // 年龄 必填
  3363. inputData["ntly"] = struct4101.Ntly // 国籍 必填
  3364. inputData["nwb_age"] = "" // 年龄 必填
  3365. inputData["naty"] = struct4101.Naty // 民族 必填
  3366. inputData["patn_cert_type"] = struct4101.PatnCertType // 患者证件类别 必填
  3367. inputData["certno"] = struct4101.Certno // 证件号码 必填
  3368. inputData["prfs"] = struct4101.Prfs // 职业 必填
  3369. inputData["curr_addr"] = "" // 现住址 必填
  3370. inputData["emp_name"] = "" // 单位名称 必填
  3371. inputData["emp_addr"] = "" // 单位地址 必填
  3372. inputData["emp_tel"] = "" // 单位电话 必填
  3373. inputData["poscode"] = "" // 邮编 必填
  3374. inputData["coner_name"] = struct4101.ConerName // 联系人姓名 必填
  3375. inputData["patn_rlts"] = struct4101.PatnRlts // 与患者关系 必填
  3376. inputData["coner_addr"] = struct4101.ConerAddr // 联系人地址 必填
  3377. inputData["coner_tel"] = struct4101.ConerTel // 联系人电话 必填
  3378. inputData["hi_type"] = struct4101.HiType // 医保类型 必填
  3379. inputData["insuplc"] = struct4101.Insuplc // 参保地 必填
  3380. inputData["sp_psn_type"] = "" // 特殊人员类型 必填
  3381. inputData["nwb_adm_type"] = "" // 新生儿入院类型 必填
  3382. inputData["nwb_bir_wt"] = "" // 新生儿出生体重 必填
  3383. inputData["nwb_adm_wt"] = "" // 新生儿入院体重 必填
  3384. inputData["opsp_diag_caty"] = "" // 门诊慢特病诊断 必填
  3385. inputData["opsp_mdtrt_date"] = "" // 门诊慢特病就诊日期 必填
  3386. inputData["ipt_med_type"] = "" // 住院医疗类型 必填
  3387. inputData["adm_way"] = "" // 入院途径 必填
  3388. inputData["trt_type"] = "10" // 治疗类别 必填
  3389. inputData["adm_time"] = struct4101.AdmTime // 入院时间 必填
  3390. inputData["adm_caty"] = struct4101.AdmCaty // 入院科别 必填
  3391. inputData["refldept_dept"] = "" // 转科科别 必填
  3392. inputData["dscg_time"] = struct4101.AdmEndTime // 出院时间 必填
  3393. inputData["dscg_caty"] = struct4101.DscgCaty // 出院科别 必填
  3394. inputData["act_ipt_days"] = "" // 实际住院天数 必填
  3395. inputData["otp_wm_dise"] = "" // 门(急) 诊西医诊断 必填
  3396. inputData["wm_dise_code"] = "" // 门(急) 诊中医诊断 必填
  3397. inputData["otp_tcm_dise"] = "" // 西医诊断疾病代码 必填
  3398. inputData["tcm_dise_code"] = "" // 中医诊断代码 必填
  3399. inputData["oprn_oprt_code_cnt"] = "" // 手术操作代码计数 必填
  3400. inputData["vent_used_dura"] = "" // 呼吸机使用时长 必填
  3401. inputData["pwcry_bfadm_coma_dura"] = "" // 颅脑损伤患者入院前昏迷时长 必填
  3402. inputData["pwcry_afadm_coma_dura"] = "" // 颅脑损伤患者入院后昏迷时长 必填
  3403. inputData["bld_cat"] = "" // 输血品种 必填
  3404. inputData["bld_amt"] = "" // 输血量 必填
  3405. inputData["bld_unt"] = "" // 输血计量单位 必填
  3406. inputData["spga_nurscare_days"] = "" // 特级护理天数 必填
  3407. inputData["lv1_nurscare_days"] = "" // 一级护理天数 必填
  3408. inputData["scd_nurscare_days"] = "" // 二级护理天数 必填
  3409. inputData["lv3_nurscare_days"] = "" // 三级护理天数 必填
  3410. inputData["acp_medins_name"] = "" // 拟接收机构名称 必填
  3411. inputData["acp_optins_code"] = "" // 拟接收机构代码 必填
  3412. inputData["bill_code"] = struct4101.BillCode // 票据代码 必填
  3413. inputData["bill_no"] = struct4101.BillNo // 票据号码 必填
  3414. inputData["biz_sn"] = struct4101.BizSn // 业务流水号 必填
  3415. inputData["days_rinp_flag_31"] = "" // 出院 31 天内再住院计划标志 必填
  3416. inputData["days_rinp_pup_31"] = "" // 出院 31 天内再住院目的 必填
  3417. inputData["chfpdr_name"] = struct4101.DoctorName // 主诊医师姓名 必填
  3418. inputData["chfpdr_code"] = struct4101.DoctorCode // 主诊医师代码 必填
  3419. inputData["setl_begn_date"] = struct4101.SetlBegnDate // 结算开始日期 必填
  3420. inputData["setl_end_date"] = struct4101.SetlEndDate // 结算结束日期 必填
  3421. inputData["psn_selfpay"] = struct4101.PsnSelfPay // 个人自付 必填
  3422. inputData["psn_ownpay"] = struct4101.PsnOwnPay // 个人自费 必填
  3423. inputData["acct_pay"] = struct4101.AcctPay // 个人账户支出 必填
  3424. inputData["hi_paymtd"] = struct4101.HiPaymtd // 医保支付方式 必填
  3425. inputData["hsorg"] = struct4101.Hsorg // 医保机构 必填
  3426. inputData["hsorg_opter"] = struct4101.HsorgOpter // 医保机构经办人 必填
  3427. inputData["medins_fill_dept"] = struct4101.MedinsFillDept // 医疗机构填报部门 必填
  3428. inputData["medins_fill_psn"] = struct4101.MedinsFillPsn // 医疗机构填报人 必填
  3429. inputData["psn_cashpay"] = struct4101.PsnCashpay // 医疗机构填报人 必填
  3430. payinfo := make([]map[string]interface{}, 0) // 基金支付信息
  3431. for _, item := range struct4101.CustomStruct {
  3432. payinfotemp := make(map[string]interface{})
  3433. 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" {
  3434. payinfotemp["fund_pay_type"] = item.FundPayType // 基金支付类型 必填
  3435. payinfotemp["fund_payamt"] = item.FundPayamt // 基金支付金额
  3436. payinfo = append(payinfo, payinfotemp)
  3437. }
  3438. }
  3439. opspdiseinfo := make([]map[string]interface{}, 0) // 门诊慢特病诊断信息
  3440. opspdiseinfotemp := make(map[string]interface{})
  3441. opspdiseinfotemp["diag_name"] = struct4101.Diseinfo[len(struct4101.Diseinfo)-1].DiagName // 诊断名称 必填
  3442. opspdiseinfotemp["diag_code"] = struct4101.Diseinfo[len(struct4101.Diseinfo)-1].DiagCode // 诊断代码 必填
  3443. opspdiseinfotemp["oprn_oprt_name"] = "血液透析" // 手术操作名称 必填
  3444. opspdiseinfotemp["oprn_oprt_code"] = "39.9500" // 手术操作代码 必填
  3445. opspdiseinfo = append(opspdiseinfo, opspdiseinfotemp)
  3446. diseinfo := make([]map[string]interface{}, 0) // 住院诊断信息
  3447. for _, item := range struct4101.Diseinfo {
  3448. diseinfotemp := make(map[string]interface{})
  3449. diseinfotemp["maindiag_flag"] = item.MaindiagFlag // 手术操作代码 必填
  3450. diseinfotemp["diag_type"] = item.DiagType // 诊断类别 必填
  3451. diseinfotemp["diag_code"] = item.DiagCode // 诊断代码 必填
  3452. diseinfotemp["diag_name"] = item.DiagName // 诊断名称 必填
  3453. diseinfotemp["adm_cond_type"] = "3" // 入院病情类型 必填
  3454. diseinfo = append(diseinfo, diseinfotemp)
  3455. }
  3456. iteminfo := make([]map[string]interface{}, 0)
  3457. for _, item := range struct4101.IteminfoStruct {
  3458. iteminfotemp := make(map[string]interface{})
  3459. iteminfotemp["med_chrgitm"] = item.MedChrgitm // 医疗收费项目 必填
  3460. iteminfotemp["amt"] = item.Amt // 金额 必填
  3461. iteminfotemp["claa_sumfee"] = item.ClaaSumfee // 甲类费用合计 必填
  3462. iteminfotemp["clab_amt"] = item.ClabAmt // 乙类金额 必填
  3463. iteminfotemp["fulamt_ownpay_amt"] = item.FulamtOwnpayAmt // 全自费金额 必填
  3464. iteminfotemp["oth_amt"] = item.OthAmt // 其他金额 必填
  3465. iteminfo = append(iteminfo, iteminfotemp)
  3466. }
  3467. oprninfo := make([]map[string]interface{}, 0) // 手术操作信息
  3468. oprninfotemp := make(map[string]interface{})
  3469. oprninfotemp["oprn_oprt_type"] = "" // 手术操作类别 必填
  3470. oprninfotemp["oprn_oprt_name"] = "" // 手术操作名称 必填
  3471. oprninfotemp["oprn_oprt_code"] = "" // 手术操作代码 必填
  3472. oprninfotemp["oprn_oprt_date"] = "" // 手术操作日期 必填
  3473. oprninfotemp["anst_way"] = "" // 麻醉方式 必填
  3474. oprninfotemp["oper_dr_name"] = "" // 术者医师姓名 必填
  3475. oprninfotemp["oper_dr_code"] = "" // 术者医师代码 必填
  3476. oprninfotemp["anst_dr_name"] = "" // 麻醉医师姓名 必填
  3477. oprninfotemp["anst_dr_code"] = "" // 麻醉医师代码 必填
  3478. oprninfo = append(oprninfo, oprninfotemp)
  3479. icuinfo := make([]map[string]interface{}, 0) // 重症监护信息
  3480. icuinfotemp := make(map[string]interface{})
  3481. icuinfotemp["scs_cutd_ward_type"] = "" // 重症监护病房类型 必填
  3482. icuinfotemp["scs_cutd_inpool_time"] = "" // 重症监护进入时间 必填
  3483. icuinfotemp["scs_cutd_exit_time"] = "" // 重症监护退出时间 必填
  3484. icuinfotemp["scs_cutd_sum_dura"] = "" // 重症监护合计时长 必填
  3485. icuinfo = append(icuinfo, icuinfotemp)
  3486. input["setlinfo"] = inputData
  3487. input["payinfo"] = payinfo
  3488. input["opspdiseinfo"] = opspdiseinfo
  3489. input["diseinfo"] = diseinfo
  3490. input["iteminfo"] = iteminfo
  3491. inputMessage["input"] = input //交易输入
  3492. bytesData, err := json.Marshal(inputMessage)
  3493. fmt.Println(string(bytesData))
  3494. if err != nil {
  3495. fmt.Println(err.Error())
  3496. return err.Error(), ""
  3497. }
  3498. reader := bytes.NewReader(bytesData)
  3499. gdyb_url := beego.AppConfig.String("gdyb_url")
  3500. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3501. //url := gdyb_url + "4101"
  3502. var url string
  3503. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  3504. url = gdyb_url
  3505. } else {
  3506. url = gdyb_url + "4101A"
  3507. }
  3508. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/4101"
  3509. request, err := http.NewRequest("POST", url, reader)
  3510. if err != nil {
  3511. fmt.Println(err.Error())
  3512. return err.Error(), ""
  3513. }
  3514. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3515. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3516. request.Header.Set("x-tif-signature", signature)
  3517. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3518. request.Header.Set("x-tif-nonce", nonce)
  3519. client := http.Client{}
  3520. resp, err := client.Do(request)
  3521. if err != nil {
  3522. fmt.Println(err.Error())
  3523. return err.Error(), ""
  3524. }
  3525. respBytes, err := ioutil.ReadAll(resp.Body)
  3526. if err != nil {
  3527. fmt.Println(err.Error())
  3528. return err.Error(), ""
  3529. }
  3530. str := string(respBytes)
  3531. fmt.Println(str)
  3532. return str, string(bytesData)
  3533. }
  3534. func Gdyb4101For10138(struct4101 Struct4101, secret_key string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, org_id int64) (string, string) {
  3535. // 生成签名
  3536. nonce := GetRandomString(32)
  3537. timestamp := time.Now().Unix()
  3538. signature := setSignature(timestamp, nonce, secret_key)
  3539. // 生成输入报文
  3540. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3541. input := make(map[string]interface{})
  3542. inputData := make(map[string]interface{})
  3543. inputMessage["infno"] = "4101A" // 交易编码
  3544. year := time.Now().Format("2006")
  3545. month := time.Now().Format("01")
  3546. day := time.Now().Format("02")
  3547. inputData["psn_no"] = struct4101.PsnNo // 结算 ID 必填
  3548. inputData["mdtrt_id"] = struct4101.MdtrtId // 就诊 ID 必填(来自2201接口返回)
  3549. inputData["setl_id"] = struct4101.SetlId // 结算 ID 必填
  3550. inputData["hi_no"] = struct4101.PsnNo // 医保编号
  3551. inputData["medcasno"] = struct4101.PsnNo // 病案号 必填
  3552. inputData["dcla_time"] = year + "-" + month + "-" + day // 申报时间 必填
  3553. inputData["ntly"] = struct4101.Ntly // 国籍 必填
  3554. inputData["prfs"] = struct4101.Prfs // 职业 必填
  3555. inputData["curr_addr"] = struct4101.CurAddr // 现住址 必填
  3556. inputData["emp_name"] = "" // 单位名称 必填
  3557. inputData["emp_addr"] = "" // 单位地址 必填
  3558. inputData["emp_tel"] = ""
  3559. inputData["poscode"] = "" // 邮编 必填
  3560. inputData["coner_name"] = "" // 联系人姓名 必填
  3561. inputData["patn_rlts"] = "" // 与患者关系 必填
  3562. inputData["coner_addr"] = "" // 联系人地址 必填
  3563. inputData["coner_tel"] = ""
  3564. inputData["nwb_adm_type"] = "" // 新生儿入院类型 必填
  3565. inputData["nwb_bir_wt"] = "" // 新生儿出生体重 必填
  3566. inputData["nwb_adm_wt"] = "" // 新生儿入院体重 必填
  3567. inputData["mul_nwb_bir_wt"] = "" // 新生儿入院体重 必填
  3568. inputData["mul_nwb_adm_wt"] = "" // 新生儿入院体重 必填
  3569. inputData["opsp_diag_caty"] = "" // 门诊慢特病诊断 必填
  3570. inputData["opsp_mdtrt_date"] = "" // 门诊慢特病就诊日期 必填
  3571. inputData["adm_way"] = "" // 入院途径 必填
  3572. inputData["trt_type"] = "" // 治疗类别 必填
  3573. inputData["adm_time"] = "" // 入院时间 必填
  3574. inputData["refldept_dept"] = "" // 转科科别 必填
  3575. inputData["dscg_time"] = "" // 出院时间 必填
  3576. inputData["dscg_caty"] = "" // 出院科别 必填
  3577. inputData["otp_wm_dise"] = "" // 门(急) 诊西医诊断 必填
  3578. inputData["wm_dise_code"] = "" // 门(急) 诊中医诊断 必填
  3579. inputData["otp_tcm_dise"] = "" // 西医诊断疾病代码 必填
  3580. inputData["tcm_dise_code"] = "" // 中医诊断代码 必填
  3581. inputData["vent_used_dura"] = "" // 呼吸机使用时长 必填
  3582. inputData["pwcry_bfadm_coma_dura"] = "" // 颅脑损伤患者入院前昏迷时长 必填
  3583. inputData["pwcry_afadm_coma_dura"] = "" // 颅脑损伤患者入院后昏迷时长 必填
  3584. inputData["spga_nurscare_days"] = "" // 特级护理天数 必填
  3585. inputData["hsorg"] = struct4101.Hsorg // 医保机构 必填
  3586. inputData["hsorg_opter"] = struct4101.HsorgOpter // 医保机构经办人 必填
  3587. inputData["lv1_nurscare_days"] = "" // 一级护理天数 必填
  3588. inputData["scd_nurscare_days"] = "" // 二级护理天数 必填
  3589. inputData["lv3_nurscare_days"] = "" // 三级护理天数 必填
  3590. inputData["acp_medins_name"] = "" // 拟接收机构名称 必填
  3591. inputData["acp_optins_code"] = "" // 拟接收机构代码 必填
  3592. inputData["bill_code"] = struct4101.BillCode // 票据代码 必填
  3593. inputData["bill_no"] = struct4101.BillNo // 票据号码 必填
  3594. inputData["biz_sn"] = struct4101.BizSn // 业务流水号 必填
  3595. inputData["hi_paymtd"] = "1" // 业务流水号 必填
  3596. inputData["days_rinp_flag_31"] = "" // 出院 31 天内再住院计划标志 必填
  3597. inputData["days_rinp_pup_31"] = "" // 出院 31 天内再住院目的 必填
  3598. //inputData["chfpdr_name"] = struct4101.DoctorName // 主诊医师姓名 必填
  3599. //inputData["chfpdr_code"] = struct4101.DoctorCode // 主诊医师代码 必填
  3600. inputData["setl_begn_date"] = struct4101.SetlBegnDate // 结算开始日期 必填
  3601. inputData["setl_end_date"] = struct4101.SetlEndDate // 结算结束日期 必填
  3602. inputData["medins_fill_dept"] = org_name // 医疗机构填报部门 必填
  3603. inputData["medins_fill_psn"] = struct4101.MedinsFillPsn // 医疗机构填报人 必填
  3604. //payinfo := make([]map[string]interface{}, 0) // 基金支付信息
  3605. //for _, item := range struct4101.CustomStruct {
  3606. // payinfotemp := make(map[string]interface{})
  3607. // 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" {
  3608. // payinfotemp["fund_pay_type"] = item.FundPayType // 基金支付类型 必填
  3609. // payinfotemp["fund_payamt"] = item.FundPayamt // 基金支付金额
  3610. // payinfo = append(payinfo, payinfotemp)
  3611. // }
  3612. //}
  3613. opspdiseinfo := make([]map[string]interface{}, 0) // 门诊慢特病诊断信息
  3614. opspdiseinfotemp := make(map[string]interface{})
  3615. opspdiseinfotemp["diag_name"] = "慢性肾脏病5期" // 诊断名称 必填
  3616. opspdiseinfotemp["diag_code"] = "N18.500" // 诊断代码 必填
  3617. opspdiseinfotemp["oprn_oprt_name"] = "血液透析" // 手术操作名称 必填
  3618. opspdiseinfotemp["oprn_oprt_code"] = "39.9500" // 手术操作代码 必填
  3619. opspdiseinfo = append(opspdiseinfo, opspdiseinfotemp)
  3620. diseinfo := make([]map[string]interface{}, 0) // 住院诊断信息
  3621. for _, item := range struct4101.Diseinfo {
  3622. diseinfotemp := make(map[string]interface{})
  3623. diseinfotemp["maindiag_flag"] = item.MaindiagFlag // 手术操作代码 必填
  3624. diseinfotemp["diag_type"] = item.DiagType // 诊断类别 必填
  3625. diseinfotemp["diag_code"] = item.DiagCode // 诊断代码 必填
  3626. diseinfotemp["diag_name"] = item.DiagName // 诊断名称 必填
  3627. diseinfotemp["adm_cond_type"] = "3" // 入院病情类型 必填
  3628. diseinfo = append(diseinfo, diseinfotemp)
  3629. }
  3630. //iteminfo := make([]map[string]interface{}, 0)
  3631. //for _, item := range struct4101.IteminfoStruct {
  3632. // iteminfotemp := make(map[string]interface{})
  3633. // iteminfotemp["med_chrgitm"] = item.MedChrgitm // 医疗收费项目 必填
  3634. // iteminfotemp["amt"] = item.Amt // 金额 必填
  3635. // iteminfotemp["claa_sumfee"] = item.ClaaSumfee // 甲类费用合计 必填
  3636. // iteminfotemp["clab_amt"] = item.ClabAmt // 乙类金额 必填
  3637. // iteminfotemp["fulamt_ownpay_amt"] = item.FulamtOwnpayAmt // 全自费金额 必填
  3638. // iteminfotemp["oth_amt"] = item.OthAmt // 其他金额 必填
  3639. // iteminfo = append(iteminfo, iteminfotemp)
  3640. //}
  3641. oprninfo := make([]map[string]interface{}, 0) // 手术操作信息
  3642. oprninfotemp := make(map[string]interface{})
  3643. oprninfotemp["oprn_oprt_type"] = "" // 手术操作类别 必填
  3644. oprninfotemp["oprn_oprt_name"] = "" // 手术操作名称 必填
  3645. oprninfotemp["oprn_oprt_code"] = "" // 手术操作代码 必填
  3646. oprninfotemp["oprn_oprt_date"] = "" // 手术操作日期 必填
  3647. oprninfotemp["anst_way"] = "" // 麻醉方式 必填
  3648. oprninfotemp["oper_dr_name"] = "" // 术者医师姓名 必填
  3649. oprninfotemp["oper_dr_code"] = "" // 术者医师代码 必填
  3650. oprninfotemp["anst_dr_name"] = "" // 麻醉医师姓名 必填
  3651. oprninfotemp["anst_dr_code"] = "" // 麻醉医师代码 必填
  3652. oprninfo = append(oprninfo, oprninfotemp)
  3653. icuinfo := make([]map[string]interface{}, 0) // 重症监护信息
  3654. icuinfotemp := make(map[string]interface{})
  3655. icuinfotemp["scs_cutd_ward_type"] = "" // 重症监护病房类型 必填
  3656. icuinfotemp["scs_cutd_inpool_time"] = "" // 重症监护进入时间 必填
  3657. icuinfotemp["scs_cutd_exit_time"] = "" // 重症监护退出时间 必填
  3658. icuinfotemp["scs_cutd_sum_dura"] = "" // 重症监护合计时长 必填
  3659. icuinfo = append(icuinfo, icuinfotemp)
  3660. input["setlinfo"] = inputData
  3661. input["opspdiseinfo"] = opspdiseinfo
  3662. //input["diseinfo"] = diseinfo
  3663. //input["oprninfo"] = payinfo
  3664. //input["icuinfo"] = payinfo
  3665. //input["bldinfo"] = payinfo
  3666. inputMessage["input"] = input //交易输入
  3667. bytesData, err := json.Marshal(inputMessage)
  3668. fmt.Println(string(bytesData))
  3669. if err != nil {
  3670. fmt.Println(err.Error())
  3671. return err.Error(), ""
  3672. }
  3673. reader := bytes.NewReader(bytesData)
  3674. gdyb_url := beego.AppConfig.String("gdyb_url")
  3675. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3676. //url := gdyb_url + "4101"
  3677. var url string
  3678. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  3679. url = gdyb_url
  3680. } else {
  3681. url = gdyb_url + "4101A"
  3682. }
  3683. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/4101"
  3684. request, err := http.NewRequest("POST", url, reader)
  3685. if err != nil {
  3686. fmt.Println(err.Error())
  3687. return err.Error(), ""
  3688. }
  3689. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3690. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3691. request.Header.Set("x-tif-signature", signature)
  3692. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3693. request.Header.Set("x-tif-nonce", nonce)
  3694. client := http.Client{}
  3695. resp, err := client.Do(request)
  3696. if err != nil {
  3697. fmt.Println(err.Error())
  3698. return err.Error(), ""
  3699. }
  3700. respBytes, err := ioutil.ReadAll(resp.Body)
  3701. if err != nil {
  3702. fmt.Println(err.Error())
  3703. return err.Error(), ""
  3704. }
  3705. str := string(respBytes)
  3706. fmt.Println(str)
  3707. return str, string(bytesData)
  3708. }
  3709. //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 {
  3710. // // 生成签名
  3711. // nonce := GetRandomString(32)
  3712. // timestamp := time.Now().Unix()
  3713. // signature := setSignature(timestamp, nonce, secret_key)
  3714. // tempTime := time.Unix(timestamp, 0)
  3715. // //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  3716. //
  3717. // timeFormatTwo := tempTime.Format("2006-01-02")
  3718. //
  3719. // t := time.Now()
  3720. // last := time.Date(t.Year(), time.December, 31, 0, 0, 0, 0, time.UTC)
  3721. // tm := time.Unix(last.Unix(), 0)
  3722. //
  3723. // // 生成输入报文
  3724. // inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3725. // input := make(map[string]interface{})
  3726. // inputData := make(map[string]interface{})
  3727. //
  3728. // inputData2 := make(map[string]interface{})
  3729. //
  3730. // inputMessage["infno"] = "7101" // 交易编码
  3731. // inputData["hosp_rxno"] = psnNo // 人员编号 (来自1101接口返回)
  3732. // inputData["init_rxno"] = insutype // 险种类型(来自1101接口返回)
  3733. // inputData["rx_type_code"] = sick_code // 险种类型(来自1101接口返回)
  3734. // inputData["prsc_time"] = sick_name // 险种类型(来自1101接口返回)
  3735. // inputData["rx_drug_nums"] = insuplc_admdvs // 险种类型(来自1101接口返回)
  3736. // inputData["rx_way_codg"] = fixmedins_code // 险种类型(来自1101接口返回)
  3737. // inputData["rx_way_name"] = org_name // 险种类型(来自1101接口返回)
  3738. // inputData["rx_freq_codg"] = timeFormatTwo // 险种类型(来自1101接口返回)
  3739. // inputData["rx_freq_name"] = doctor_id // 开始时间
  3740. // inputData["rx_dosunt"] = doctor // 开始时间
  3741. // inputData["rx_doscnt"] = timeFormatTwo // 医师编码
  3742. // inputData["rx_drord_dscr"] = "" // 医师编码
  3743. // inputData["valid_days"] = "" // 医师编码
  3744. // inputData["valid_end_time"] = tm.Format("2006-01-02") // 医师编码
  3745. // inputData["rept_flag"] = tm.Format("2006-01-02") // 医师编码
  3746. // inputData["max_rept_cnt"] = tm.Format("2006-01-02") // 医师编码
  3747. // inputData["reptd_cnt"] = tm.Format("2006-01-02") // 医师编码
  3748. // inputData["min_inrv_days"] = tm.Format("2006-01-02") // 医师编码
  3749. // inputData["dr_sign_info"] = tm.Format("2006-01-02") // 医师编码
  3750. // inputData["phar_sign_info"] = tm.Format("2006-01-02") // 医师编码
  3751. // inputData["fixmedins_sign_info"] = tm.Format("2006-01-02") // 医师编码
  3752. // inputData["rx_cotn_flag"] = tm.Format("2006-01-02") // 医师编码
  3753. // inputData["rx_file"] = tm.Format("2006-01-02") // 医师编码
  3754. // input["data"] = inputData
  3755. //
  3756. //
  3757. // inputData2["med_list_codg"] = psnNo // 人员编号 (来自1101接口返回)
  3758. // inputData2["fixmedins_hilist_id"] = insutype // 险种类型(来自1101接口返回)
  3759. // inputData["hosp_prep_flag"] = sick_code // 险种类型(来自1101接口返回)
  3760. // inputData["rx_item_type_code"] = sick_name // 险种类型(来自1101接口返回)
  3761. // inputData["rx_item_type_name"] = insuplc_admdvs // 险种类型(来自1101接口返回)
  3762. // inputData["tcmdrug_type_name"] = fixmedins_code // 险种类型(来自1101接口返回)
  3763. // inputData["tcmdrug_type_code"] = org_name // 险种类型(来自1101接口返回)
  3764. // inputData["tcmherb_foote"] = timeFormatTwo // 险种类型(来自1101接口返回)
  3765. // inputData["medn_type_code"] = doctor_id // 开始时间
  3766. // inputData["medn_type_name"] = doctor // 开始时间
  3767. // inputData["main_medc_flag"] = timeFormatTwo // 医师编码
  3768. // inputData["urgt_flag"] = "" // 医师编码
  3769. // inputData["bas_medn_flag"] = "" // 医师编码
  3770. // inputData["imp_drug_flag"] = tm.Format("2006-01-02") // 医师编码
  3771. // inputData["prod_barc"] = tm.Format("2006-01-02") // 医师编码
  3772. // inputData["drug_prodname"] = tm.Format("2006-01-02") // 医师编码
  3773. //
  3774. // inputData["genname_codg"] = tm.Format("2006-01-02") // 医师编码
  3775. // inputData["drug_genname"] = tm.Format("2006-01-02") // 医师编码
  3776. // inputData["chemname"] = tm.Format("2006-01-02") // 医师编码
  3777. //
  3778. // inputData["drugstdcode"] = tm.Format("2006-01-02") // 医师编码
  3779. // inputData["drug_dosform"] = tm.Format("2006-01-02") // 医师编码
  3780. //
  3781. //
  3782. // inputData["drug_spec"] = tm.Format("2006-01-02") // 医师编码
  3783. // inputData["prdr_name"] = tm.Format("2006-01-02") // 医师编码
  3784. //
  3785. //
  3786. // inputData["drug_pric"] = tm.Format("2006-01-02") // 医师编码
  3787. // inputData["drug_cnt"] = tm.Format("2006-01-02") // 医师编码
  3788. // inputData["drug_cnt_unit"] = tm.Format("2006-01-02") // 医师编码
  3789. // inputData["drug_sumamt"] = tm.Format("2006-01-02") // 医师编码
  3790. // inputData["medc_way_codg"] = tm.Format("2006-01-02") // 医师编码
  3791. // inputData["medc_way_dscr"] = tm.Format("2006-01-02") // 医师编码
  3792. // inputData["medc_starttime"] = tm.Format("2006-01-02") // 医师编码
  3793. //
  3794. // inputData["medc_endtime"] = tm.Format("2006-01-02") // 医师编码
  3795. //
  3796. //
  3797. // inputData["medc_days"] = tm.Format("2006-01-02") // 医师编码
  3798. // inputData["drug_dosunt"] = tm.Format("2006-01-02") // 医师编码
  3799. // inputData["sin_doscnt"] = tm.Format("2006-01-02") // 医师编码
  3800. // inputData["sin_dosunt"] = tm.Format("2006-01-02") // 医师编码
  3801. // inputData["used_frqu_codg"] = tm.Format("2006-01-02") // 医师编码
  3802. //
  3803. //
  3804. // inputData["used_frqu_name"] = tm.Format("2006-01-02") // 医师编码
  3805. // inputData["drug_totlnt"] = tm.Format("2006-01-02") // 医师编码
  3806. //
  3807. // inputData["drug_totlnt_emp"] = tm.Format("2006-01-02") // 医师编码
  3808. // inputData["dise_codg"] = tm.Format("2006-01-02") // 医师编码
  3809. // inputData["drug_res"] = tm.Format("2006-01-02") // 医师编码
  3810. // inputData["drug_limit"] = tm.Format("2006-01-02") // 医师编码
  3811. //
  3812. //
  3813. //
  3814. //
  3815. //
  3816. //
  3817. //
  3818. //
  3819. //
  3820. // input["rxdrugdetail"] = inputData2
  3821. //
  3822. //
  3823. //
  3824. //
  3825. // inputMessage["input"] = input //交易输入
  3826. // bytesData, err := json.Marshal(inputMessage)
  3827. // fmt.Println(string(bytesData))
  3828. // if err != nil {
  3829. // fmt.Println(err.Error())
  3830. // return err.Error()
  3831. // }
  3832. // reader := bytes.NewReader(bytesData)
  3833. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2503"
  3834. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2503"
  3835. // gdyb_url := beego.AppConfig.String("gdyb_url")
  3836. // gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3837. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  3838. // url := gdyb_url + "2503"
  3839. //
  3840. // request, err := http.NewRequest("POST", url, reader)
  3841. // if err != nil {
  3842. // fmt.Println(err.Error())
  3843. // return err.Error()
  3844. // }
  3845. //
  3846. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3847. // request.Header.Set("x-tif-paasid", gdyb_paasid)
  3848. // request.Header.Set("x-tif-signature", signature)
  3849. // request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3850. // request.Header.Set("x-tif-nonce", nonce)
  3851. //
  3852. // client := http.Client{}
  3853. // resp, err := client.Do(request)
  3854. // if err != nil {
  3855. // fmt.Println(err.Error())
  3856. // return err.Error()
  3857. // }
  3858. // respBytes, err := ioutil.ReadAll(resp.Body)
  3859. // if err != nil {
  3860. // fmt.Println(err.Error())
  3861. // return err.Error()
  3862. // }
  3863. // str := string(respBytes)
  3864. // fmt.Println(str)
  3865. // return str
  3866. //}
  3867. // 生成签名
  3868. func setSignature(timestamp int64, nonce string, secret_key string) string {
  3869. fmt.Println(timestamp)
  3870. fmt.Println(nonce)
  3871. fmt.Println(secret_key)
  3872. fmt.Println(strconv.FormatInt(timestamp, 10))
  3873. fmt.Println(time.Now().UnixNano() / 1e6)
  3874. str := strconv.FormatInt(timestamp, 10) + secret_key + nonce + strconv.FormatInt(timestamp, 10)
  3875. hash := sha256.New()
  3876. //输入数据
  3877. hash.Write([]byte(str))
  3878. //计算哈希值
  3879. bytes := hash.Sum(nil)
  3880. //将字符串编码为16进制格式,返回字符串
  3881. hashCode := hex.EncodeToString(bytes)
  3882. //返回哈希值
  3883. return hashCode
  3884. }
  3885. const charset = "abcdefghijklmnopqrstuvwxyz" +
  3886. "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
  3887. var seededRand *rand.Rand = rand.New(
  3888. rand.NewSource(time.Now().UnixNano()))
  3889. // 生成随机字符串
  3890. func GetRandomString(l int) string {
  3891. //str := "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
  3892. //bytes := []byte(str)
  3893. //result := []byte{}
  3894. //r := rand.New(rand.NewSource(time.Now().UnixNano()))
  3895. //for i := 0; i < l; i++ {
  3896. // result = append(result, bytes[r.Intn(len(bytes))])
  3897. //}
  3898. return String(32)
  3899. }
  3900. func StringWithCharset(length int, charset string) string {
  3901. b := make([]byte, length)
  3902. for i := range b {
  3903. b[i] = charset[seededRand.Intn(len(charset))]
  3904. }
  3905. return string(b)
  3906. }
  3907. func String(length int) string {
  3908. return StringWithCharset(length, charset)
  3909. }
  3910. // 生成基础报文
  3911. func SetInputMessage1111(nonce string, timestamp int64, org_name string, doctor int64, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, op_name string) map[string]interface{} {
  3912. // 生成签名
  3913. tempTime := time.Unix(timestamp, 0)
  3914. //timeFormat := tempTime.Format("20060102150405")
  3915. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  3916. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  3917. month := time.Unix(1557042972, 0).Format("1")
  3918. year := time.Now().Format("2006")
  3919. month = time.Now().Format("01")
  3920. day := time.Now().Format("02")
  3921. hour := time.Now().Format("15")
  3922. min := time.Now().Format("04")
  3923. sec := time.Now().Format("05")
  3924. msec := time.Now().Format("000")
  3925. // 生成输入报文
  3926. inputMessage := make(map[string]interface{})
  3927. inputMessage["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  3928. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  3929. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  3930. inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  3931. inputMessage["dev_no"] = "" // 设备编号
  3932. inputMessage["dev_safe_info"] = "" // 设备安全信息
  3933. inputMessage["cainfo"] = "" // 数字签名信息
  3934. inputMessage["signtype"] = "MOCK" // 签名类型
  3935. inputMessage["infver"] = "V1.0" // 接收方系统代码
  3936. inputMessage["opter_type"] = "1" // 经办人类别
  3937. inputMessage["opter"] = doctor // 经办人
  3938. inputMessage["opter_name"] = op_name // 经办人姓名
  3939. inputMessage["inf_time"] = timeFormatOne // 交易时间
  3940. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  3941. inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  3942. if mdtrtarea_admvs == "440100" {
  3943. inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号
  3944. } else {
  3945. inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号 //交易签到流水号
  3946. }
  3947. return inputMessage
  3948. }
  3949. func SetInputMessage(nonce string, timestamp int64, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) map[string]interface{} {
  3950. // 生成签名
  3951. tempTime := time.Unix(timestamp, 0)
  3952. //timeFormat := tempTime.Format("20060102150405")
  3953. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  3954. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  3955. month := time.Unix(1557042972, 0).Format("1")
  3956. year := time.Now().Format("2006")
  3957. month = time.Now().Format("01")
  3958. day := time.Now().Format("02")
  3959. hour := time.Now().Format("15")
  3960. min := time.Now().Format("04")
  3961. sec := time.Now().Format("05")
  3962. msec := time.Now().Format("000")
  3963. // 生成输入报文
  3964. inputMessage := make(map[string]interface{})
  3965. inputMessage["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  3966. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  3967. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  3968. inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  3969. inputMessage["dev_no"] = "" // 设备编号
  3970. inputMessage["dev_safe_info"] = "" // 设备安全信息
  3971. inputMessage["cainfo"] = "" // 数字签名信息
  3972. inputMessage["signtype"] = "MOCK" // 签名类型
  3973. inputMessage["infver"] = "V1.0" // 接收方系统代码
  3974. inputMessage["opter_type"] = "1" // 经办人类别
  3975. inputMessage["opter"] = doctor // 经办人
  3976. inputMessage["opter_name"] = doctor // 经办人姓名
  3977. inputMessage["inf_time"] = timeFormatOne // 交易时间
  3978. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  3979. inputMessage["fixmedins_name"] = org_name
  3980. inputMessage["sign_no"] = "489925883" //交易签到流水号
  3981. //定点医药机构名称
  3982. //if mdtrtarea_admvs == "440100" {
  3983. // inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号
  3984. //} else {
  3985. // inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号 //交易签到流水号
  3986. //}
  3987. return inputMessage
  3988. }
  3989. func SetInputMessagenosign(nonce string, timestamp int64, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) map[string]interface{} {
  3990. // 生成签名
  3991. tempTime := time.Unix(timestamp, 0)
  3992. //timeFormat := tempTime.Format("20060102150405")
  3993. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  3994. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  3995. month := time.Unix(1557042972, 0).Format("1")
  3996. year := time.Now().Format("2006")
  3997. month = time.Now().Format("01")
  3998. day := time.Now().Format("02")
  3999. hour := time.Now().Format("15")
  4000. min := time.Now().Format("04")
  4001. sec := time.Now().Format("05")
  4002. msec := time.Now().Format("000")
  4003. // 生成输入报文
  4004. inputMessage := make(map[string]interface{})
  4005. inputMessage["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  4006. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  4007. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  4008. inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  4009. inputMessage["dev_no"] = "" // 设备编号
  4010. inputMessage["dev_safe_info"] = "" // 设备安全信息
  4011. inputMessage["cainfo"] = "" // 数字签名信息
  4012. inputMessage["signtype"] = "MOCK" // 签名类型
  4013. inputMessage["infver"] = "V1.0" // 接收方系统代码
  4014. inputMessage["opter_type"] = "1" // 经办人类别
  4015. inputMessage["opter"] = doctor // 经办人
  4016. inputMessage["opter_name"] = doctor // 经办人姓名
  4017. inputMessage["inf_time"] = timeFormatOne // 交易时间
  4018. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  4019. inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  4020. if mdtrtarea_admvs == "440100" {
  4021. inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号
  4022. } else {
  4023. inputMessage["sign_no"] = ""
  4024. }
  4025. return inputMessage
  4026. }
  4027. //func GetSignInInfo(code string) string {
  4028. // var sign models.HisSignIn
  4029. // err = readDb.Model(&models.HisSignIn{}).Where("fixmedins_code = ? AND status = 1", code).Last(&sign).Error
  4030. // return sign.SignNo
  4031. //}
  4032. 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{} {
  4033. // 生成签名
  4034. tempTime := time.Unix(timestamp, 0)
  4035. //timeFormat := tempTime.Format("20060102150405")
  4036. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  4037. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  4038. // 生成输入报文
  4039. inputMessage := make(map[string]interface{})
  4040. inputMessage["msgid"] = msg_id // 发送方报文 ID
  4041. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  4042. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  4043. inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  4044. inputMessage["dev_no"] = "" // 设备编号
  4045. inputMessage["dev_safe_info"] = "" // 设备安全信息
  4046. inputMessage["cainfo"] = "" // 数字签名信息
  4047. inputMessage["signtype"] = "SM3" // 签名类型
  4048. inputMessage["infver"] = "V1.0" // 接收方系统代码
  4049. inputMessage["opter_type"] = "1" // 经办人类别
  4050. inputMessage["opter"] = doctor // 经办人
  4051. inputMessage["opter_name"] = doctor // 经办人姓名
  4052. inputMessage["inf_time"] = timeFormatOne // 交易时间
  4053. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  4054. inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  4055. if mdtrtarea_admvs == "440100" {
  4056. inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号
  4057. } else {
  4058. inputMessage["sign_no"] = "" //交易签到流水号
  4059. }
  4060. return inputMessage
  4061. }
  4062. 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{} {
  4063. // 生成签名
  4064. tempTime := time.Unix(timestamp, 0)
  4065. //timeFormat := tempTime.Format("20060102150405")
  4066. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  4067. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  4068. month := time.Unix(1557042972, 0).Format("1")
  4069. year := time.Now().Format("2006")
  4070. month = time.Now().Format("01")
  4071. day := time.Now().Format("02")
  4072. hour := time.Now().Format("15")
  4073. min := time.Now().Format("04")
  4074. sec := time.Now().Format("05")
  4075. msec := time.Now().Format("000")
  4076. // 生成输入报文
  4077. inputMessage := make(map[string]interface{})
  4078. inputMessage["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  4079. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  4080. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  4081. inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  4082. inputMessage["dev_no"] = "" // 设备编号
  4083. inputMessage["dev_safe_info"] = "" // 设备安全信息
  4084. inputMessage["cainfo"] = "" // 数字签名信息
  4085. inputMessage["signtype"] = "SM3" // 签名类型
  4086. inputMessage["infver"] = "V1.0" // 接收方系统代码
  4087. inputMessage["opter_type"] = "1" // 经办人类别
  4088. inputMessage["opter"] = doctor // 经办人
  4089. inputMessage["opter_name"] = doctor // 经办人姓名
  4090. inputMessage["inf_time"] = timeFormatOne // 交易时间
  4091. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  4092. inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  4093. if mdtrtarea_admvs == "440100" {
  4094. inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号
  4095. } else {
  4096. inputMessage["sign_no"] = sign_no //交易签到流水号
  4097. }
  4098. return inputMessage
  4099. }
  4100. func postFile(filename string, target_url string) (*http.Response, error) {
  4101. body_buf := bytes.NewBufferString("")
  4102. body_writer := multipart.NewWriter(body_buf)
  4103. // use the body_writer to write the Part headers to the buffer
  4104. _, err := body_writer.CreateFormFile("userfile", filename)
  4105. if err != nil {
  4106. fmt.Println("error writing to buffer")
  4107. return nil, err
  4108. }
  4109. // the file data will be the second part of the body
  4110. fh, err := os.Open(filename)
  4111. if err != nil {
  4112. fmt.Println("error opening file")
  4113. return nil, err
  4114. }
  4115. // need to know the boundary to properly close the part myself.
  4116. boundary := body_writer.Boundary()
  4117. //close_string := fmt.Sprintf("\r\n--%s--\r\n", boundary)
  4118. close_buf := bytes.NewBufferString(fmt.Sprintf("\r\n--%s--\r\n", boundary))
  4119. // use multi-reader to defer the reading of the file data until
  4120. // writing to the socket buffer.
  4121. request_reader := io.MultiReader(body_buf, fh, close_buf)
  4122. fi, err := fh.Stat()
  4123. if err != nil {
  4124. fmt.Printf("Error Stating file: %s", filename)
  4125. return nil, err
  4126. }
  4127. req, err := http.NewRequest("POST", target_url, request_reader)
  4128. if err != nil {
  4129. return nil, err
  4130. }
  4131. // Set headers for multipart, and Content Length
  4132. req.Header.Add("Content-Type", "multipart/form-data; boundary="+boundary)
  4133. req.ContentLength = fi.Size() + int64(body_buf.Len()) + int64(close_buf.Len())
  4134. return http.DefaultClient.Do(req)
  4135. }
  4136. //func Gdyb1201(psnNo string, org_name string, doctor string) string {
  4137. // // 生成签名
  4138. // nonce := GetRandomString(32)
  4139. // timestamp := time.Now().Unix()
  4140. // signature := setSignature(timestamp, nonce)
  4141. //
  4142. // // 生成输入报文
  4143. // inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, "")
  4144. // input := make(map[string]interface{})
  4145. // inputData := make(map[string]interface{})
  4146. // inputMessage["infno"] = "1201" // 交易编码
  4147. // inputData["fixmedins_type"] = psnNo // 人员编号 (来自1101接口返回)
  4148. // inputData["fixmedins_name"] = org_name // 人员编号 (来自1101接口返回)
  4149. // inputData["fixmedins_code"] = "" // 人员编号 (来自1101接口返回)
  4150. //
  4151. // input["medinsinfo"] = inputData
  4152. // inputMessage["input"] = input //交易输入
  4153. //
  4154. // bytesData, err := json.Marshal(inputMessage)
  4155. // fmt.Println(string(bytesData))
  4156. // if err != nil {
  4157. // fmt.Println(err.Error())
  4158. // return err.Error()
  4159. // }
  4160. // reader := bytes.NewReader(bytesData)
  4161. //
  4162. // url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1201"
  4163. // request, err := http.NewRequest("POST", url, reader)
  4164. // if err != nil {
  4165. // fmt.Println(err.Error())
  4166. // return err.Error()
  4167. // }
  4168. //
  4169. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4170. // request.Header.Set("x-tif-paasid", "test_hosp")
  4171. // request.Header.Set("x-tif-signature", signature)
  4172. // request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4173. // request.Header.Set("x-tif-nonce", nonce)
  4174. //
  4175. // client := http.Client{}
  4176. // resp, err := client.Do(request)
  4177. // if err != nil {
  4178. // fmt.Println(err.Error())
  4179. // return err.Error()
  4180. // }
  4181. // respBytes, err := ioutil.ReadAll(resp.Body)
  4182. // if err != nil {
  4183. // fmt.Println(err.Error())
  4184. // return err.Error()
  4185. // }
  4186. // str := string(respBytes)
  4187. // fmt.Println(str)
  4188. // return str
  4189. //}
  4190. func newfileUploadRequest(uri string, params map[string]string, paramName, path string) (*http.Request, error) {
  4191. file, err := os.Open(path)
  4192. if err != nil {
  4193. return nil, err
  4194. }
  4195. defer file.Close()
  4196. body := &bytes.Buffer{}
  4197. writer := multipart.NewWriter(body)
  4198. part, err := writer.CreateFormFile(paramName, filepath.Base(path))
  4199. if err != nil {
  4200. return nil, err
  4201. }
  4202. _, err = io.Copy(part, file)
  4203. for key, val := range params {
  4204. _ = writer.WriteField(key, val)
  4205. }
  4206. err = writer.Close()
  4207. if err != nil {
  4208. return nil, err
  4209. }
  4210. req, err := http.NewRequest("POST", uri, body)
  4211. req.Header.Set("Content-Type", writer.FormDataContentType())
  4212. return req, err
  4213. }
  4214. func CreateMedicalInsuranceCostCompareRecord(record *models.MedicalInsuranceCostCompare) error {
  4215. err := writeDb.Save(&record).Error
  4216. return err
  4217. }
  4218. //func Gdyb5203(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  4219. // // 生成签名
  4220. // nonce := GetRandomString(32)
  4221. // timestamp := time.Now().Unix()
  4222. // signature := setSignature(timestamp, nonce, secret_key)
  4223. //
  4224. // // 生成输入报文
  4225. // inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4226. // input := make(map[string]interface{})
  4227. // inputData := make(map[string]interface{})
  4228. // inputMessage["infno"] = "5203" // 交易编码
  4229. //
  4230. // inputData["fixmedins_type"] = "1"
  4231. // inputData["fixmedins_name"] = org_name
  4232. // inputData["fixmedins_code"] = fixmedins_code
  4233. // input["medinsinfo"] = inputData
  4234. // inputMessage["input"] = input //交易输入
  4235. //
  4236. // bytesData, err := json.Marshal(inputMessage)
  4237. // fmt.Println(string(bytesData))
  4238. // if err != nil {
  4239. // fmt.Println(err.Error())
  4240. // return err.Error()
  4241. // }
  4242. // reader := bytes.NewReader(bytesData)
  4243. // url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1201"
  4244. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1201"
  4245. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4246. // request, err := http.NewRequest("POST", url, reader)
  4247. // if err != nil {
  4248. // fmt.Println(err.Error())
  4249. // return err.Error()
  4250. // }
  4251. //
  4252. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4253. // request.Header.Set("x-tif-paasid", "sg03_prd")
  4254. // request.Header.Set("x-tif-signature", signature)
  4255. // request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4256. // request.Header.Set("x-tif-nonce", nonce)
  4257. //
  4258. // client := http.Client{}
  4259. // resp, err := client.Do(request)
  4260. // if err != nil {
  4261. // fmt.Println(err.Error())
  4262. // return err.Error()
  4263. // }
  4264. // respBytes, err := ioutil.ReadAll(resp.Body)
  4265. // if err != nil {
  4266. // fmt.Println(err.Error())
  4267. // return err.Error()
  4268. // }
  4269. // fmt.Println(string(respBytes))
  4270. // str := string(respBytes)
  4271. // return str
  4272. //}
  4273. func CreatePsnRecord(record *models.GdybPsnRecord) {
  4274. writeDb.Save(&record)
  4275. return
  4276. }
  4277. func GetPsnRecordById(id int64) (record models.GdybPsnRecord, err error) {
  4278. err = readDb.Model(&models.GdybPsnRecord{}).Where("id = ?").First(&record).Error
  4279. return
  4280. }
  4281. func CreatePsnNCDSRecord(record *models.GdybPsnNcdsRecord) {
  4282. writeDb.Save(&record)
  4283. return
  4284. }
  4285. func GetPsnNCDSRecordById(id int64) (record models.GdybPsnNcdsRecord, err error) {
  4286. err = readDb.Model(&models.GdybPsnNcdsRecord{}).Where("id = ?", id).First(&record).Error
  4287. return
  4288. }
  4289. func GetPatientsByIds(ids []string, current_org_id int64) (patients []*models.Patients, err error) {
  4290. err = readDb.Model(&models.Patients{}).Where("id IN (?) AND user_org_id = ?", ids, current_org_id).Find(&patients).Error
  4291. return
  4292. }
  4293. 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 {
  4294. // 生成签名
  4295. nonce := GetRandomString(32)
  4296. timestamp := time.Now().Unix()
  4297. signature := setSignature(timestamp, nonce, secret_key)
  4298. // 生成输入报文
  4299. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4300. input := make(map[string]interface{})
  4301. inputData := make(map[string]interface{})
  4302. inputMessage["infno"] = "2601" // 交易编码
  4303. inputData["psn_no"] = psnNo
  4304. inputData["omsgid"] = omsgid
  4305. inputData["oinfno"] = oinfno
  4306. input["data"] = inputData
  4307. inputMessage["input"] = input //交易输入
  4308. bytesData, err := json.Marshal(inputMessage)
  4309. fmt.Println(string(bytesData))
  4310. if err != nil {
  4311. fmt.Println(err.Error())
  4312. return err.Error()
  4313. }
  4314. reader := bytes.NewReader(bytesData)
  4315. gdyb_url := beego.AppConfig.String("gdyb_url")
  4316. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4317. url := gdyb_url + "2601"
  4318. request, err := http.NewRequest("POST", url, reader)
  4319. if err != nil {
  4320. fmt.Println(err.Error())
  4321. return err.Error()
  4322. }
  4323. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4324. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4325. request.Header.Set("x-tif-signature", signature)
  4326. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4327. request.Header.Set("x-tif-nonce", nonce)
  4328. client := http.Client{}
  4329. resp, err := client.Do(request)
  4330. if err != nil {
  4331. fmt.Println(err.Error())
  4332. return err.Error()
  4333. }
  4334. respBytes, err := ioutil.ReadAll(resp.Body)
  4335. if err != nil {
  4336. fmt.Println(err.Error())
  4337. return err.Error()
  4338. }
  4339. str := string(respBytes)
  4340. fmt.Println(str)
  4341. return str
  4342. }
  4343. // 人员信息版本3
  4344. 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, admin_user_id int64) string {
  4345. //生成签名
  4346. nonce := GetRandomString(32)
  4347. timestamp := time.Now().Unix()
  4348. signature := setSignature(timestamp, nonce, secret_key)
  4349. //生成输入报文
  4350. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4351. inputMessage := make(map[string]interface{})
  4352. //生成输入报文
  4353. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  4354. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  4355. } else {
  4356. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4357. }
  4358. input := make(map[string]interface{})
  4359. inputData := make(map[string]interface{})
  4360. inputMessage["infno"] = "1101" // 交易编码
  4361. if certificates == 3 {
  4362. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  4363. inputData["certno"] = "01836483" // 证件号码
  4364. inputData["psn_cert_type"] = "01" // 人员证件类型
  4365. inputData["mdtrt_cert_no"] = "01836483" // 就诊凭证编号
  4366. } else {
  4367. if certificates == 1 {
  4368. if id_card_type == 1 {
  4369. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  4370. inputData["card_sn"] = card_sn // 卡识别码
  4371. inputData["certno"] = certNo // 证件号码
  4372. inputData["psn_cert_type"] = "01" // 人员证件类型
  4373. inputData["mdtrt_cert_no"] = cardNumber // 就诊凭证编号
  4374. } else {
  4375. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  4376. inputData["card_sn"] = "" // 卡识别码
  4377. inputData["certno"] = certNo // 证件号码
  4378. inputData["psn_cert_type"] = "01" // 人员证件类型
  4379. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  4380. }
  4381. } else if certificates == 6 {
  4382. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  4383. inputData["card_sn"] = "" // 卡识别码
  4384. inputData["certno"] = certNo // 证件号码
  4385. inputData["psn_cert_type"] = "17" // 人员证件类型
  4386. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  4387. }
  4388. }
  4389. inputData["begntime"] = "" // 开始时间
  4390. inputData["psn_name"] = name // 人员姓名
  4391. input["data"] = inputData
  4392. inputMessage["input"] = input //交易输入
  4393. bytesData, err := json.Marshal(inputMessage)
  4394. fmt.Println(string(bytesData))
  4395. if err != nil {
  4396. fmt.Println(err.Error())
  4397. return err.Error()
  4398. }
  4399. reader := bytes.NewReader(bytesData)
  4400. gdyb_url := beego.AppConfig.String("gdyb_url")
  4401. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4402. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4403. //url := gdyb_url + "1101"
  4404. var url string
  4405. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  4406. url = gdyb_url
  4407. } else {
  4408. url = gdyb_url + "1101"
  4409. }
  4410. fmt.Println(url)
  4411. fmt.Println(gdyb_paasid)
  4412. fmt.Println(secret_key)
  4413. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4414. request, err := http.NewRequest("POST", url, reader)
  4415. if err != nil {
  4416. fmt.Println(err.Error())
  4417. return err.Error()
  4418. }
  4419. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4420. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4421. request.Header.Set("x-tif-signature", signature)
  4422. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4423. request.Header.Set("x-tif-nonce", nonce)
  4424. client := http.Client{}
  4425. resp, err := client.Do(request)
  4426. if err != nil {
  4427. fmt.Println(err.Error())
  4428. return err.Error()
  4429. }
  4430. respBytes, err := ioutil.ReadAll(resp.Body)
  4431. if err != nil {
  4432. fmt.Println(err.Error())
  4433. return err.Error()
  4434. }
  4435. fmt.Println(string(respBytes))
  4436. str := string(respBytes)
  4437. return str
  4438. }
  4439. 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 int64, name string, token string, admin_user_id int64) string {
  4440. //生成签名
  4441. nonce := GetRandomString(32)
  4442. timestamp := time.Now().Unix()
  4443. signature := setSignature(timestamp, nonce, secret_key)
  4444. inputMessage := make(map[string]interface{})
  4445. //生成输入报文
  4446. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  4447. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  4448. } else {
  4449. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4450. }
  4451. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4452. input := make(map[string]interface{})
  4453. inputData := make(map[string]interface{})
  4454. inputMessage["infno"] = "1101" // 交易编码
  4455. if certificates == 3 {
  4456. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  4457. inputData["certno"] = "01836483" // 证件号码
  4458. inputData["psn_cert_type"] = "01" // 人员证件类型
  4459. inputData["mdtrt_cert_no"] = "01836483" // 就诊凭证编号
  4460. } else {
  4461. if certificates == 1 {
  4462. if id_card_type == 4 {
  4463. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  4464. inputData["card_sn"] = card_sn // 卡识别码
  4465. inputData["certno"] = certNo // 证件号码
  4466. inputData["psn_cert_type"] = "01" // 人员证件类型
  4467. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  4468. }
  4469. } else if certificates == 6 {
  4470. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  4471. inputData["card_sn"] = "" // 卡识别码
  4472. inputData["certno"] = certNo // 证件号码
  4473. inputData["psn_cert_type"] = "17" // 人员证件类型
  4474. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  4475. }
  4476. }
  4477. inputData["begntime"] = "" // 开始时间
  4478. inputData["psn_name"] = name // 人员姓名
  4479. input["data"] = inputData
  4480. inputMessage["input"] = input //交易输入
  4481. bytesData, err := json.Marshal(inputMessage)
  4482. fmt.Println(string(bytesData))
  4483. if err != nil {
  4484. fmt.Println(err.Error())
  4485. return err.Error()
  4486. }
  4487. reader := bytes.NewReader(bytesData)
  4488. gdyb_url := beego.AppConfig.String("gdyb_url")
  4489. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4490. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4491. //url := gdyb_url + "1101"
  4492. var url string
  4493. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  4494. url = gdyb_url
  4495. } else {
  4496. url = gdyb_url + "1101"
  4497. }
  4498. fmt.Println(url)
  4499. fmt.Println(gdyb_paasid)
  4500. fmt.Println(secret_key)
  4501. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4502. request, err := http.NewRequest("POST", url, reader)
  4503. if err != nil {
  4504. fmt.Println(err.Error())
  4505. return err.Error()
  4506. }
  4507. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4508. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4509. request.Header.Set("x-tif-signature", signature)
  4510. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4511. request.Header.Set("x-tif-nonce", nonce)
  4512. client := http.Client{}
  4513. resp, err := client.Do(request)
  4514. if err != nil {
  4515. fmt.Println(err.Error())
  4516. return err.Error()
  4517. }
  4518. respBytes, err := ioutil.ReadAll(resp.Body)
  4519. if err != nil {
  4520. fmt.Println(err.Error())
  4521. return err.Error()
  4522. }
  4523. fmt.Println(string(respBytes))
  4524. str := string(respBytes)
  4525. return str
  4526. }
  4527. 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 {
  4528. //生成签名
  4529. nonce := GetRandomString(32)
  4530. timestamp := time.Now().Unix()
  4531. signature := setSignature(timestamp, nonce, secret_key)
  4532. //生成输入报文
  4533. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4534. input := make(map[string]interface{})
  4535. inputData := make(map[string]interface{})
  4536. inputMessage["infno"] = "1101" // 交易编码
  4537. if certificates == 3 {
  4538. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  4539. inputData["certno"] = "01836483" // 证件号码
  4540. inputData["psn_cert_type"] = "01" // 人员证件类型
  4541. inputData["mdtrt_cert_no"] = "01836483" // 就诊凭证编号
  4542. } else {
  4543. if certificates == 1 {
  4544. if id_card_type == 1 {
  4545. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  4546. inputData["card_sn"] = "" // 卡识别码
  4547. inputData["certno"] = certNo // 证件号码
  4548. inputData["psn_cert_type"] = "01" // 人员证件类型
  4549. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  4550. } else {
  4551. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  4552. inputData["card_sn"] = "" // 卡识别码
  4553. inputData["certno"] = certNo // 证件号码
  4554. inputData["psn_cert_type"] = "" // 人员证件类型
  4555. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  4556. }
  4557. } else if certificates == 6 {
  4558. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  4559. inputData["card_sn"] = "" // 卡识别码
  4560. inputData["certno"] = certNo // 证件号码
  4561. inputData["psn_cert_type"] = "" // 人员证件类型
  4562. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  4563. }
  4564. }
  4565. inputData["begntime"] = "" // 开始时间
  4566. inputData["psn_name"] = "" // 人员姓名
  4567. input["data"] = inputData
  4568. inputMessage["input"] = input //交易输入
  4569. bytesData, err := json.Marshal(inputMessage)
  4570. fmt.Println(string(bytesData))
  4571. if err != nil {
  4572. fmt.Println(err.Error())
  4573. return err.Error()
  4574. }
  4575. reader := bytes.NewReader(bytesData)
  4576. gdyb_url := beego.AppConfig.String("gdyb_url")
  4577. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4578. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4579. //url := gdyb_url + "1101"
  4580. var url string
  4581. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  4582. url = gdyb_url
  4583. } else {
  4584. url = gdyb_url + "1101"
  4585. }
  4586. fmt.Println(url)
  4587. fmt.Println(gdyb_paasid)
  4588. fmt.Println(secret_key)
  4589. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4590. request, err := http.NewRequest("POST", url, reader)
  4591. if err != nil {
  4592. fmt.Println(err.Error())
  4593. return err.Error()
  4594. }
  4595. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4596. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4597. request.Header.Set("x-tif-signature", signature)
  4598. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4599. request.Header.Set("x-tif-nonce", nonce)
  4600. client := http.Client{}
  4601. resp, err := client.Do(request)
  4602. if err != nil {
  4603. fmt.Println(err.Error())
  4604. return err.Error()
  4605. }
  4606. respBytes, err := ioutil.ReadAll(resp.Body)
  4607. if err != nil {
  4608. fmt.Println(err.Error())
  4609. return err.Error()
  4610. }
  4611. fmt.Println(string(respBytes))
  4612. str := string(respBytes)
  4613. return str
  4614. }
  4615. 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 {
  4616. //生成签名
  4617. nonce := GetRandomString(32)
  4618. timestamp := time.Now().Unix()
  4619. signature := setSignature(timestamp, nonce, secret_key)
  4620. //生成输入报文
  4621. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4622. input := make(map[string]interface{})
  4623. inputData := make(map[string]interface{})
  4624. inputMessage["infno"] = "1101" // 交易编码
  4625. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  4626. inputData["card_sn"] = card_sn // 卡识别码
  4627. inputData["certno"] = certNo // 证件号码
  4628. inputData["psn_cert_type"] = "01" // 人员证件类型
  4629. inputData["mdtrt_cert_no"] = cardNumber // 就诊凭证编号
  4630. inputData["begntime"] = "" // 开始时间
  4631. inputData["psn_name"] = name // 人员姓名
  4632. input["data"] = inputData
  4633. inputMessage["input"] = input //交易输入
  4634. bytesData, err := json.Marshal(inputMessage)
  4635. fmt.Println(string(bytesData))
  4636. if err != nil {
  4637. fmt.Println(err.Error())
  4638. return err.Error()
  4639. }
  4640. reader := bytes.NewReader(bytesData)
  4641. gdyb_url := beego.AppConfig.String("gdyb_url")
  4642. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4643. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4644. //url := gdyb_url + "1101"
  4645. var url string
  4646. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  4647. url = gdyb_url
  4648. } else {
  4649. url = gdyb_url + "1101"
  4650. }
  4651. fmt.Println(url)
  4652. fmt.Println(gdyb_paasid)
  4653. fmt.Println(secret_key)
  4654. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4655. request, err := http.NewRequest("POST", url, reader)
  4656. if err != nil {
  4657. fmt.Println(err.Error())
  4658. return err.Error()
  4659. }
  4660. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4661. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4662. request.Header.Set("x-tif-signature", signature)
  4663. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4664. request.Header.Set("x-tif-nonce", nonce)
  4665. client := http.Client{}
  4666. resp, err := client.Do(request)
  4667. if err != nil {
  4668. fmt.Println(err.Error())
  4669. return err.Error()
  4670. }
  4671. respBytes, err := ioutil.ReadAll(resp.Body)
  4672. if err != nil {
  4673. fmt.Println(err.Error())
  4674. return err.Error()
  4675. }
  4676. fmt.Println(string(respBytes))
  4677. str := string(respBytes)
  4678. return str
  4679. }
  4680. func Gdyb1101ForEleCert1111(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, token string, user_name string, idNo string, certificates int64) (string, string) {
  4681. //生成签名
  4682. nonce := GetRandomString(32)
  4683. timestamp := time.Now().Unix()
  4684. signature := setSignature(timestamp, nonce, secret_key)
  4685. //生成输入报文
  4686. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4687. input := make(map[string]interface{})
  4688. inputData := make(map[string]interface{})
  4689. inputMessage["infno"] = "1101" // 交易编码
  4690. if certificates == 6 {
  4691. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  4692. inputData["psn_cert_type"] = "" // 人员证件类型
  4693. } else {
  4694. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  4695. inputData["psn_cert_type"] = "01" // 人员证件类型
  4696. }
  4697. inputData["card_sn"] = "" // 卡识别码
  4698. inputData["certno"] = idNo // 证件号码
  4699. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  4700. inputData["begntime"] = "" // 开始时间
  4701. inputData["psn_name"] = user_name // 人员姓名
  4702. input["data"] = inputData
  4703. inputMessage["input"] = input //交易输入
  4704. bytesData, err := json.Marshal(inputMessage)
  4705. fmt.Println(string(bytesData))
  4706. if err != nil {
  4707. fmt.Println(err.Error())
  4708. return err.Error(), ""
  4709. }
  4710. reader := bytes.NewReader(bytesData)
  4711. gdyb_url := beego.AppConfig.String("gdyb_url")
  4712. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4713. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4714. //url := gdyb_url + "1101"
  4715. var url string
  4716. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  4717. url = gdyb_url
  4718. } else {
  4719. url = gdyb_url + "1101"
  4720. }
  4721. fmt.Println(url)
  4722. fmt.Println(gdyb_paasid)
  4723. fmt.Println(secret_key)
  4724. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4725. request, err := http.NewRequest("POST", url, reader)
  4726. if err != nil {
  4727. fmt.Println(err.Error())
  4728. return err.Error(), ""
  4729. }
  4730. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4731. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4732. request.Header.Set("x-tif-signature", signature)
  4733. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4734. request.Header.Set("x-tif-nonce", nonce)
  4735. client := http.Client{}
  4736. resp, err := client.Do(request)
  4737. if err != nil {
  4738. fmt.Println(err.Error())
  4739. return err.Error(), ""
  4740. }
  4741. respBytes, err := ioutil.ReadAll(resp.Body)
  4742. if err != nil {
  4743. fmt.Println(err.Error())
  4744. return err.Error(), ""
  4745. }
  4746. fmt.Println(string(respBytes))
  4747. str := string(respBytes)
  4748. return str, string(bytesData)
  4749. }
  4750. 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) {
  4751. //生成签名
  4752. nonce := GetRandomString(32)
  4753. timestamp := time.Now().Unix()
  4754. signature := setSignature(timestamp, nonce, secret_key)
  4755. //生成输入报文
  4756. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4757. input := make(map[string]interface{})
  4758. inputData := make(map[string]interface{})
  4759. inputMessage["infno"] = "1101" // 交易编码
  4760. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  4761. inputData["psn_cert_type"] = "01" // 人员证件类型
  4762. inputData["card_sn"] = "" // 卡识别码
  4763. inputData["certno"] = idNo // 证件号码
  4764. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  4765. inputData["begntime"] = "" // 开始时间
  4766. inputData["psn_name"] = user_name // 人员姓名
  4767. input["data"] = inputData
  4768. inputMessage["input"] = input //交易输入
  4769. bytesData, err := json.Marshal(inputMessage)
  4770. fmt.Println(string(bytesData))
  4771. if err != nil {
  4772. fmt.Println(err.Error())
  4773. return err.Error(), ""
  4774. }
  4775. reader := bytes.NewReader(bytesData)
  4776. gdyb_url := beego.AppConfig.String("gdyb_url")
  4777. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4778. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4779. //url := gdyb_url + "1101"
  4780. var url string
  4781. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  4782. url = gdyb_url
  4783. } else {
  4784. url = gdyb_url + "1101"
  4785. }
  4786. fmt.Println(url)
  4787. fmt.Println(gdyb_paasid)
  4788. fmt.Println(secret_key)
  4789. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4790. request, err := http.NewRequest("POST", url, reader)
  4791. if err != nil {
  4792. fmt.Println(err.Error())
  4793. return err.Error(), ""
  4794. }
  4795. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4796. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4797. request.Header.Set("x-tif-signature", signature)
  4798. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4799. request.Header.Set("x-tif-nonce", nonce)
  4800. client := http.Client{}
  4801. resp, err := client.Do(request)
  4802. if err != nil {
  4803. fmt.Println(err.Error())
  4804. return err.Error(), ""
  4805. }
  4806. respBytes, err := ioutil.ReadAll(resp.Body)
  4807. if err != nil {
  4808. fmt.Println(err.Error())
  4809. return err.Error(), ""
  4810. }
  4811. fmt.Println(string(respBytes))
  4812. str := string(respBytes)
  4813. return str, string(bytesData)
  4814. }
  4815. 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) {
  4816. //生成签名
  4817. nonce := GetRandomString(32)
  4818. timestamp := time.Now().Unix()
  4819. signature := setSignature(timestamp, nonce, secret_key)
  4820. //生成输入报文
  4821. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4822. input := make(map[string]interface{})
  4823. inputData := make(map[string]interface{})
  4824. inputMessage["infno"] = "1101" // 交易编码
  4825. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  4826. inputData["card_sn"] = "" // 卡识别码
  4827. inputData["certno"] = idNo // 证件号码
  4828. inputData["psn_cert_type"] = "01" // 人员证件类型
  4829. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  4830. inputData["begntime"] = "" // 开始时间
  4831. inputData["psn_name"] = user_name // 人员姓名
  4832. input["data"] = inputData
  4833. inputMessage["input"] = input //交易输入
  4834. bytesData, err := json.Marshal(inputMessage)
  4835. fmt.Println(string(bytesData))
  4836. if err != nil {
  4837. fmt.Println(err.Error())
  4838. return err.Error(), ""
  4839. }
  4840. reader := bytes.NewReader(bytesData)
  4841. gdyb_url := beego.AppConfig.String("gdyb_url")
  4842. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4843. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4844. //url := gdyb_url + "1101"
  4845. var url string
  4846. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  4847. url = gdyb_url
  4848. } else {
  4849. url = gdyb_url + "1101"
  4850. }
  4851. fmt.Println(url)
  4852. fmt.Println(gdyb_paasid)
  4853. fmt.Println(secret_key)
  4854. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4855. request, err := http.NewRequest("POST", url, reader)
  4856. if err != nil {
  4857. fmt.Println(err.Error())
  4858. return err.Error(), ""
  4859. }
  4860. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4861. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4862. request.Header.Set("x-tif-signature", signature)
  4863. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4864. request.Header.Set("x-tif-nonce", nonce)
  4865. client := http.Client{}
  4866. resp, err := client.Do(request)
  4867. if err != nil {
  4868. fmt.Println(err.Error())
  4869. return err.Error(), ""
  4870. }
  4871. respBytes, err := ioutil.ReadAll(resp.Body)
  4872. if err != nil {
  4873. fmt.Println(err.Error())
  4874. return err.Error(), ""
  4875. }
  4876. fmt.Println(string(respBytes))
  4877. str := string(respBytes)
  4878. return str, string(bytesData)
  4879. }
  4880. func Gdyb6101(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) (string, string) {
  4881. //生成签名
  4882. nonce := GetRandomString(32)
  4883. timestamp := time.Now().Unix()
  4884. signature := setSignature(timestamp, nonce, secret_key)
  4885. //生成输入报文
  4886. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4887. input := make(map[string]interface{})
  4888. inputData := make(map[string]interface{})
  4889. inputMessage["infno"] = "6101" // 交易编码
  4890. inputData["orgId"] = fixmedins_code // 就诊凭证类型
  4891. inputData["businessType"] = "01101" // 卡识别码
  4892. inputData["businessInfo"] = "" // 证件号码
  4893. inputData["operateorId"] = "01" // 人员证件类型
  4894. inputData["operateornName"] = doctor // 就诊凭证编号
  4895. inputData["officeId"] = "01" // 开始时间
  4896. inputData["officeName"] = "血透" // 人员姓名
  4897. inputData["deviceType"] = "" // 人员姓名
  4898. input["InData"] = inputData
  4899. inputMessage["input"] = input //交易输入
  4900. bytesData, err := json.Marshal(inputMessage)
  4901. fmt.Println(string(bytesData))
  4902. if err != nil {
  4903. fmt.Println(err.Error())
  4904. return err.Error(), ""
  4905. }
  4906. reader := bytes.NewReader(bytesData)
  4907. gdyb_url := beego.AppConfig.String("gdyb_url")
  4908. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4909. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4910. //url := gdyb_url + "1101"
  4911. var url string
  4912. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450127" {
  4913. url = gdyb_url
  4914. } else {
  4915. url = gdyb_url + "1101"
  4916. }
  4917. fmt.Println(url)
  4918. fmt.Println(gdyb_paasid)
  4919. fmt.Println(secret_key)
  4920. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4921. request, err := http.NewRequest("POST", url, reader)
  4922. if err != nil {
  4923. fmt.Println(err.Error())
  4924. return err.Error(), ""
  4925. }
  4926. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4927. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4928. request.Header.Set("x-tif-signature", signature)
  4929. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4930. request.Header.Set("x-tif-nonce", nonce)
  4931. client := http.Client{}
  4932. resp, err := client.Do(request)
  4933. if err != nil {
  4934. fmt.Println(err.Error())
  4935. return err.Error(), ""
  4936. }
  4937. respBytes, err := ioutil.ReadAll(resp.Body)
  4938. if err != nil {
  4939. fmt.Println(err.Error())
  4940. return err.Error(), ""
  4941. }
  4942. fmt.Println(string(respBytes))
  4943. str := string(respBytes)
  4944. return str, string(bytesData)
  4945. }
  4946. // 人员信息版本4
  4947. 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) {
  4948. //生成签名
  4949. nonce := GetRandomString(32)
  4950. timestamp := time.Now().Unix()
  4951. //signature := setSignature(timestamp, nonce, secret_key)
  4952. //生成输入报文
  4953. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4954. input := make(map[string]interface{})
  4955. inputData := make(map[string]interface{})
  4956. inputMessage["infno"] = "1101" // 交易编码
  4957. if certificates == 3 {
  4958. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  4959. inputData["certno"] = certNo // 证件号码
  4960. inputData["psn_cert_type"] = "99" // 人员证件类型
  4961. } else {
  4962. if id_card_type == 1 {
  4963. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  4964. inputData["card_sn"] = "" // 卡识别码
  4965. inputData["certno"] = "" // 证件号码
  4966. inputData["psn_cert_type"] = "" // 人员证件类型
  4967. } else {
  4968. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  4969. inputData["card_sn"] = "" // 卡识别码
  4970. inputData["certno"] = certNo // 证件号码
  4971. inputData["psn_cert_type"] = "1" // 人员证件类型
  4972. }
  4973. }
  4974. inputData["mdtrt_cert_no"] = "" // 就诊凭证编号
  4975. inputData["begntime"] = "" // 开始时间
  4976. inputData["psn_name"] = "" // 人员姓名
  4977. input["data"] = inputData
  4978. inputMessage["input"] = input //交易输入
  4979. bytesData, err := json.Marshal(inputMessage)
  4980. fmt.Println(string(bytesData))
  4981. if err != nil {
  4982. fmt.Println(err.Error())
  4983. return err.Error(), ""
  4984. }
  4985. var json2 string
  4986. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  4987. out, err := cmd.Output()
  4988. if err != nil {
  4989. fmt.Println("error:", err.Error())
  4990. }
  4991. fmt.Println(string(out))
  4992. return string(out), string(bytesData)
  4993. }
  4994. func StrPtr(s string) uintptr {
  4995. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  4996. }
  4997. 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 {
  4998. //生成签名
  4999. nonce := GetRandomString(32)
  5000. timestamp := time.Now().Unix()
  5001. signature := setSignature(timestamp, nonce, secret_key)
  5002. //生成输入报文
  5003. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  5004. input := make(map[string]interface{})
  5005. inputData := make(map[string]interface{})
  5006. inputMessage["infno"] = "90991" // 交易编码
  5007. inputData["fixmedins_code"] = fixmedins_code // 就诊凭证编号
  5008. inputData["psn_no"] = psn_no // 开始时间
  5009. inputData["card_pwd"] = pwd // 人员姓名
  5010. inputData["sscno"] = card_number // 人员姓名
  5011. input["data"] = inputData
  5012. inputMessage["input"] = input //交易输入
  5013. bytesData, err := json.Marshal(inputMessage)
  5014. fmt.Println(string(bytesData))
  5015. if err != nil {
  5016. fmt.Println(err.Error())
  5017. return err.Error()
  5018. }
  5019. reader := bytes.NewReader(bytesData)
  5020. gdyb_url := beego.AppConfig.String("gdyb_url")
  5021. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5022. url := gdyb_url + "90991"
  5023. request, err := http.NewRequest("POST", url, reader)
  5024. if err != nil {
  5025. fmt.Println(err.Error())
  5026. return err.Error()
  5027. }
  5028. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5029. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5030. request.Header.Set("x-tif-signature", signature)
  5031. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5032. request.Header.Set("x-tif-nonce", nonce)
  5033. client := http.Client{}
  5034. resp, err := client.Do(request)
  5035. if err != nil {
  5036. fmt.Println(err.Error())
  5037. return err.Error()
  5038. }
  5039. respBytes, err := ioutil.ReadAll(resp.Body)
  5040. if err != nil {
  5041. fmt.Println(err.Error())
  5042. return err.Error()
  5043. }
  5044. fmt.Println(string(respBytes))
  5045. str := string(respBytes)
  5046. return str
  5047. }
  5048. func Gdyb90100(psn_no string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  5049. //生成签名
  5050. nonce := GetRandomString(32)
  5051. timestamp := time.Now().Unix()
  5052. signature := setSignature(timestamp, nonce, secret_key)
  5053. //生成输入报文
  5054. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  5055. input := make(map[string]interface{})
  5056. inputData := make(map[string]interface{})
  5057. inputMessage["infno"] = "90100" // 交易编码
  5058. inputData["psn_no"] = psn_no // 开始时间
  5059. input["data"] = inputData
  5060. inputMessage["input"] = input //交易输入
  5061. bytesData, err := json.Marshal(inputMessage)
  5062. fmt.Println(string(bytesData))
  5063. if err != nil {
  5064. fmt.Println(err.Error())
  5065. return err.Error()
  5066. }
  5067. reader := bytes.NewReader(bytesData)
  5068. gdyb_url := beego.AppConfig.String("gdyb_url")
  5069. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5070. url := gdyb_url + "90100"
  5071. request, err := http.NewRequest("POST", url, reader)
  5072. if err != nil {
  5073. fmt.Println(err.Error())
  5074. return err.Error()
  5075. }
  5076. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5077. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5078. request.Header.Set("x-tif-signature", signature)
  5079. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5080. request.Header.Set("x-tif-nonce", nonce)
  5081. client := http.Client{}
  5082. resp, err := client.Do(request)
  5083. if err != nil {
  5084. fmt.Println(err.Error())
  5085. return err.Error()
  5086. }
  5087. respBytes, err := ioutil.ReadAll(resp.Body)
  5088. if err != nil {
  5089. fmt.Println(err.Error())
  5090. return err.Error()
  5091. }
  5092. fmt.Println(string(respBytes))
  5093. str := string(respBytes)
  5094. return str
  5095. }
  5096. 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, count int) (string, string) {
  5097. //生成签名
  5098. nonce := GetRandomString(32)
  5099. timestamp := time.Now().Unix()
  5100. signature := setSignature(timestamp, nonce, secret_key)
  5101. //生成输入报文
  5102. inputMessage := SetInputMessageTwo(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, sign)
  5103. input := make(map[string]interface{})
  5104. inputData := make(map[string]interface{})
  5105. inputMessage["infno"] = "3260" // 交易编码
  5106. inputData["sign"] = sign // 就诊凭证编号
  5107. inputData["trt_year"] = year // 就诊凭证编号
  5108. inputData["trt_month"] = month // 开始时间
  5109. inputData["startrow"] = count // 人员姓名
  5110. input["data"] = inputData
  5111. inputMessage["input"] = input //交易输入
  5112. var inputLog string
  5113. bytesData, err := json.Marshal(inputMessage)
  5114. inputLog = string(bytesData)
  5115. fmt.Println(string(bytesData))
  5116. if err != nil {
  5117. fmt.Println(err.Error())
  5118. return err.Error(), ""
  5119. }
  5120. reader := bytes.NewReader(bytesData)
  5121. gdyb_url := beego.AppConfig.String("gdyb_url")
  5122. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5123. var url string
  5124. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5125. url = gdyb_url
  5126. } else {
  5127. url = gdyb_url + "3260"
  5128. }
  5129. {
  5130. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  5131. request, err := http.NewRequest("POST", url, reader)
  5132. if err != nil {
  5133. fmt.Println(err.Error())
  5134. return err.Error(), ""
  5135. }
  5136. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5137. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5138. request.Header.Set("x-tif-signature", signature)
  5139. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5140. request.Header.Set("x-tif-nonce", nonce)
  5141. client := http.Client{}
  5142. resp, err := client.Do(request)
  5143. if err != nil {
  5144. fmt.Println(err.Error())
  5145. return err.Error(), ""
  5146. }
  5147. respBytes, err := ioutil.ReadAll(resp.Body)
  5148. if err != nil {
  5149. fmt.Println(err.Error())
  5150. return err.Error(), ""
  5151. }
  5152. fmt.Println(string(respBytes))
  5153. str := string(respBytes)
  5154. return str, inputLog
  5155. }
  5156. }
  5157. 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) {
  5158. //msg_month := time.Unix(1557042972, 0).Format("1")
  5159. //msg_year := time.Now().Format("2006")
  5160. //msg_month = time.Now().Format("01")
  5161. //day := time.Now().Format("02")
  5162. //
  5163. //hour := time.Now().Format("15")
  5164. //min := time.Now().Format("04")
  5165. //sec := time.Now().Format("05")
  5166. //
  5167. //msec := time.Now().Format("000")
  5168. //msg_id := fixmedins_code + msg_year + msg_month + day + hour + min + sec + msec + "0"
  5169. feedetail := make([]map[string]interface{}, 0)
  5170. for _, subitem := range result3260 {
  5171. for _, item := range subitem.Output.Data {
  5172. if item.MdtrtId != "out20230406681871" && item.MdtrtId != "out20230406681868" {
  5173. feedetailInfo := make(map[string]interface{})
  5174. feedetailInfo["certno"] = item.Certno
  5175. feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5176. feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5177. feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5178. feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5179. feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5180. feedetailInfo["cnfm_flag"] = "1" // 处方号
  5181. feedetail = append(feedetail, feedetailInfo)
  5182. }
  5183. }
  5184. }
  5185. for _, subitem := range result3260 {
  5186. for _, item := range subitem.Output.Data {
  5187. if item.MdtrtId == "out20230406681871" {
  5188. feedetailInfo := make(map[string]interface{})
  5189. feedetailInfo["certno"] = item.Certno
  5190. feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5191. feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5192. feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5193. feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5194. feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5195. feedetailInfo["cnfm_flag"] = "0" // 处方号
  5196. feedetail = append(feedetail, feedetailInfo)
  5197. }
  5198. }
  5199. }
  5200. for _, subitem := range result3260 {
  5201. for _, item := range subitem.Output.Data {
  5202. if item.MdtrtId == "out20230406681868" {
  5203. feedetailInfo := make(map[string]interface{})
  5204. feedetailInfo["certno"] = item.Certno
  5205. feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5206. feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5207. feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5208. feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5209. feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5210. feedetailInfo["cnfm_flag"] = "0" // 处方号
  5211. feedetail = append(feedetail, feedetailInfo)
  5212. }
  5213. }
  5214. }
  5215. // 分页操作
  5216. pageSize := 100
  5217. pages := paginate(feedetail, pageSize)
  5218. //aa := 0
  5219. // 输出每一页的数据
  5220. for _, page := range pages {
  5221. nonce := GetRandomString(32)
  5222. timestamp := time.Now().Unix()
  5223. signature := setSignature(timestamp, nonce, secret_key)
  5224. //生成输入报文
  5225. //aa = aa + len(page)
  5226. //nonce := GetRandomString(32)
  5227. //timestamp := time.Now().Unix()
  5228. inputMessage := SetInputMessageTwo(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, sign_no)
  5229. input := make(map[string]interface{})
  5230. inputData := make(map[string]interface{})
  5231. inputMessage["infno"] = "3261" // 交易编码
  5232. inputData["trt_year"] = year // 就诊凭证编号
  5233. inputData["trt_month"] = month // 开始时间
  5234. inputData["totalrow"] = len(feedetail) // 人员姓名
  5235. input["data"] = inputData
  5236. input["detail"] = page
  5237. inputMessage["input"] = input //交易输入
  5238. //var inputLog string
  5239. bytesData, err := json.Marshal(inputMessage)
  5240. //inputLog = string(bytesData)
  5241. fmt.Println(string(bytesData))
  5242. if err != nil {
  5243. fmt.Println(err.Error())
  5244. return
  5245. }
  5246. reader := bytes.NewReader(bytesData)
  5247. gdyb_url := beego.AppConfig.String("gdyb_url")
  5248. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5249. var url string
  5250. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5251. url = gdyb_url
  5252. } else {
  5253. url = gdyb_url + "3261"
  5254. }
  5255. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  5256. request, err := http.NewRequest("POST", url, reader)
  5257. if err != nil {
  5258. fmt.Println(err.Error())
  5259. return
  5260. }
  5261. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5262. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5263. request.Header.Set("x-tif-signature", signature)
  5264. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5265. request.Header.Set("x-tif-nonce", nonce)
  5266. client := http.Client{}
  5267. resp, err := client.Do(request)
  5268. if err != nil {
  5269. fmt.Println(err.Error())
  5270. return
  5271. }
  5272. respBytes, err := ioutil.ReadAll(resp.Body)
  5273. if err != nil {
  5274. fmt.Println(err.Error())
  5275. return
  5276. }
  5277. fmt.Println(string(respBytes))
  5278. str := string(respBytes)
  5279. fmt.Println(str)
  5280. }
  5281. //for _, item := range result3260.Output.Data[start-1 : stop] {
  5282. // if item.MdtrtId != "out20230406681871" && item.MdtrtId != "out20230406681868" {
  5283. // feedetailInfo := make(map[string]interface{})
  5284. // feedetailInfo["certno"] = item.Certno
  5285. // feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5286. // feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5287. // feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5288. // feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5289. // feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5290. // feedetailInfo["cnfm_flag"] = "1" // 处方号
  5291. // feedetail = append(feedetail, feedetailInfo)
  5292. // }
  5293. //}
  5294. //for _, item := range result3260.Output.Data[start-1 : stop] {
  5295. // if item.MdtrtId == "out20230406681871" {
  5296. // feedetailInfo := make(map[string]interface{})
  5297. // feedetailInfo["certno"] = item.Certno
  5298. // feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5299. // feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5300. // feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5301. // feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5302. // feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5303. // feedetailInfo["cnfm_flag"] = "0" // 处方号
  5304. // feedetail = append(feedetail, feedetailInfo)
  5305. // }
  5306. //
  5307. //}
  5308. //for _, item := range result3260.Output.Data[start-1 : stop] {
  5309. // if item.MdtrtId == "out20230406681868" {
  5310. // feedetailInfo := make(map[string]interface{})
  5311. // feedetailInfo["certno"] = item.Certno
  5312. // feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5313. // feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5314. // feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5315. // feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5316. // feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5317. // feedetailInfo["cnfm_flag"] = "0" // 处方号
  5318. // feedetail = append(feedetail, feedetailInfo)
  5319. // }
  5320. //
  5321. //}
  5322. return
  5323. }
  5324. func Gdyb3263(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) {
  5325. //msg_month := time.Unix(1557042972, 0).Format("1")
  5326. //msg_year := time.Now().Format("2006")
  5327. //msg_month = time.Now().Format("01")
  5328. //day := time.Now().Format("02")
  5329. //
  5330. //hour := time.Now().Format("15")
  5331. //min := time.Now().Format("04")
  5332. //sec := time.Now().Format("05")
  5333. //
  5334. //msec := time.Now().Format("000")
  5335. //msg_id := fixmedins_code + msg_year + msg_month + day + hour + min + sec + msec + "0"
  5336. feedetail := make([]map[string]interface{}, 0)
  5337. for _, subitem := range result3260 {
  5338. for _, item := range subitem.Output.Data {
  5339. if item.MdtrtId != "out20230406681871" && item.MdtrtId != "out20230406681868" {
  5340. feedetailInfo := make(map[string]interface{})
  5341. feedetailInfo["certno"] = item.Certno
  5342. feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5343. feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5344. feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5345. feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5346. feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5347. feedetailInfo["cnfm_flag"] = "1" // 处方号
  5348. feedetail = append(feedetail, feedetailInfo)
  5349. }
  5350. }
  5351. }
  5352. for _, subitem := range result3260 {
  5353. for _, item := range subitem.Output.Data {
  5354. if item.MdtrtId == "out20230406681871" {
  5355. feedetailInfo := make(map[string]interface{})
  5356. feedetailInfo["certno"] = item.Certno
  5357. feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5358. feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5359. feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5360. feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5361. feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5362. feedetailInfo["cnfm_flag"] = "0" // 处方号
  5363. feedetail = append(feedetail, feedetailInfo)
  5364. }
  5365. }
  5366. }
  5367. for _, subitem := range result3260 {
  5368. for _, item := range subitem.Output.Data {
  5369. if item.MdtrtId == "out20230406681868" {
  5370. feedetailInfo := make(map[string]interface{})
  5371. feedetailInfo["certno"] = item.Certno
  5372. feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5373. feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5374. feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5375. feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5376. feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5377. feedetailInfo["cnfm_flag"] = "0" // 处方号
  5378. feedetail = append(feedetail, feedetailInfo)
  5379. }
  5380. }
  5381. }
  5382. var firstSlice, secondSlice []map[string]interface{}
  5383. if len(feedetail) > 500 {
  5384. firstSlice = feedetail[:500]
  5385. secondSlice = feedetail[500:]
  5386. } else {
  5387. firstSlice = feedetail
  5388. secondSlice = []map[string]interface{}{}
  5389. }
  5390. fmt.Println(firstSlice)
  5391. nonce := GetRandomString(32)
  5392. timestamp := time.Now().Unix()
  5393. signature := setSignature(timestamp, nonce, secret_key)
  5394. //生成输入报文
  5395. total := 0
  5396. for _, item := range result3260 {
  5397. total = total + len(item.Output.Data)
  5398. }
  5399. //nonce := GetRandomString(32)
  5400. //timestamp := time.Now().Unix()
  5401. inputMessage := SetInputMessageTwo(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, sign_no)
  5402. input := make(map[string]interface{})
  5403. inputData := make(map[string]interface{})
  5404. inputMessage["infno"] = "3261" // 交易编码
  5405. inputData["trt_year"] = year // 就诊凭证编号
  5406. inputData["trt_month"] = month // 开始时间
  5407. inputData["totalrow"] = len(secondSlice) // 人员姓名
  5408. input["data"] = inputData
  5409. input["detail"] = secondSlice
  5410. inputMessage["input"] = input //交易输入
  5411. //var inputLog string
  5412. bytesData, err := json.Marshal(inputMessage)
  5413. //inputLog = string(bytesData)
  5414. fmt.Println(string(bytesData))
  5415. if err != nil {
  5416. fmt.Println(err.Error())
  5417. return
  5418. }
  5419. reader := bytes.NewReader(bytesData)
  5420. gdyb_url := beego.AppConfig.String("gdyb_url")
  5421. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5422. var url string
  5423. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5424. url = gdyb_url
  5425. } else {
  5426. url = gdyb_url + "3261"
  5427. }
  5428. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  5429. request, err := http.NewRequest("POST", url, reader)
  5430. if err != nil {
  5431. fmt.Println(err.Error())
  5432. return
  5433. }
  5434. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5435. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5436. request.Header.Set("x-tif-signature", signature)
  5437. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5438. request.Header.Set("x-tif-nonce", nonce)
  5439. client := http.Client{}
  5440. resp, err := client.Do(request)
  5441. if err != nil {
  5442. fmt.Println(err.Error())
  5443. return
  5444. }
  5445. respBytes, err := ioutil.ReadAll(resp.Body)
  5446. if err != nil {
  5447. fmt.Println(err.Error())
  5448. return
  5449. }
  5450. fmt.Println(string(respBytes))
  5451. str := string(respBytes)
  5452. fmt.Println(str)
  5453. //for _, item := range result3260.Output.Data[start-1 : stop] {
  5454. // if item.MdtrtId != "out20230406681871" && item.MdtrtId != "out20230406681868" {
  5455. // feedetailInfo := make(map[string]interface{})
  5456. // feedetailInfo["certno"] = item.Certno
  5457. // feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5458. // feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5459. // feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5460. // feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5461. // feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5462. // feedetailInfo["cnfm_flag"] = "1" // 处方号
  5463. // feedetail = append(feedetail, feedetailInfo)
  5464. // }
  5465. //}
  5466. //for _, item := range result3260.Output.Data[start-1 : stop] {
  5467. // if item.MdtrtId == "out20230406681871" {
  5468. // feedetailInfo := make(map[string]interface{})
  5469. // feedetailInfo["certno"] = item.Certno
  5470. // feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5471. // feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5472. // feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5473. // feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5474. // feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5475. // feedetailInfo["cnfm_flag"] = "0" // 处方号
  5476. // feedetail = append(feedetail, feedetailInfo)
  5477. // }
  5478. //
  5479. //}
  5480. //for _, item := range result3260.Output.Data[start-1 : stop] {
  5481. // if item.MdtrtId == "out20230406681868" {
  5482. // feedetailInfo := make(map[string]interface{})
  5483. // feedetailInfo["certno"] = item.Certno
  5484. // feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5485. // feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5486. // feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5487. // feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5488. // feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5489. // feedetailInfo["cnfm_flag"] = "0" // 处方号
  5490. // feedetail = append(feedetail, feedetailInfo)
  5491. // }
  5492. //
  5493. //}
  5494. return
  5495. }
  5496. 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) {
  5497. //生成签名
  5498. nonce := GetRandomString(32)
  5499. timestamp := time.Now().Unix()
  5500. signature := setSignature(timestamp, nonce, secret_key)
  5501. //生成输入报文
  5502. inputMessage := SetInputMessageTwo(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, sign_no)
  5503. input := make(map[string]interface{})
  5504. inputData := make(map[string]interface{})
  5505. inputMessage["infno"] = "3262" // 交易编码
  5506. inputData["trt_year"] = year // 就诊凭证编号
  5507. inputData["trt_month"] = month // 开始时间
  5508. inputData["otransid"] = "0" // 开始时间
  5509. input["data"] = inputData
  5510. inputMessage["input"] = input //交易输入
  5511. var inputLog string
  5512. bytesData, err := json.Marshal(inputMessage)
  5513. inputLog = string(bytesData)
  5514. fmt.Println(string(bytesData))
  5515. if err != nil {
  5516. fmt.Println(err.Error())
  5517. return err.Error(), ""
  5518. }
  5519. reader := bytes.NewReader(bytesData)
  5520. gdyb_url := beego.AppConfig.String("gdyb_url")
  5521. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5522. var url string
  5523. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5524. url = gdyb_url
  5525. } else {
  5526. url = gdyb_url + "3262"
  5527. }
  5528. {
  5529. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  5530. request, err := http.NewRequest("POST", url, reader)
  5531. if err != nil {
  5532. fmt.Println(err.Error())
  5533. return err.Error(), ""
  5534. }
  5535. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5536. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5537. request.Header.Set("x-tif-signature", signature)
  5538. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5539. request.Header.Set("x-tif-nonce", nonce)
  5540. client := http.Client{}
  5541. resp, err := client.Do(request)
  5542. if err != nil {
  5543. fmt.Println(err.Error())
  5544. return err.Error(), ""
  5545. }
  5546. respBytes, err := ioutil.ReadAll(resp.Body)
  5547. if err != nil {
  5548. fmt.Println(err.Error())
  5549. return err.Error(), ""
  5550. }
  5551. fmt.Println(string(respBytes))
  5552. str := string(respBytes)
  5553. return str, inputLog
  5554. }
  5555. }
  5556. 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) {
  5557. //生成签名
  5558. nonce := GetRandomString(32)
  5559. timestamp := time.Now().Unix()
  5560. signature := setSignature(timestamp, nonce, "d6Ad0P1B3z6Dsdst0gYAFPlz8YlIvFDx")
  5561. inputMessage := make(map[string]interface{})
  5562. //生成输入报文
  5563. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5564. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  5565. } else {
  5566. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  5567. }
  5568. input := make(map[string]interface{})
  5569. inputData := make(map[string]interface{})
  5570. inputMessage["infno"] = "9001" // 交易编码
  5571. inputData["opter_no"] = admin_user_id // 就诊凭证编号
  5572. inputData["mac"] = "11-11-11-11-11" // 开始时间
  5573. inputData["ip"] = "11.11.11.11"
  5574. //inputData["userid"] = "H44010400081"
  5575. //month := time.Unix(1557042972, 0).Format("1")
  5576. //year := time.Now().Format("2006")
  5577. //month = time.Now().Format("01")
  5578. //day := time.Now().Format("02")
  5579. //hour := time.Now().Format("15")
  5580. //min := time.Now().Format("04")
  5581. //sec := time.Now().Format("05")
  5582. //custom_time := year + month + day + hour + min + sec
  5583. //inputData["currenttime"] = custom_time
  5584. //var psd string
  5585. //psd = custom_time + "Gzyb$867"
  5586. //h := md5.New()
  5587. //h.Write([]byte(psd))
  5588. //inputData["password"] = strings.ToUpper(hex.EncodeToString(h.Sum(nil)))
  5589. input["data"] = inputData
  5590. inputMessage["input"] = input //交易输入
  5591. var inputLog string
  5592. bytesData, err := json.Marshal(inputMessage)
  5593. inputLog = string(bytesData)
  5594. fmt.Println(string(bytesData))
  5595. if err != nil {
  5596. fmt.Println(err.Error())
  5597. return err.Error(), ""
  5598. }
  5599. reader := bytes.NewReader(bytesData)
  5600. gdyb_url := beego.AppConfig.String("gdyb_url")
  5601. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5602. var url string
  5603. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5604. url = gdyb_url
  5605. } else {
  5606. url = gdyb_url + "9001"
  5607. }
  5608. {
  5609. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  5610. request, err := http.NewRequest("POST", url, reader)
  5611. if err != nil {
  5612. fmt.Println(err.Error())
  5613. return err.Error(), ""
  5614. }
  5615. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5616. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5617. request.Header.Set("x-tif-signature", signature)
  5618. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5619. request.Header.Set("x-tif-nonce", nonce)
  5620. fmt.Println(string(bytesData))
  5621. fmt.Println(gdyb_url)
  5622. fmt.Println(gdyb_paasid)
  5623. fmt.Println(request.Header)
  5624. client := http.Client{}
  5625. resp, err := client.Do(request)
  5626. if err != nil {
  5627. fmt.Println(err.Error())
  5628. return err.Error(), ""
  5629. }
  5630. respBytes, err := ioutil.ReadAll(resp.Body)
  5631. if err != nil {
  5632. fmt.Println(err.Error())
  5633. return err.Error(), ""
  5634. }
  5635. fmt.Println(string(respBytes))
  5636. str := string(respBytes)
  5637. return str, inputLog
  5638. }
  5639. }
  5640. 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) {
  5641. //生成签名
  5642. nonce := GetRandomString(32)
  5643. timestamp := time.Now().Unix()
  5644. signature := setSignature(timestamp, nonce, secret_key)
  5645. inputMessage := make(map[string]interface{})
  5646. //生成输入报文
  5647. //生成输入报文
  5648. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5649. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  5650. } else {
  5651. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  5652. }
  5653. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  5654. input := make(map[string]interface{})
  5655. inputData := make(map[string]interface{})
  5656. inputMessage["infno"] = "9001" // 交易编码
  5657. inputData["opter_no"] = admin_user_id // 就诊凭证编号
  5658. inputData["mac"] = GetMac() // 开始时间
  5659. inputData["ip"] = GetLocalIp()
  5660. input["signIn"] = inputData
  5661. inputMessage["input"] = input //交易输入
  5662. var inputLog string
  5663. bytesData, err := json.Marshal(inputMessage)
  5664. inputLog = string(bytesData)
  5665. fmt.Println(string(bytesData))
  5666. if err != nil {
  5667. fmt.Println(err.Error())
  5668. return err.Error(), ""
  5669. }
  5670. reader := bytes.NewReader(bytesData)
  5671. gdyb_url := beego.AppConfig.String("gdyb_url")
  5672. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5673. var url string
  5674. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5675. url = gdyb_url
  5676. } else {
  5677. url = gdyb_url + "9001"
  5678. }
  5679. {
  5680. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  5681. request, err := http.NewRequest("POST", url, reader)
  5682. if err != nil {
  5683. fmt.Println(err.Error())
  5684. return err.Error(), ""
  5685. }
  5686. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5687. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5688. request.Header.Set("x-tif-signature", signature)
  5689. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5690. request.Header.Set("x-tif-nonce", nonce)
  5691. fmt.Println(string(bytesData))
  5692. fmt.Println(gdyb_url)
  5693. fmt.Println(gdyb_paasid)
  5694. fmt.Println(request.Header)
  5695. client := http.Client{}
  5696. resp, err := client.Do(request)
  5697. if err != nil {
  5698. fmt.Println(err.Error())
  5699. return err.Error(), ""
  5700. }
  5701. respBytes, err := ioutil.ReadAll(resp.Body)
  5702. if err != nil {
  5703. fmt.Println(err.Error())
  5704. return err.Error(), ""
  5705. }
  5706. fmt.Println(string(respBytes))
  5707. str := string(respBytes)
  5708. return str, inputLog
  5709. }
  5710. }
  5711. // 获取本机ip
  5712. func GetLocalIp() string {
  5713. addrs, err := net.InterfaceAddrs()
  5714. if err != nil {
  5715. fmt.Println("get local ip failed")
  5716. }
  5717. for _, address := range addrs {
  5718. if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
  5719. if ipnet.IP.To4() != nil {
  5720. return ipnet.IP.String()
  5721. }
  5722. }
  5723. }
  5724. return ""
  5725. }
  5726. // 获取本机Mac
  5727. func GetMac() string {
  5728. interfaces, err := net.Interfaces()
  5729. if err != nil {
  5730. fmt.Println("Get loacl Mac failed")
  5731. }
  5732. for _, inter := range interfaces {
  5733. mac := inter.HardwareAddr
  5734. fmt.Println("+======" + mac.String())
  5735. if mac.String() != "" {
  5736. return mac.String()
  5737. }
  5738. }
  5739. return ""
  5740. }
  5741. // 人员基本信息
  5742. 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, admin_user_id int64) (string, string) {
  5743. //生成签名
  5744. fmt.Println("DDDDD")
  5745. nonce := GetRandomString(32)
  5746. timestamp := time.Now().Unix()
  5747. signature := setSignature(timestamp, nonce, secret_key)
  5748. //生成输入报文
  5749. inputMessage := make(map[string]interface{})
  5750. //tempTime := time.Unix(timestamp, 0)
  5751. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  5752. // 生成输入报文
  5753. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5754. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  5755. } else {
  5756. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  5757. }
  5758. //inputMessage := SetInputMessagenosign(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  5759. input := make(map[string]interface{})
  5760. inputData := make(map[string]interface{})
  5761. inputMessage["infno"] = "1101" // 交易编码
  5762. if certificates == "3" {
  5763. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  5764. inputData["certno"] = certNo // 证件号码
  5765. inputData["psn_cert_type"] = "99" // 人员证件类型
  5766. } else {
  5767. if certificates == "1" {
  5768. if id_card_type == 1 {
  5769. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  5770. inputData["card_sn"] = "" // 卡识别码
  5771. inputData["certno"] = certNo // 证件号码
  5772. inputData["psn_cert_type"] = "01" // 人员证件类型
  5773. } else if id_card_type == 4 {
  5774. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  5775. inputData["certno"] = certNo // 证件号码
  5776. inputData["psn_cert_type"] = "01" // 人员证件类型
  5777. } else {
  5778. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  5779. inputData["card_sn"] = "" // 卡识别码
  5780. inputData["certno"] = certNo // 证件号码
  5781. inputData["psn_cert_type"] = "01" // 人员证件类型
  5782. }
  5783. } else if certificates == "6" {
  5784. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  5785. inputData["card_sn"] = "" // 卡识别码
  5786. inputData["certno"] = certNo // 证件号码
  5787. inputData["psn_cert_type"] = "17" // 人员证件类型
  5788. }
  5789. }
  5790. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  5791. inputData["begntime"] = "" // 开始时间
  5792. inputData["psn_name"] = "" // 人员姓名
  5793. input["data"] = inputData
  5794. inputMessage["input"] = input //交易输入
  5795. var inputLog string
  5796. bytesData, err := json.Marshal(inputMessage)
  5797. inputLog = string(bytesData)
  5798. fmt.Println(string(bytesData))
  5799. if err != nil {
  5800. fmt.Println(err.Error())
  5801. return err.Error(), ""
  5802. }
  5803. reader := bytes.NewReader(bytesData)
  5804. gdyb_url := beego.AppConfig.String("gdyb_url")
  5805. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5806. //DllDef := syscall.MustLoadDLL("yh_hb_sctrl.dll")
  5807. //Iinit := DllDef.MustFindProc("yh_hb_call")
  5808. //var str3 string
  5809. //ret, _, _ := Iinit.Call(StrPtr("1101"), StrPtr(string(bytesData)), StrPtr(str3))
  5810. //fmt.Println(ret)
  5811. //fmt.Println(str3)
  5812. //
  5813. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  5814. var url string
  5815. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5816. url = gdyb_url
  5817. } else {
  5818. url = gdyb_url + "1101"
  5819. }
  5820. {
  5821. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  5822. request, err := http.NewRequest("POST", url, reader)
  5823. if err != nil {
  5824. fmt.Println(err.Error())
  5825. return err.Error(), ""
  5826. }
  5827. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5828. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5829. request.Header.Set("x-tif-signature", signature)
  5830. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5831. request.Header.Set("x-tif-nonce", nonce)
  5832. client := http.Client{}
  5833. resp, err := client.Do(request)
  5834. if err != nil {
  5835. fmt.Println(err.Error())
  5836. return err.Error(), ""
  5837. }
  5838. respBytes, err := ioutil.ReadAll(resp.Body)
  5839. if err != nil {
  5840. fmt.Println(err.Error())
  5841. return err.Error(), ""
  5842. }
  5843. fmt.Println(string(respBytes))
  5844. str := string(respBytes)
  5845. return str, inputLog
  5846. }
  5847. }
  5848. //func SetInputMessageFour(nonce string, timestamp int64, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) map[string]interface{} {
  5849. // // 生成签名
  5850. // //tempTime := time.Unix(timestamp, 0)
  5851. // //timeFormat := tempTime.Format("20060102150405")
  5852. // //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  5853. // //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  5854. //
  5855. // msec := time.Now().Format("000")
  5856. // fmt.Println(utils.GetNetTime())
  5857. // // 生成输入报文
  5858. // inputMessage := make(map[string]interface{})
  5859. // inputMessage["msgid"] = fixmedins_code + utils.GetNetTime() + msec + "0" // 发送方报文 ID
  5860. // inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  5861. // inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  5862. // inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  5863. // inputMessage["dev_no"] = "" // 设备编号
  5864. // inputMessage["dev_safe_info"] = "" // 设备安全信息
  5865. // inputMessage["cainfo"] = "" // 数字签名信息
  5866. // inputMessage["signtype"] = "SM3" // 签名类型
  5867. // inputMessage["infver"] = "V1.0" // 接收方系统代码
  5868. // inputMessage["opter_type"] = "1" // 经办人类别
  5869. // inputMessage["opter"] = doctor // 经办人
  5870. // inputMessage["opter_name"] = doctor // 经办人姓名
  5871. // inputMessage["inf_time"] = utils.GetNetTime() // 交易时间
  5872. // inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  5873. // inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  5874. // inputMessage["sign_no"] = "" //交易签到流水号
  5875. // return inputMessage
  5876. //}
  5877. func Gdyb5302(psnNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  5878. // 生成签名
  5879. nonce := GetRandomString(32)
  5880. //timestamp := time.Now().Unix()
  5881. timestamp := time.Now().UnixNano() / 1e6
  5882. signature := setSignature(timestamp, nonce, secret_key)
  5883. // 生成输入报文
  5884. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  5885. input := make(map[string]interface{})
  5886. inputData := make(map[string]interface{})
  5887. inputMessage["infno"] = "5302" // 交易编码
  5888. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  5889. inputData["biz_appy_type"] = "03" // 人员编号 (来自1101接口返回)
  5890. input["data"] = inputData
  5891. inputMessage["input"] = input //交易输入
  5892. bytesData, err := json.Marshal(inputMessage)
  5893. fmt.Println(string(bytesData))
  5894. if err != nil {
  5895. fmt.Println(err.Error())
  5896. return err.Error()
  5897. }
  5898. reader := bytes.NewReader(bytesData)
  5899. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  5900. gdyb_url := beego.AppConfig.String("gdyb_url")
  5901. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5902. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  5903. url := gdyb_url + "5302"
  5904. request, err := http.NewRequest("POST", url, reader)
  5905. if err != nil {
  5906. fmt.Println(err.Error())
  5907. return err.Error()
  5908. }
  5909. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5910. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5911. request.Header.Set("x-tif-signature", signature)
  5912. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5913. request.Header.Set("x-tif-nonce", nonce)
  5914. client := http.Client{}
  5915. resp, err := client.Do(request)
  5916. if err != nil {
  5917. fmt.Println(err.Error())
  5918. return err.Error()
  5919. }
  5920. respBytes, err := ioutil.ReadAll(resp.Body)
  5921. if err != nil {
  5922. fmt.Println(err.Error())
  5923. return err.Error()
  5924. }
  5925. str := string(respBytes)
  5926. fmt.Println(str)
  5927. return str
  5928. }
  5929. func CreateSignIn(record *models.HisSignIn) (err error) {
  5930. err = writeDb.Save(&record).Error
  5931. return
  5932. }
  5933. func GetSignInInfo(code string) string {
  5934. var sign models.HisSignIn
  5935. err = readDb.Model(&models.HisSignIn{}).Where("fixmedins_code = ? AND status = 1", code).Last(&sign).Error
  5936. return sign.SignNo
  5937. }
  5938. func Gdyb3501(struct3501 models.Struct3501, secret_key string) (string, string) {
  5939. // 生成签名
  5940. nonce := GetRandomString(32)
  5941. timestamp := time.Now().Unix()
  5942. signature := setSignature(timestamp, nonce, secret_key)
  5943. // 生成输入报文
  5944. inputMessage := SetGdInputMessage(timestamp, struct3501.OrgName, struct3501.Opter, struct3501.Code, struct3501.InsuplcAdmdvs, struct3501.MdtrtareaAdmvs, struct3501.Cainfo)
  5945. input := make(map[string]interface{})
  5946. inputData := make(map[string]interface{})
  5947. inputMessage["infno"] = "3501" // 交易编码
  5948. inputData["med_list_codg"] = struct3501.MedListCodg // 定点医药机构目录编号
  5949. inputData["fixmedins_hilist_id"] = struct3501.FixmedinsHilistId // 定点医药机构目录编号
  5950. inputData["fixmedins_hilist_name"] = struct3501.FixmedinsHilistName // 定点医药机构目录名称
  5951. inputData["rx_flag"] = struct3501.RxFlag //
  5952. inputData["invdate"] = struct3501.Invdate // 人员编号 (来自1101接口返回)
  5953. inputData["inv_cnt"] = struct3501.InvCnt // 人员编号 (来自1101接口返回)
  5954. inputData["manu_lotnum"] = struct3501.ManuLotnum // 人员编号 (来自1101接口返回)
  5955. inputData["fixmedins_bchno"] = struct3501.FixmedinsBchno // 人员编号 (来自1101接口返回)
  5956. inputData["manu_date"] = struct3501.ManuDate // 人员编号 (来自1101接口返回)
  5957. inputData["expy_end"] = struct3501.ExpyEnd // 人员编号 (来自1101接口返回)
  5958. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  5959. feedetail := make([]map[string]interface{}, 0)
  5960. codes := strings.Split(struct3501.DrugTracCodg, ",")
  5961. for _, item := range codes {
  5962. if len(item) > 0 {
  5963. druginputData := make(map[string]interface{})
  5964. druginputData["drug_trac_codg"] = removeNonDigits(item)
  5965. feedetail = append(feedetail, druginputData)
  5966. }
  5967. }
  5968. inputData["drugtracinfo"] = feedetail
  5969. input["invinfo"] = inputData
  5970. inputMessage["input"] = input //交易输入
  5971. bytesData, err := json.Marshal(inputMessage)
  5972. fmt.Println(string(bytesData))
  5973. if err != nil {
  5974. fmt.Println(err.Error())
  5975. return err.Error(), ""
  5976. }
  5977. reader := bytes.NewReader(bytesData)
  5978. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  5979. gdyb_url := beego.AppConfig.String("gdyb_url")
  5980. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5981. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  5982. url := gdyb_url + "3501"
  5983. request, err := http.NewRequest("POST", url, reader)
  5984. if err != nil {
  5985. fmt.Println(err.Error())
  5986. return err.Error(), ""
  5987. }
  5988. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5989. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5990. request.Header.Set("x-tif-signature", signature)
  5991. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5992. request.Header.Set("x-tif-nonce", nonce)
  5993. client := http.Client{}
  5994. resp, err := client.Do(request)
  5995. if err != nil {
  5996. fmt.Println(err.Error())
  5997. return err.Error(), ""
  5998. }
  5999. respBytes, err := ioutil.ReadAll(resp.Body)
  6000. if err != nil {
  6001. fmt.Println(err.Error())
  6002. return err.Error(), ""
  6003. }
  6004. str := string(respBytes)
  6005. fmt.Println(str)
  6006. return str, string(bytesData)
  6007. }
  6008. func Gdyb3502(struct3502 models.Struct3502, secret_key string) (string, string) {
  6009. // 生成签名
  6010. nonce := GetRandomString(32)
  6011. timestamp := time.Now().Unix()
  6012. signature := setSignature(timestamp, nonce, secret_key)
  6013. // 生成输入报文
  6014. inputMessage := SetGdInputMessage(timestamp, struct3502.OrgName, struct3502.Opter, struct3502.FixmedinsCode, struct3502.InsuplcAdmdvs, struct3502.MdtrtareaAdmvs, struct3502.Cainfo)
  6015. input := make(map[string]interface{})
  6016. inputData := make(map[string]interface{})
  6017. inputMessage["infno"] = "3502" // 交易编码
  6018. inputData["med_list_codg"] = struct3502.MedListCodg // 定点医药机构目录编号
  6019. inputData["inv_chg_type"] = struct3502.InvChgType // 定点医药机构目录编号
  6020. inputData["fixmedins_hilist_id"] = struct3502.FixmedinsCode // 定点医药机构目录编号
  6021. inputData["fixmedins_hilist_name"] = struct3502.FixmedinsHilistName // 定点医药机构目录名称
  6022. inputData["fixmedins_bchno"] = struct3502.FixmedinsBchno // 人员编号 (来自1101接口返回)
  6023. inputData["pric"] = struct3502.Pric // 人员编号 (来自1101接口返回)
  6024. inputData["cnt"] = struct3502.Cnt // 人员编号 (来自1101接口返回)
  6025. inputData["rx_flag"] = struct3502.RxFlag //
  6026. inputData["inv_chg_time"] = struct3502.InvChgTime // 人员编号 (来自1101接口返回)
  6027. inputData["inv_chg_opter_name"] = "" // 人员编号 (来自1101接口返回)
  6028. inputData["memo"] = struct3502.Memo // 人员编号 (来自1101接口返回)
  6029. inputData["trdn_flag"] = "" // 人员编号 (来自1101接口返回)
  6030. input["invinfo"] = inputData
  6031. //feedetail := make([]map[string]interface{}, 0)
  6032. //druginputData := make(map[string]interface{})
  6033. //druginputData["drug_trac_codg"] = struct3502.DrugTracCodg
  6034. //feedetail = append(feedetail, druginputData)
  6035. //inputData["drugtracinfo"] = feedetail
  6036. feedetail := make([]map[string]interface{}, 0)
  6037. codes := strings.Split(struct3502.DrugTracCodg, ",")
  6038. for _, item := range codes {
  6039. if len(item) > 0 {
  6040. druginputData := make(map[string]interface{})
  6041. druginputData["drug_trac_codg"] = item
  6042. feedetail = append(feedetail, druginputData)
  6043. }
  6044. }
  6045. inputData["drugtracinfo"] = feedetail
  6046. input["invinfo"] = inputData
  6047. inputMessage["input"] = input //交易输入
  6048. bytesData, err := json.Marshal(inputMessage)
  6049. fmt.Println(string(bytesData))
  6050. if err != nil {
  6051. fmt.Println(err.Error())
  6052. return err.Error(), ""
  6053. }
  6054. reader := bytes.NewReader(bytesData)
  6055. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6056. gdyb_url := beego.AppConfig.String("gdyb_url")
  6057. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6058. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6059. url := gdyb_url + "3502"
  6060. request, err := http.NewRequest("POST", url, reader)
  6061. if err != nil {
  6062. fmt.Println(err.Error())
  6063. return err.Error(), ""
  6064. }
  6065. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6066. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6067. request.Header.Set("x-tif-signature", signature)
  6068. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6069. request.Header.Set("x-tif-nonce", nonce)
  6070. client := http.Client{}
  6071. resp, err := client.Do(request)
  6072. if err != nil {
  6073. fmt.Println(err.Error())
  6074. return err.Error(), ""
  6075. }
  6076. respBytes, err := ioutil.ReadAll(resp.Body)
  6077. if err != nil {
  6078. fmt.Println(err.Error())
  6079. return err.Error(), ""
  6080. }
  6081. str := string(respBytes)
  6082. fmt.Println(str)
  6083. return str, string(bytesData)
  6084. }
  6085. func Gdyb3503(struct3503 models.Struct3503, secret_key string) (string, string) {
  6086. // 生成签名
  6087. nonce := GetRandomString(32)
  6088. timestamp := time.Now().Unix()
  6089. signature := setSignature(timestamp, nonce, secret_key)
  6090. // 生成输入报文
  6091. inputMessage := SetGdInputMessage(timestamp, struct3503.OrgName, struct3503.Opter, struct3503.FixmedinsHilistId, struct3503.InsuplcAdmdvs, struct3503.MdtrtareaAdmvs, struct3503.Cainfo)
  6092. input := make(map[string]interface{})
  6093. inputMessage["infno"] = "3503"
  6094. item := struct3503
  6095. feedetailInfo := make(map[string]interface{})
  6096. feedetailInfo["med_list_codg"] = item.MedListCodg
  6097. feedetailInfo["fixmedins_hilist_id"] = item.FixmedinsHilistId
  6098. feedetailInfo["fixmedins_hilist_name"] = item.FixmedinsHilistName
  6099. feedetailInfo["dynt_no"] = ""
  6100. feedetailInfo["fixmedins_bchno"] = item.FixmedinsBchno // 人员编号 (来自1101接口返回)
  6101. feedetailInfo["spler_name"] = item.SplerName // 人员编号 (来自1101接口返回)
  6102. feedetailInfo["spler_pmtno"] = "" // 人员编号 (来自1101接口返回)
  6103. feedetailInfo["manu_lotnum"] = item.ManuLotnum // 人员编号 (来自1101接口返回)
  6104. feedetailInfo["prodentp_name"] = item.ProdentpName // 人员编号 (来自1101接口返回)
  6105. feedetailInfo["aprvno"] = item.Aprvno // 人员编号 (来自1101接口返回)
  6106. feedetailInfo["manu_date"] = item.ManuDate // 人员编号 (来自1101接口返回)
  6107. feedetailInfo["expy_end"] = item.ExpyEnd // 人员编号 (来自1101接口返回)
  6108. feedetailInfo["finl_trns_pric"] = item.FinlTrnsPric // 人员编号 (来自1101接口返回)
  6109. feedetailInfo["purc_retn_cnt"] = item.PurcRetnCnt // 人员编号 (来自1101接口返回)
  6110. feedetailInfo["purc_invo_codg"] = item.PurcInvoCodg // 人员编号 (来自1101接口返回)
  6111. feedetailInfo["purc_invo_no"] = item.PurcInvoNo // 人员编号 (来自1101接口返回)
  6112. feedetailInfo["rx_flag"] = item.RxFlag // 人员编号 (来自1101接口返回)
  6113. feedetailInfo["purc_retn_stoin_time"] = item.PurcRetnStoinTime // 人员编号 (来自1101接口返回)
  6114. feedetailInfo["purc_retn_opter_name"] = item.PurcRetnOpterName // 人员编号 (来自1101接口返回)
  6115. feedetailInfo["prod_geay_flag"] = "" // 人员编号 (来自1101接口返回)
  6116. feedetailInfo["memo"] = "" // 人员编号 (来自1101接口返回)
  6117. input["purcinfo"] = feedetailInfo
  6118. inputMessage["input"] = input //交易输入
  6119. bytesData, err := json.Marshal(inputMessage)
  6120. fmt.Println(string(bytesData))
  6121. if err != nil {
  6122. fmt.Println(err.Error())
  6123. return err.Error(), ""
  6124. }
  6125. reader := bytes.NewReader(bytesData)
  6126. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6127. gdyb_url := beego.AppConfig.String("gdyb_url")
  6128. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6129. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6130. url := gdyb_url + "3503"
  6131. request, err := http.NewRequest("POST", url, reader)
  6132. if err != nil {
  6133. fmt.Println(err.Error())
  6134. return err.Error(), ""
  6135. }
  6136. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6137. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6138. request.Header.Set("x-tif-signature", signature)
  6139. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6140. request.Header.Set("x-tif-nonce", nonce)
  6141. client := http.Client{}
  6142. resp, err := client.Do(request)
  6143. if err != nil {
  6144. fmt.Println(err.Error())
  6145. return err.Error(), ""
  6146. }
  6147. respBytes, err := ioutil.ReadAll(resp.Body)
  6148. if err != nil {
  6149. fmt.Println(err.Error())
  6150. return err.Error(), ""
  6151. }
  6152. str := string(respBytes)
  6153. fmt.Println(str)
  6154. return str, string(bytesData)
  6155. }
  6156. func Gdyb3504(struct3504 models.Struct3504, secret_key string) (string, string) {
  6157. // 生成签名
  6158. nonce := GetRandomString(32)
  6159. timestamp := time.Now().Unix()
  6160. signature := setSignature(timestamp, nonce, secret_key)
  6161. // 生成输入报文
  6162. inputMessage := SetGdInputMessage(timestamp, struct3504.OrgName, struct3504.Opter, struct3504.FixmedinsCode, struct3504.InsuplcAdmdvs, struct3504.MdtrtareaAdmvs, struct3504.Cainfo)
  6163. input := make(map[string]interface{})
  6164. inputData := make(map[string]interface{})
  6165. inputMessage["infno"] = "3504" // 交易编码
  6166. inputData["med_list_codg"] = struct3504.MedListCodg // 定点医药机构目录编号
  6167. inputData["fixmedins_hilist_id"] = struct3504.FixmedinsHilistId // 定点医药机构目录编号
  6168. inputData["fixmedins_hilist_name"] = struct3504.FixmedinsHilistName // 定点医药机构目录名称
  6169. inputData["fixmedins_bchno"] = struct3504.FixmedinsBchno // 人员编号 (来自1101接口返回)
  6170. inputData["spler_name"] = struct3504.SplerName // 人员编号 (来自1101接口返回)
  6171. inputData["spler_pmtno"] = "" // 人员编号 (来自1101接口返回)
  6172. inputData["manu_date"] = struct3504.ManuDate // 人员编号 (来自1101接口返回)
  6173. inputData["expy_end"] = struct3504.ExpyEnd // 人员编号 (来自1101接口返回)
  6174. inputData["finl_trns_pric"] = struct3504.FinlTrnsPric // 人员编号 (来自1101接口返回)
  6175. inputData["purc_retn_cnt"] = struct3504.PurcRetnCnt // 人员编号 (来自1101接口返回)
  6176. inputData["purc_invo_codg"] = struct3504.PurcInvoCodg // 人员编号 (来自1101接口返回)
  6177. inputData["purc_invo_no"] = struct3504.PurcInvoNo // 人员编号 (来自1101接口返回)
  6178. inputData["rx_flag"] = struct3504.RxFlag // 人员编号 (来自1101接口返回)
  6179. inputData["purc_retn_stoin_time"] = struct3504.PurcRetnStoinTime // 人员编号 (来自1101接口返回)
  6180. inputData["purc_retn_opter_name"] = struct3504.PurcRetnOpterName // 人员编号 (来自1101接口返回)
  6181. inputData["medins_prod_purc_no"] = "" // 人员编号 (来自1101接口返回)
  6182. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  6183. input["purcinfo"] = inputData
  6184. inputMessage["input"] = input //交易输入
  6185. bytesData, err := json.Marshal(inputMessage)
  6186. fmt.Println(string(bytesData))
  6187. if err != nil {
  6188. fmt.Println(err.Error())
  6189. return err.Error(), ""
  6190. }
  6191. reader := bytes.NewReader(bytesData)
  6192. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6193. gdyb_url := beego.AppConfig.String("gdyb_url")
  6194. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6195. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6196. url := gdyb_url + "3504"
  6197. request, err := http.NewRequest("POST", url, reader)
  6198. if err != nil {
  6199. fmt.Println(err.Error())
  6200. return err.Error(), ""
  6201. }
  6202. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6203. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6204. request.Header.Set("x-tif-signature", signature)
  6205. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6206. request.Header.Set("x-tif-nonce", nonce)
  6207. client := http.Client{}
  6208. resp, err := client.Do(request)
  6209. if err != nil {
  6210. fmt.Println(err.Error())
  6211. return err.Error(), ""
  6212. }
  6213. respBytes, err := ioutil.ReadAll(resp.Body)
  6214. if err != nil {
  6215. fmt.Println(err.Error())
  6216. return err.Error(), ""
  6217. }
  6218. str := string(respBytes)
  6219. fmt.Println(str)
  6220. return str, string(bytesData)
  6221. }
  6222. func Gdyb3505(struct3505 models.Struct3505, secret_key string) (string, string) {
  6223. // 生成签名
  6224. nonce := GetRandomString(32)
  6225. timestamp := time.Now().Unix()
  6226. signature := setSignature(timestamp, nonce, secret_key)
  6227. // 生成输入报文
  6228. inputMessage := SetGdInputMessage(timestamp, struct3505.OrgName, struct3505.Opter, struct3505.Code, struct3505.InsuplcAdmdvs, struct3505.MdtrtareaAdmvs, struct3505.Cainfo)
  6229. input := make(map[string]interface{})
  6230. inputData := make(map[string]interface{})
  6231. inputMessage["infno"] = "3505" // 交易编码
  6232. inputData["med_list_codg"] = struct3505.MedListCodg // 定点医药机构目录编号
  6233. inputData["fixmedins_hilist_id"] = struct3505.FixmedinsHilistId // 定点医药机构目录编号
  6234. inputData["fixmedins_hilist_name"] = struct3505.FixmedinsHilistName // 定点医药机构目录名称
  6235. inputData["fixmedins_bchno"] = struct3505.FixmedinsBchno // 人员编号 (来自1101接口返回)
  6236. inputData["prsc_dr_cert_type"] = struct3505.PrscDrCertType // 人员编号 (来自1101接口返回)
  6237. inputData["prsc_dr_certno"] = struct3505.PrscDrCertno // 人员编号 (来自1101接口返回)
  6238. inputData["prsc_dr_name"] = struct3505.PrscDrName // 人员编号 (来自1101接口返回)
  6239. inputData["phar_cert_type"] = struct3505.PharCertType // 人员编号 (来自1101接口返回)
  6240. inputData["phar_certno"] = struct3505.PharCertno // 人员编号 (来自1101接口返回)
  6241. inputData["phar_name"] = struct3505.PharName // 人员编号 (来自1101接口返回)
  6242. inputData["phar_prac_cert_no"] = struct3505.PharPracCertNo // 人员编号 (来自1101接口返回)
  6243. inputData["hi_feesetl_type"] = struct3505.HiFeesetlType // 人员编号 (来自1101接口返回)
  6244. inputData["setl_id"] = struct3505.SetlId // 人员编号 (来自1101接口返回)
  6245. inputData["mdtrt_sn"] = struct3505.MdtrtSn // 人员编号 (来自1101接口返回)
  6246. inputData["psn_no"] = struct3505.PsnNo // 人员编号 (来自1101接口返回)
  6247. inputData["psn_cert_type"] = struct3505.PsnCertType // 人员编号 (来自1101接口返回)
  6248. inputData["certno"] = struct3505.CertNo // 人员编号 (来自1101接口返回)
  6249. inputData["psn_name"] = struct3505.PsnName // 人员编号 (来自1101接口返回)
  6250. inputData["manu_lotnum"] = struct3505.ManuLotnum // 人员编号 (来自1101接口返回)
  6251. inputData["manu_date"] = struct3505.ManuDate // 人员编号 (来自1101接口返回)
  6252. inputData["expy_end"] = struct3505.ExpyEnd // 人员编号 (来自1101接口返回)
  6253. inputData["rx_flag"] = struct3505.RxFlag // 人员编号 (来自1101接口返回)
  6254. inputData["trdn_flag"] = struct3505.TrdnFlag // 人员编号 (来自1101接口返回)
  6255. inputData["finl_trns_pric"] = struct3505.FinlTrnsPric // 人员编号 (来自1101接口返回)
  6256. inputData["rxno"] = struct3505.Rxno // 人员编号 (来自1101接口返回)
  6257. inputData["rx_circ_flag"] = struct3505.RxCircFlag // 人员编号 (来自1101接口返回)
  6258. inputData["rtal_docno"] = struct3505.RtalDocno // 人员编号 (来自1101接口返回)
  6259. inputData["stoout_no"] = struct3505.StooutNo // 人员编号 (来自1101接口返回)
  6260. inputData["MDTRT_SETL_TYPE"] = struct3505.MdtrtSetlType // 人员编号 (来自1101接口返回)
  6261. inputData["bchno"] = struct3505.Bchno // 人员编号 (来自1101接口返回)
  6262. inputData["drug_trac_codg"] = "--" // 人员编号 (来自1101接口返回)
  6263. inputData["drug_prod_barc"] = struct3505.DrugProdBarc // 人员编号 (来自1101接口返回)
  6264. inputData["shelf_posi"] = struct3505.ShelfPosi // 人员编号 (来自1101接口返回)
  6265. inputData["sel_retn_cnt"] = struct3505.SelRetnCnt // 人员编号 (来自1101接口返回)
  6266. inputData["sel_retn_time"] = struct3505.SelRetnTime // 人员编号 (来自1101接口返回)
  6267. inputData["sel_retn_opter_name"] = struct3505.SelRetnOpterName // 人员编号 (来自1101接口返回)
  6268. inputData["memo"] = struct3505.Memo // 人员编号 (来自1101接口返回)
  6269. //input["selinfo"] = inputData
  6270. feedetail := make([]map[string]interface{}, 0)
  6271. codes := strings.Split(struct3505.DrugTracCodg, ",")
  6272. for _, item := range codes {
  6273. if len(item) > 0 {
  6274. druginputData := make(map[string]interface{})
  6275. druginputData["drug_trac_codg"] = removeNonDigits(item)
  6276. feedetail = append(feedetail, druginputData)
  6277. }
  6278. }
  6279. inputData["drugtracinfo"] = feedetail
  6280. input["selinfo"] = inputData
  6281. inputMessage["input"] = input //交易输入
  6282. bytesData, err := json.Marshal(inputMessage)
  6283. fmt.Println(string(bytesData))
  6284. if err != nil {
  6285. fmt.Println(err.Error())
  6286. return err.Error(), ""
  6287. }
  6288. reader := bytes.NewReader(bytesData)
  6289. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6290. gdyb_url := beego.AppConfig.String("gdyb_url")
  6291. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6292. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6293. url := gdyb_url + "3505"
  6294. request, err := http.NewRequest("POST", url, reader)
  6295. if err != nil {
  6296. fmt.Println(err.Error())
  6297. return err.Error(), ""
  6298. }
  6299. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6300. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6301. request.Header.Set("x-tif-signature", signature)
  6302. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6303. request.Header.Set("x-tif-nonce", nonce)
  6304. client := http.Client{}
  6305. resp, err := client.Do(request)
  6306. if err != nil {
  6307. fmt.Println(err.Error())
  6308. return err.Error(), ""
  6309. }
  6310. respBytes, err := ioutil.ReadAll(resp.Body)
  6311. if err != nil {
  6312. fmt.Println(err.Error())
  6313. return err.Error(), ""
  6314. }
  6315. str := string(respBytes)
  6316. fmt.Println(str)
  6317. return str, ""
  6318. }
  6319. func removeNonDigits(input string) string {
  6320. // 使用正则表达式匹配所有非数字字符
  6321. re := regexp.MustCompile(`\D`)
  6322. // 将所有非数字字符替换为空字符串
  6323. return re.ReplaceAllString(input, "")
  6324. }
  6325. func Gdyb3506(struct3506 models.Struct3506, secret_key string) (string, string) {
  6326. // 生成签名
  6327. nonce := GetRandomString(32)
  6328. timestamp := time.Now().Unix()
  6329. signature := setSignature(timestamp, nonce, secret_key)
  6330. // 生成输入报文
  6331. inputMessage := SetGdInputMessage(timestamp, struct3506.OrgName, struct3506.Opter, struct3506.FixmedinsCode, struct3506.InsuplcAdmdvs, struct3506.MdtrtareaAdmvs, struct3506.Cainfo)
  6332. input := make(map[string]interface{})
  6333. inputData := make(map[string]interface{})
  6334. inputMessage["infno"] = "3506" // 交易编码
  6335. inputData["med_list_codg"] = struct3506.MedListCodg // 定点医药机构目录编号
  6336. inputData["fixmedins_hilist_id"] = struct3506.FixmedinsHilistId // 定点医药机构目录编号
  6337. inputData["fixmedins_hilist_name"] = struct3506.FixmedinsHilistName // 定点医药机构目录名称
  6338. inputData["fixmedins_bchno"] = struct3506.FixmedinsBchno // 人员编号 (来自1101接口返回)
  6339. inputData["setl_id"] = struct3506.SetlId // 人员编号 (来自1101接口返回)
  6340. inputData["psn_no"] = struct3506.PsnNo // 人员编号 (来自1101接口返回)
  6341. inputData["psn_cert_type"] = struct3506.PsnCertType // 人员编号 (来自1101接口返回)
  6342. inputData["certno"] = struct3506.Certno // 人员编号 (来自1101接口返回)
  6343. inputData["psn_name"] = struct3506.PsnName // 人员编号 (来自1101接口返回)
  6344. inputData["manu_lotnum"] = struct3506.ManuLotnum // 人员编号 (来自1101接口返回)
  6345. inputData["manu_date"] = struct3506.ManuDate // 人员编号 (来自1101接口返回)
  6346. inputData["expy_end"] = struct3506.ExpyEnd // 人员编号 (来自1101接口返回)
  6347. inputData["rx_flag"] = struct3506.RxFlag // 人员编号 (来自1101接口返回)
  6348. inputData["trdn_flag"] = struct3506.TrdnFlag // 人员编号 (来自1101接口返回)
  6349. inputData["finl_trns_pric"] = struct3506.FinlTrnsPric // 人员编号 (来自1101接口返回)
  6350. inputData["sel_retn_cnt"] = struct3506.SelRetnCnt // 人员编号 (来自1101接口返回)
  6351. inputData["sel_retn_time"] = struct3506.SelRetnTime // 人员编号 (来自1101接口返回)
  6352. inputData["sel_retn_opter_name"] = struct3506.SelRetnOpterName // 人员编号 (来自1101接口返回)
  6353. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  6354. inputData["medins_prod_sel_no"] = "" // 人员编号 (来自1101接口返回)
  6355. input["selinfo"] = inputData
  6356. inputMessage["input"] = input //交易输入
  6357. bytesData, err := json.Marshal(inputMessage)
  6358. fmt.Println(string(bytesData))
  6359. if err != nil {
  6360. fmt.Println(err.Error())
  6361. return err.Error(), ""
  6362. }
  6363. reader := bytes.NewReader(bytesData)
  6364. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6365. gdyb_url := beego.AppConfig.String("gdyb_url")
  6366. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6367. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6368. url := gdyb_url + "3506"
  6369. request, err := http.NewRequest("POST", url, reader)
  6370. if err != nil {
  6371. fmt.Println(err.Error())
  6372. return err.Error(), ""
  6373. }
  6374. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6375. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6376. request.Header.Set("x-tif-signature", signature)
  6377. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6378. request.Header.Set("x-tif-nonce", nonce)
  6379. client := http.Client{}
  6380. resp, err := client.Do(request)
  6381. if err != nil {
  6382. fmt.Println(err.Error())
  6383. return err.Error(), ""
  6384. }
  6385. respBytes, err := ioutil.ReadAll(resp.Body)
  6386. if err != nil {
  6387. fmt.Println(err.Error())
  6388. return err.Error(), ""
  6389. }
  6390. str := string(respBytes)
  6391. fmt.Println(str)
  6392. return str, string(bytesData)
  6393. }
  6394. func Gdyb3507(struct3507 models.Struct3507, secret_key string) (string, string) {
  6395. // 生成签名
  6396. nonce := GetRandomString(32)
  6397. timestamp := time.Now().Unix()
  6398. signature := setSignature(timestamp, nonce, secret_key)
  6399. // 生成输入报文
  6400. inputMessage := SetGdInputMessage(timestamp, struct3507.OrgName, struct3507.Opter, struct3507.FixmedinsCode, struct3507.InsuplcAdmdvs, struct3507.MdtrtareaAdmvs, struct3507.Cainfo)
  6401. input := make(map[string]interface{})
  6402. inputData := make(map[string]interface{})
  6403. inputMessage["infno"] = "3507" // 交易编码
  6404. inputData["fixmedins_bchno"] = struct3507.FixmedinsBchno // 人员编号 (来自1101接口返回)
  6405. inputData["inv_data_type"] = struct3507.InvDataType // 人员编号 (来自1101接口返回)
  6406. input["data"] = inputData
  6407. inputMessage["input"] = input //交易输入
  6408. bytesData, err := json.Marshal(inputMessage)
  6409. fmt.Println(string(bytesData))
  6410. if err != nil {
  6411. fmt.Println(err.Error())
  6412. return err.Error(), ""
  6413. }
  6414. reader := bytes.NewReader(bytesData)
  6415. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6416. gdyb_url := beego.AppConfig.String("gdyb_url")
  6417. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6418. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6419. url := gdyb_url + "3507"
  6420. request, err := http.NewRequest("POST", url, reader)
  6421. if err != nil {
  6422. fmt.Println(err.Error())
  6423. return err.Error(), ""
  6424. }
  6425. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6426. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6427. request.Header.Set("x-tif-signature", signature)
  6428. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6429. request.Header.Set("x-tif-nonce", nonce)
  6430. client := http.Client{}
  6431. resp, err := client.Do(request)
  6432. if err != nil {
  6433. fmt.Println(err.Error())
  6434. return err.Error(), ""
  6435. }
  6436. respBytes, err := ioutil.ReadAll(resp.Body)
  6437. if err != nil {
  6438. fmt.Println(err.Error())
  6439. return err.Error(), ""
  6440. }
  6441. str := string(respBytes)
  6442. fmt.Println(str)
  6443. return str, string(bytesData)
  6444. }
  6445. func Gdyb3508(struct3508 models.Struct3508, secret_key string) (string, string) {
  6446. // 生成签名
  6447. nonce := GetRandomString(32)
  6448. timestamp := time.Now().Unix()
  6449. signature := setSignature(timestamp, nonce, secret_key)
  6450. // 生成输入报文
  6451. inputMessage := SetGdInputMessage(timestamp, struct3508.OrgName, struct3508.Opter, struct3508.FixmedinsCode, struct3508.InsuplcAdmdvs, struct3508.MdtrtareaAdmvs, struct3508.Cainfo)
  6452. input := make(map[string]interface{})
  6453. inputData := make(map[string]interface{})
  6454. inputMessage["infno"] = "3508"
  6455. inputData["fixmedins_code"] = struct3508.FixmedinsCode
  6456. inputData["medins_list_codg"] = struct3508.MedListCodg
  6457. inputData["fixmedins_bchno"] = ""
  6458. inputData["begndate"] = struct3508.Begndate
  6459. inputData["enddate"] = struct3508.Enddate
  6460. inputData["medins_prod_inv_no"] = ""
  6461. inputData["medins_list_name"] = ""
  6462. inputData["rx_flag"] = ""
  6463. inputData["list_sp_item_flag"] = ""
  6464. inputData["trdn_flag"] = ""
  6465. inputData["invdate"] = ""
  6466. inputData["manu_lotnum"] = ""
  6467. inputData["manu_date"] = ""
  6468. inputData["expy_end"] = ""
  6469. inputData["memo"] = ""
  6470. inputData["vali_flag"] = ""
  6471. inputData["rid"] = ""
  6472. inputData["crter_id"] = ""
  6473. inputData["crter_name"] = ""
  6474. inputData["crte_optins_no"] = ""
  6475. inputData["opter_id"] = ""
  6476. inputData["opter_name"] = ""
  6477. inputData["optins_no"] = ""
  6478. inputData["poolarea_no"] = ""
  6479. inputData["fixmedins_bchno"] = ""
  6480. inputData["inv_data_type"] = ""
  6481. input["data"] = inputData
  6482. inputMessage["input"] = input //交易输入
  6483. bytesData, err := json.Marshal(inputMessage)
  6484. fmt.Println(string(bytesData))
  6485. if err != nil {
  6486. fmt.Println(err.Error())
  6487. return err.Error(), ""
  6488. }
  6489. reader := bytes.NewReader(bytesData)
  6490. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6491. gdyb_url := beego.AppConfig.String("gdyb_url")
  6492. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6493. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6494. url := gdyb_url + "3508"
  6495. request, err := http.NewRequest("POST", url, reader)
  6496. if err != nil {
  6497. fmt.Println(err.Error())
  6498. return err.Error(), ""
  6499. }
  6500. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6501. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6502. request.Header.Set("x-tif-signature", signature)
  6503. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6504. request.Header.Set("x-tif-nonce", nonce)
  6505. client := http.Client{}
  6506. resp, err := client.Do(request)
  6507. if err != nil {
  6508. fmt.Println(err.Error())
  6509. return err.Error(), ""
  6510. }
  6511. respBytes, err := ioutil.ReadAll(resp.Body)
  6512. if err != nil {
  6513. fmt.Println(err.Error())
  6514. return err.Error(), ""
  6515. }
  6516. str := string(respBytes)
  6517. fmt.Println(str)
  6518. return str, string(bytesData)
  6519. }
  6520. func Gdyb3509(struct3509 models.Struct3509, secret_key string) (string, string) {
  6521. // 生成签名
  6522. nonce := GetRandomString(32)
  6523. timestamp := time.Now().Unix()
  6524. signature := setSignature(timestamp, nonce, secret_key)
  6525. // 生成输入报文
  6526. inputMessage := SetGdInputMessage(timestamp, struct3509.OrgName, struct3509.Opter, struct3509.FixmedinsCode, struct3509.InsuplcAdmdvs, struct3509.MdtrtareaAdmvs, struct3509.Cainfo)
  6527. input := make(map[string]interface{})
  6528. inputData := make(map[string]interface{})
  6529. inputMessage["infno"] = "3509"
  6530. inputData["fixmedins_code"] = struct3509.FixmedinsCode
  6531. //inputData["med_list_codg"] = struct3509.MedinsListCodg
  6532. inputData["medins_list_codg"] = struct3509.MedListCodg
  6533. inputData["fixmedins_bchno"] = ""
  6534. inputData["begndate"] = struct3509.Begndate
  6535. inputData["enddate"] = struct3509.Enddate
  6536. inputData["medins_prod_inv_no"] = ""
  6537. inputData["medins_list_name"] = ""
  6538. inputData["rx_flag"] = ""
  6539. inputData["list_sp_item_flag"] = ""
  6540. inputData["trdn_flag"] = ""
  6541. inputData["invdate"] = ""
  6542. inputData["manu_lotnum"] = ""
  6543. inputData["manu_date"] = ""
  6544. inputData["expy_end"] = ""
  6545. inputData["memo"] = ""
  6546. inputData["vali_flag"] = ""
  6547. inputData["rid"] = ""
  6548. inputData["crter_id"] = ""
  6549. inputData["crter_name"] = ""
  6550. inputData["crte_optins_no"] = ""
  6551. inputData["opter_id"] = ""
  6552. inputData["opter_name"] = ""
  6553. inputData["optins_no"] = ""
  6554. inputData["poolarea_no"] = ""
  6555. inputData["fixmedins_bchno"] = ""
  6556. inputData["inv_data_type"] = ""
  6557. input["data"] = inputData
  6558. inputMessage["input"] = input //交易输入
  6559. bytesData, err := json.Marshal(inputMessage)
  6560. fmt.Println(string(bytesData))
  6561. if err != nil {
  6562. fmt.Println(err.Error())
  6563. return err.Error(), ""
  6564. }
  6565. reader := bytes.NewReader(bytesData)
  6566. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6567. gdyb_url := beego.AppConfig.String("gdyb_url")
  6568. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6569. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6570. url := gdyb_url + "3509"
  6571. request, err := http.NewRequest("POST", url, reader)
  6572. if err != nil {
  6573. fmt.Println(err.Error())
  6574. return err.Error(), ""
  6575. }
  6576. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6577. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6578. request.Header.Set("x-tif-signature", signature)
  6579. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6580. request.Header.Set("x-tif-nonce", nonce)
  6581. client := http.Client{}
  6582. resp, err := client.Do(request)
  6583. if err != nil {
  6584. fmt.Println(err.Error())
  6585. return err.Error(), ""
  6586. }
  6587. respBytes, err := ioutil.ReadAll(resp.Body)
  6588. if err != nil {
  6589. fmt.Println(err.Error())
  6590. return err.Error(), ""
  6591. }
  6592. str := string(respBytes)
  6593. fmt.Println(str)
  6594. return str, string(bytesData)
  6595. }
  6596. func Gdyb3510(struct3510 models.Struct3510, secret_key string) (string, string) {
  6597. // 生成签名
  6598. nonce := GetRandomString(32)
  6599. timestamp := time.Now().Unix()
  6600. signature := setSignature(timestamp, nonce, secret_key)
  6601. // 生成输入报文
  6602. inputMessage := SetGdInputMessage(timestamp, struct3510.OrgName, struct3510.Opter, struct3510.FixmedinsCode, struct3510.InsuplcAdmdvs, struct3510.MdtrtareaAdmvs, struct3510.Cainfo)
  6603. input := make(map[string]interface{})
  6604. inputData := make(map[string]interface{})
  6605. inputMessage["infno"] = "3510"
  6606. inputData["fixmedins_code"] = struct3510.FixmedinsCode
  6607. //inputData["medins_list_codg"] = struct3510.MedinsListCodg
  6608. inputData["medins_list_codg"] = struct3510.MedListCodg
  6609. inputData["fixmedins_bchno"] = ""
  6610. inputData["begndate"] = struct3510.Begndate
  6611. inputData["enddate"] = struct3510.Enddate
  6612. inputData["medins_prod_inv_no"] = ""
  6613. inputData["medins_list_name"] = ""
  6614. inputData["rx_flag"] = ""
  6615. inputData["list_sp_item_flag"] = ""
  6616. inputData["trdn_flag"] = ""
  6617. inputData["invdate"] = ""
  6618. inputData["manu_lotnum"] = ""
  6619. inputData["manu_date"] = ""
  6620. inputData["expy_end"] = ""
  6621. inputData["memo"] = ""
  6622. inputData["vali_flag"] = ""
  6623. inputData["rid"] = ""
  6624. inputData["crter_id"] = ""
  6625. inputData["crter_name"] = ""
  6626. inputData["crte_optins_no"] = ""
  6627. inputData["opter_id"] = ""
  6628. inputData["opter_name"] = ""
  6629. inputData["optins_no"] = ""
  6630. inputData["poolarea_no"] = ""
  6631. inputData["fixmedins_bchno"] = ""
  6632. inputData["inv_data_type"] = ""
  6633. input["data"] = inputData
  6634. inputMessage["input"] = input //交易输入
  6635. bytesData, err := json.Marshal(inputMessage)
  6636. fmt.Println(string(bytesData))
  6637. if err != nil {
  6638. fmt.Println(err.Error())
  6639. return err.Error(), ""
  6640. }
  6641. reader := bytes.NewReader(bytesData)
  6642. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6643. gdyb_url := beego.AppConfig.String("gdyb_url")
  6644. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6645. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6646. url := gdyb_url + "3510"
  6647. request, err := http.NewRequest("POST", url, reader)
  6648. if err != nil {
  6649. fmt.Println(err.Error())
  6650. return err.Error(), ""
  6651. }
  6652. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6653. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6654. request.Header.Set("x-tif-signature", signature)
  6655. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6656. request.Header.Set("x-tif-nonce", nonce)
  6657. client := http.Client{}
  6658. resp, err := client.Do(request)
  6659. if err != nil {
  6660. fmt.Println(err.Error())
  6661. return err.Error(), ""
  6662. }
  6663. respBytes, err := ioutil.ReadAll(resp.Body)
  6664. if err != nil {
  6665. fmt.Println(err.Error())
  6666. return err.Error(), ""
  6667. }
  6668. str := string(respBytes)
  6669. fmt.Println(str)
  6670. return str, string(bytesData)
  6671. }
  6672. func Gdyb3511(struct3511 models.Struct3511, secret_key string) (string, string) {
  6673. // 生成签名
  6674. nonce := GetRandomString(32)
  6675. timestamp := time.Now().Unix()
  6676. signature := setSignature(timestamp, nonce, secret_key)
  6677. // 生成输入报文
  6678. inputMessage := SetGdInputMessage(timestamp, struct3511.OrgName, struct3511.Opter, struct3511.FixmedinsCode, struct3511.InsuplcAdmdvs, struct3511.MdtrtareaAdmvs, struct3511.Cainfo)
  6679. input := make(map[string]interface{})
  6680. inputData := make(map[string]interface{})
  6681. inputMessage["infno"] = "3511"
  6682. inputData["fixmedins_code"] = struct3511.FixmedinsCode
  6683. //inputData["medins_list_codg"] = struct3511.MedinsListCodg
  6684. inputData["medins_list_codg"] = struct3511.MedListCodg
  6685. inputData["fixmedins_bchno"] = ""
  6686. inputData["begndate"] = struct3511.Begndate
  6687. inputData["enddate"] = struct3511.Enddate
  6688. inputData["medins_prod_inv_no"] = ""
  6689. inputData["medins_list_name"] = ""
  6690. inputData["rx_flag"] = ""
  6691. inputData["list_sp_item_flag"] = ""
  6692. inputData["trdn_flag"] = ""
  6693. inputData["invdate"] = ""
  6694. inputData["manu_lotnum"] = ""
  6695. inputData["manu_date"] = ""
  6696. inputData["expy_end"] = ""
  6697. inputData["memo"] = ""
  6698. inputData["vali_flag"] = ""
  6699. inputData["rid"] = ""
  6700. inputData["crter_id"] = ""
  6701. inputData["crter_name"] = ""
  6702. inputData["crte_optins_no"] = ""
  6703. inputData["opter_id"] = ""
  6704. inputData["opter_name"] = ""
  6705. inputData["optins_no"] = ""
  6706. inputData["poolarea_no"] = ""
  6707. inputData["fixmedins_bchno"] = ""
  6708. inputData["inv_data_type"] = ""
  6709. input["data"] = inputData
  6710. inputMessage["input"] = input //交易输入
  6711. bytesData, err := json.Marshal(inputMessage)
  6712. fmt.Println(string(bytesData))
  6713. if err != nil {
  6714. fmt.Println(err.Error())
  6715. return err.Error(), ""
  6716. }
  6717. reader := bytes.NewReader(bytesData)
  6718. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6719. gdyb_url := beego.AppConfig.String("gdyb_url")
  6720. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6721. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6722. url := gdyb_url + "3511"
  6723. request, err := http.NewRequest("POST", url, reader)
  6724. if err != nil {
  6725. fmt.Println(err.Error())
  6726. return err.Error(), ""
  6727. }
  6728. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6729. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6730. request.Header.Set("x-tif-signature", signature)
  6731. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6732. request.Header.Set("x-tif-nonce", nonce)
  6733. client := http.Client{}
  6734. resp, err := client.Do(request)
  6735. if err != nil {
  6736. fmt.Println(err.Error())
  6737. return err.Error(), ""
  6738. }
  6739. respBytes, err := ioutil.ReadAll(resp.Body)
  6740. if err != nil {
  6741. fmt.Println(err.Error())
  6742. return err.Error(), ""
  6743. }
  6744. str := string(respBytes)
  6745. fmt.Println(str)
  6746. return str, string(bytesData)
  6747. }
  6748. func Gdyb3512(struct3512 models.Struct3512, secret_key string) (string, string) {
  6749. // 生成签名
  6750. nonce := GetRandomString(32)
  6751. timestamp := time.Now().Unix()
  6752. signature := setSignature(timestamp, nonce, secret_key)
  6753. // 生成输入报文
  6754. inputMessage := SetGdInputMessage(timestamp, struct3512.OrgName, struct3512.Opter, struct3512.FixmedinsCode, struct3512.InsuplcAdmdvs, struct3512.MdtrtareaAdmvs, struct3512.Cainfo)
  6755. input := make(map[string]interface{})
  6756. inputData := make(map[string]interface{})
  6757. inputMessage["infno"] = "3512"
  6758. inputData["fixmedins_code"] = struct3512.FixmedinsCode
  6759. //inputData["medins_list_codg"] = struct3512.MedinsListCodg
  6760. inputData["medins_list_codg"] = struct3512.MedListCodg
  6761. inputData["fixmedins_bchno"] = ""
  6762. inputData["begndate"] = struct3512.Begndate
  6763. inputData["enddate"] = struct3512.Enddate
  6764. inputData["medins_prod_inv_no"] = ""
  6765. inputData["medins_list_name"] = ""
  6766. inputData["rx_flag"] = ""
  6767. inputData["list_sp_item_flag"] = ""
  6768. inputData["trdn_flag"] = ""
  6769. inputData["invdate"] = ""
  6770. inputData["manu_lotnum"] = ""
  6771. inputData["manu_date"] = ""
  6772. inputData["expy_end"] = ""
  6773. inputData["memo"] = ""
  6774. inputData["vali_flag"] = ""
  6775. inputData["rid"] = ""
  6776. inputData["crter_id"] = ""
  6777. inputData["crter_name"] = ""
  6778. inputData["crte_optins_no"] = ""
  6779. inputData["opter_id"] = ""
  6780. inputData["opter_name"] = ""
  6781. inputData["optins_no"] = ""
  6782. inputData["poolarea_no"] = ""
  6783. inputData["fixmedins_bchno"] = ""
  6784. inputData["inv_data_type"] = ""
  6785. input["data"] = inputData
  6786. inputMessage["input"] = input //交易输入
  6787. bytesData, err := json.Marshal(inputMessage)
  6788. fmt.Println(string(bytesData))
  6789. if err != nil {
  6790. fmt.Println(err.Error())
  6791. return err.Error(), ""
  6792. }
  6793. reader := bytes.NewReader(bytesData)
  6794. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6795. gdyb_url := beego.AppConfig.String("gdyb_url")
  6796. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6797. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6798. url := gdyb_url + "3512"
  6799. request, err := http.NewRequest("POST", url, reader)
  6800. if err != nil {
  6801. fmt.Println(err.Error())
  6802. return err.Error(), ""
  6803. }
  6804. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6805. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6806. request.Header.Set("x-tif-signature", signature)
  6807. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6808. request.Header.Set("x-tif-nonce", nonce)
  6809. client := http.Client{}
  6810. resp, err := client.Do(request)
  6811. if err != nil {
  6812. fmt.Println(err.Error())
  6813. return err.Error(), ""
  6814. }
  6815. respBytes, err := ioutil.ReadAll(resp.Body)
  6816. if err != nil {
  6817. fmt.Println(err.Error())
  6818. return err.Error(), ""
  6819. }
  6820. str := string(respBytes)
  6821. fmt.Println(str)
  6822. return str, string(bytesData)
  6823. }
  6824. func Gdyb3513(struct3513 models.Struct3513, secret_key string) (string, string) {
  6825. // 生成签名
  6826. nonce := GetRandomString(32)
  6827. timestamp := time.Now().Unix()
  6828. signature := setSignature(timestamp, nonce, secret_key)
  6829. // 生成输入报文
  6830. inputMessage := SetGdInputMessage(timestamp, struct3513.OrgName, struct3513.Opter, struct3513.FixmedinsCode, struct3513.InsuplcAdmdvs, struct3513.MdtrtareaAdmvs, struct3513.Cainfo)
  6831. input := make(map[string]interface{})
  6832. inputData := make(map[string]interface{})
  6833. inputMessage["infno"] = "3513"
  6834. inputData["fixmedins_code"] = struct3513.FixmedinsCode
  6835. //inputData["medins_list_codg"] = struct3513.MedinsListCodg
  6836. inputData["medins_list_codg"] = struct3513.MedListCodg
  6837. inputData["fixmedins_bchno"] = ""
  6838. inputData["begndate"] = struct3513.Begndate
  6839. inputData["enddate"] = struct3513.Enddate
  6840. inputData["medins_prod_inv_no"] = ""
  6841. inputData["med_list_codg"] = ""
  6842. inputData["medins_list_name"] = ""
  6843. inputData["rx_flag"] = ""
  6844. inputData["list_sp_item_flag"] = ""
  6845. inputData["trdn_flag"] = ""
  6846. inputData["invdate"] = ""
  6847. inputData["manu_lotnum"] = ""
  6848. inputData["manu_date"] = ""
  6849. inputData["expy_end"] = ""
  6850. inputData["memo"] = ""
  6851. inputData["vali_flag"] = ""
  6852. inputData["rid"] = ""
  6853. inputData["crter_id"] = ""
  6854. inputData["crter_name"] = ""
  6855. inputData["crte_optins_no"] = ""
  6856. inputData["opter_id"] = ""
  6857. inputData["opter_name"] = ""
  6858. inputData["optins_no"] = ""
  6859. inputData["poolarea_no"] = ""
  6860. inputData["fixmedins_bchno"] = ""
  6861. inputData["inv_data_type"] = ""
  6862. input["data"] = inputData
  6863. inputMessage["input"] = input //交易输入
  6864. bytesData, err := json.Marshal(inputMessage)
  6865. fmt.Println(string(bytesData))
  6866. if err != nil {
  6867. fmt.Println(err.Error())
  6868. return err.Error(), ""
  6869. }
  6870. reader := bytes.NewReader(bytesData)
  6871. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6872. gdyb_url := beego.AppConfig.String("gdyb_url")
  6873. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6874. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6875. url := gdyb_url + "3513"
  6876. request, err := http.NewRequest("POST", url, reader)
  6877. if err != nil {
  6878. fmt.Println(err.Error())
  6879. return err.Error(), ""
  6880. }
  6881. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6882. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6883. request.Header.Set("x-tif-signature", signature)
  6884. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6885. request.Header.Set("x-tif-nonce", nonce)
  6886. client := http.Client{}
  6887. resp, err := client.Do(request)
  6888. if err != nil {
  6889. fmt.Println(err.Error())
  6890. return err.Error(), ""
  6891. }
  6892. respBytes, err := ioutil.ReadAll(resp.Body)
  6893. if err != nil {
  6894. fmt.Println(err.Error())
  6895. return err.Error(), ""
  6896. }
  6897. str := string(respBytes)
  6898. fmt.Println(str)
  6899. return str, string(bytesData)
  6900. }
  6901. // 生成基础报文
  6902. func SetGdInputMessage(timestamp int64, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, cainfo string) map[string]interface{} {
  6903. // 生成签名
  6904. tempTime := time.Unix(timestamp, 0)
  6905. //timeFormat := tempTime.Format("20060102150405")
  6906. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  6907. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  6908. month := time.Unix(1557042972, 0).Format("1")
  6909. year := time.Now().Format("2006")
  6910. month = time.Now().Format("01")
  6911. day := time.Now().Format("02")
  6912. hour := time.Now().Format("15")
  6913. min := time.Now().Format("04")
  6914. sec := time.Now().Format("05")
  6915. msec := time.Now().Format("000")
  6916. // 生成输入报文
  6917. inputMessage := make(map[string]interface{})
  6918. inputMessage["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  6919. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  6920. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  6921. inputMessage["recer_sys_code"] = "MBS_LOCAL" // 接收方系统代码
  6922. inputMessage["dev_no"] = "1" // 设备编号
  6923. inputMessage["dev_safe_info"] = "1" // 设备安全信息
  6924. inputMessage["cainfo"] = cainfo // 数字签名信息
  6925. inputMessage["signtype"] = "SM3" // 签名类型
  6926. inputMessage["infver"] = "1.0.0" // 接收方系统代码
  6927. inputMessage["opter_type"] = "1" // 经办人类别
  6928. inputMessage["opter"] = doctor // 经办人
  6929. inputMessage["opter_name"] = doctor // 经办人姓名
  6930. inputMessage["inf_time"] = timeFormatOne // 交易时间
  6931. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  6932. inputMessage["fixmedins_name"] = org_name
  6933. inputMessage["fixmedins_soft_fcty"] = "深圳市领透科技有限公司" //定点医药机构名称
  6934. //定点医药机构名称
  6935. inputMessage["sign_no"] = "" //交易签到流水号
  6936. return inputMessage
  6937. }
  6938. func Gdyb3101(pd models.PatientDtos, fed models.FsiEncounterDtos, fdds []*models.FsiDiagnoseDtos, fods []*models.FsiOrderDtos, fopds []*models.FsiOperationDtosData, params models.PublicParams, trig_scen string) (string, string) {
  6939. nonce := GetRandomString(32)
  6940. timestamp := time.Now().Unix()
  6941. signature := setSignature(timestamp, nonce, params.SecretKey)
  6942. // 生成输入报文
  6943. inputMessage := SetGdInputMessage(timestamp, params.FixmedinsName, params.OpterName, params.FixmedinsCode, params.InsuplcAdmdvs, params.MdtrtareaAdmvs, params.Cainfo)
  6944. //inputMessage := SetJSInputMessage(timestamp, params.FixmedinsName, params.OpterName, params.FixmedinsCode, params.InsuplcAdmdvs, params.MdtrtareaAdmvs, params.Cainfo)
  6945. input := make(map[string]interface{})
  6946. inputData := make(map[string]interface{})
  6947. patientDtosinputData := make(map[string]interface{})
  6948. fisEncounterDtosData := make(map[string]interface{})
  6949. fsiDiagnoseDtosDatas := make([]map[string]interface{}, 0)
  6950. fsiOrderDtosDatas := make([]map[string]interface{}, 0)
  6951. fsiOperationDtosData := make(map[string]interface{})
  6952. fsiOperationDtosDatas := make([]map[string]interface{}, 0)
  6953. //就诊信息
  6954. fisEncounterDtosData["mdtrt_id"] = fed.MdtrtID
  6955. fisEncounterDtosData["medins_id"] = fed.MedinsID
  6956. fisEncounterDtosData["medins_name"] = fed.MedinsName
  6957. fisEncounterDtosData["medins_admdvs"] = fed.MedinsAdmdvs
  6958. fisEncounterDtosData["medins_type"] = fed.MedinsType
  6959. fisEncounterDtosData["medins_lv"] = fed.MedinsLv
  6960. fisEncounterDtosData["wardarea_codg"] = fed.WardareaCodg
  6961. fisEncounterDtosData["wardno"] = fed.Wardno
  6962. fisEncounterDtosData["bedno"] = fed.Bedno
  6963. fisEncounterDtosData["adm_date"] = fed.AdmDate
  6964. fisEncounterDtosData["dscg_date"] = fed.DscgDate
  6965. fisEncounterDtosData["dscg_main_dise_codg"] = fed.DscgMainDiseCodg
  6966. fisEncounterDtosData["dscg_main_dise_name"] = fed.DscgMainDiseName
  6967. for _, fdd := range fdds {
  6968. fsiDiagnoseDtosData := make(map[string]interface{})
  6969. //诊断集合
  6970. fsiDiagnoseDtosData["dise_id"] = fdd.DiseID
  6971. fsiDiagnoseDtosData["inout_dise_type"] = fdd.InoutDiseType
  6972. fsiDiagnoseDtosData["maindise_flag"] = fdd.MaindiseFlag
  6973. fsiDiagnoseDtosData["dias_srt_no"] = fdd.DiasSrtNo
  6974. fsiDiagnoseDtosData["dise_codg"] = fdd.DiseCodg
  6975. fsiDiagnoseDtosData["dise_name"] = fdd.DiseName
  6976. fsiDiagnoseDtosData["dise_date"] = fdd.DiseDate
  6977. fsiDiagnoseDtosDatas = append(fsiDiagnoseDtosDatas, fsiDiagnoseDtosData)
  6978. }
  6979. fisEncounterDtosData["fsi_diagnose_dtos"] = fsiDiagnoseDtosDatas
  6980. fisEncounterDtosData["dr_codg"] = fed.DrCodg
  6981. fisEncounterDtosData["adm_dept_codg"] = fed.AdmDeptCodg
  6982. fisEncounterDtosData["adm_dept_name"] = fed.AdmDeptName
  6983. fisEncounterDtosData["dscg_dept_codg"] = fed.DscgDeptCodg
  6984. fisEncounterDtosData["dscg_dept_name"] = fed.DscgDeptName
  6985. fisEncounterDtosData["med_mdtrt_type"] = fed.MedMdtrtType
  6986. fisEncounterDtosData["med_type"] = fed.MedType
  6987. for _, fod := range fods {
  6988. fsiOrderDtosData := make(map[string]interface{})
  6989. //医嘱集合
  6990. fsiOrderDtosData["rx_id"] = fod.RxID
  6991. fsiOrderDtosData["rxno"] = fod.Rxno
  6992. fsiOrderDtosData["grpno"] = fod.Grpno
  6993. fsiOrderDtosData["long_drord_flag"] = fod.LongDrordFlag
  6994. fsiOrderDtosData["hilist_type"] = fod.HilistType
  6995. fsiOrderDtosData["chrg_type"] = fod.ChrgType
  6996. fsiOrderDtosData["drord_bhvr"] = fod.DrordBhvr
  6997. fsiOrderDtosData["hilist_code"] = fod.HilistCode
  6998. fsiOrderDtosData["hilist_name"] = fod.HosplistName
  6999. fsiOrderDtosData["hilist_dosform"] = fod.HilistDosform
  7000. fsiOrderDtosData["hilist_lv"] = fod.HilistLv
  7001. fsiOrderDtosData["hilist_pric"] = fod.HilistPric
  7002. fsiOrderDtosData["lv1_hosp_item_pric"] = fod.Lv1HospItemPric
  7003. fsiOrderDtosData["lv2_hosp_item_pric"] = fod.Lv2HospItemPric
  7004. fsiOrderDtosData["lv3_hosp_item_pric"] = fod.Lv3HospItemPric
  7005. fsiOrderDtosData["hilist_memo"] = fod.HilistMemo
  7006. fsiOrderDtosData["hosplist_code"] = fod.HosplistCode
  7007. fsiOrderDtosData["hosplist_name"] = fod.HosplistName
  7008. fsiOrderDtosData["hosplist_dosform"] = fod.HosplistDosform
  7009. fsiOrderDtosData["cnt"] = fod.Cnt
  7010. fsiOrderDtosData["pric"] = fod.Pric
  7011. fsiOrderDtosData["sumamt"] = fod.Sumamt
  7012. fsiOrderDtosData["ownpay_amt"] = fod.OwnpayAmt
  7013. fsiOrderDtosData["selfpay_amt"] = fod.SelfpayAmt
  7014. fsiOrderDtosData["spec"] = fod.Spec
  7015. fsiOrderDtosData["spec_unt"] = fod.SpecUnt
  7016. fsiOrderDtosData["drord_begn_date"] = fod.DrordBegnDate
  7017. fsiOrderDtosData["drord_stop_date"] = fod.DrordStopDate
  7018. fsiOrderDtosData["drord_dept_codg"] = fod.DrordDeptCodg
  7019. fsiOrderDtosData["drord_dept_name"] = fod.DrordDeptName
  7020. fsiOrderDtosData["drord_dr_codg"] = fod.DrordDrCodg
  7021. fsiOrderDtosData["drord_dr_name"] = fod.DrordDrName
  7022. fsiOrderDtosData["drord_dr_profttl"] = fod.DrordDrProfttl
  7023. fsiOrderDtosData["curr_drord_flag"] = fod.CurrDrordFlag
  7024. fsiOrderDtosDatas = append(fsiOrderDtosDatas, fsiOrderDtosData)
  7025. }
  7026. fisEncounterDtosData["fsi_order_dtos"] = fsiOrderDtosDatas
  7027. fisEncounterDtosData["matn_stas"] = fed.MatnStas
  7028. fisEncounterDtosData["medfee_sumamt"] = fed.MedfeeSumamt
  7029. fisEncounterDtosData["ownpay_amt"] = fed.OwnpayAmt
  7030. fisEncounterDtosData["selfpay_amt"] = fed.SelfpayAmt
  7031. fisEncounterDtosData["acct_payamt"] = fed.AcctPayamt
  7032. fisEncounterDtosData["ma_amt"] = fed.MaAmt
  7033. fisEncounterDtosData["hifp_payamt"] = fed.HifpPayamt
  7034. fisEncounterDtosData["setl_totlnum"] = fed.SetlTotlnum
  7035. fisEncounterDtosData["insutype"] = fed.Insutype
  7036. fisEncounterDtosData["reim_flag"] = fed.ReimFlag
  7037. fisEncounterDtosData["out_setl_flag"] = fed.OutSetlFlag
  7038. //手术操作
  7039. for _, fopd := range fopds {
  7040. fsiOperationDtosData["setl_list_oprn_id"] = fopd.Setl_list_oprn_id
  7041. fsiOperationDtosData["oprn_code"] = fopd.Oprn_code
  7042. fsiOperationDtosData["oprn_name"] = fopd.Oprn_name
  7043. fsiOperationDtosData["main_oprn_flag"] = fopd.Main_oprn_flag
  7044. fsiOperationDtosData["oprn_date"] = fopd.Oprn_date
  7045. fsiOperationDtosData["anst_way"] = fopd.Anst_way
  7046. fsiOperationDtosData["oper_dr_name"] = fopd.Oper_dr_name
  7047. fsiOperationDtosData["oper_dr_code"] = fopd.Oper_dr_code
  7048. fsiOperationDtosData["anst_dr_name"] = fopd.Anst_dr_name
  7049. fsiOperationDtosData["anst_dr_code"] = fopd.Anst_dr_code
  7050. fsiOperationDtosDatas = append(fsiOperationDtosDatas, fsiOperationDtosData)
  7051. }
  7052. fisEncounterDtosData["fsi_operation_dtos"] = fsiOperationDtosDatas
  7053. patientDtosinputData["patn_id"] = pd.PatnID
  7054. patientDtosinputData["patn_name"] = pd.PatnName
  7055. patientDtosinputData["gend"] = pd.Gend
  7056. patientDtosinputData["brdy"] = pd.Brdy
  7057. patientDtosinputData["poolarea"] = pd.Poolarea
  7058. patientDtosinputData["curr_mdtrt_id"] = pd.CurrMdtrtID
  7059. patientDtosinputData["fsi_his_data_dto"] = ""
  7060. patientDtosinputData["fsi_encounter_dtos"] = fisEncounterDtosData
  7061. inputData["syscode"] = "LinkDialysis"
  7062. inputData["trig_scen"] = trig_scen
  7063. inputData["rule_ids"] = ""
  7064. inputData["task_id"] = ""
  7065. inputData["patient_dtos"] = patientDtosinputData
  7066. input["data"] = inputData
  7067. inputMessage["infno"] = "3101"
  7068. inputMessage["input"] = input //交易输入
  7069. bytesData, err := json.Marshal(inputMessage)
  7070. fmt.Println(string(bytesData))
  7071. if err != nil {
  7072. fmt.Println(err.Error())
  7073. return err.Error(), ""
  7074. }
  7075. reader := bytes.NewReader(bytesData)
  7076. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7077. gdyb_url := beego.AppConfig.String("gdyb_url")
  7078. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7079. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7080. url := gdyb_url + "3101"
  7081. request, err := http.NewRequest("POST", url, reader)
  7082. if err != nil {
  7083. fmt.Println(err.Error())
  7084. return err.Error(), ""
  7085. }
  7086. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  7087. request.Header.Set("x-tif-paasid", gdyb_paasid)
  7088. request.Header.Set("x-tif-signature", signature)
  7089. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  7090. request.Header.Set("x-tif-nonce", nonce)
  7091. client := http.Client{}
  7092. resp, err := client.Do(request)
  7093. if err != nil {
  7094. fmt.Println(err.Error())
  7095. return err.Error(), ""
  7096. }
  7097. respBytes, err := ioutil.ReadAll(resp.Body)
  7098. if err != nil {
  7099. fmt.Println(err.Error())
  7100. return err.Error(), ""
  7101. }
  7102. str := string(respBytes)
  7103. fmt.Println(str)
  7104. return str, string(bytesData)
  7105. }
  7106. func Gdyb3102(pd models.PatientDtos, fed models.FsiEncounterDtos, fdds []*models.FsiDiagnoseDtos, fods []*models.FsiOrderDtos, fopds []*models.FsiOperationDtosData, params models.PublicParams, trig_scen string) (string, string) {
  7107. nonce := GetRandomString(32)
  7108. timestamp := time.Now().Unix()
  7109. signature := setSignature(timestamp, nonce, params.SecretKey)
  7110. // 生成输入报文
  7111. inputMessage := SetGdInputMessage(timestamp, params.FixmedinsName, params.OpterName, params.FixmedinsCode, params.InsuplcAdmdvs, params.MdtrtareaAdmvs, params.Cainfo)
  7112. input := make(map[string]interface{})
  7113. inputData := make(map[string]interface{})
  7114. patientDtosinputData := make(map[string]interface{})
  7115. fisEncounterDtosData := make(map[string]interface{})
  7116. fsiDiagnoseDtosDatas := make([]map[string]interface{}, 0)
  7117. fsiOrderDtosDatas := make([]map[string]interface{}, 0)
  7118. fsiOperationDtosData := make(map[string]interface{})
  7119. fsiOperationDtosDatas := make([]map[string]interface{}, 0)
  7120. //就诊信息
  7121. fisEncounterDtosData["mdtrt_id"] = fed.MdtrtID
  7122. fisEncounterDtosData["medins_id"] = fed.MedinsID
  7123. fisEncounterDtosData["medins_name"] = fed.MedinsName
  7124. fisEncounterDtosData["medins_admdvs"] = fed.MedinsAdmdvs
  7125. fisEncounterDtosData["medins_type"] = fed.MedinsType
  7126. fisEncounterDtosData["medins_lv"] = fed.MedinsLv
  7127. fisEncounterDtosData["wardarea_codg"] = fed.WardareaCodg
  7128. fisEncounterDtosData["wardno"] = fed.Wardno
  7129. fisEncounterDtosData["bedno"] = fed.Bedno
  7130. fisEncounterDtosData["adm_date"] = fed.AdmDate
  7131. fisEncounterDtosData["dscg_date"] = fed.DscgDate
  7132. fisEncounterDtosData["dscg_main_dise_codg"] = fed.DscgMainDiseCodg
  7133. fisEncounterDtosData["dscg_main_dise_name"] = fed.DscgMainDiseName
  7134. for _, fdd := range fdds {
  7135. fsiDiagnoseDtosData := make(map[string]interface{})
  7136. //诊断集合
  7137. fsiDiagnoseDtosData["dise_id"] = fdd.DiseID
  7138. fsiDiagnoseDtosData["inout_dise_type"] = fdd.InoutDiseType
  7139. fsiDiagnoseDtosData["maindise_flag"] = fdd.MaindiseFlag
  7140. fsiDiagnoseDtosData["dias_srt_no"] = fdd.DiasSrtNo
  7141. fsiDiagnoseDtosData["dise_codg"] = fdd.DiseCodg
  7142. fsiDiagnoseDtosData["dise_name"] = fdd.DiseName
  7143. fsiDiagnoseDtosData["dise_date"] = fdd.DiseDate
  7144. fsiDiagnoseDtosDatas = append(fsiDiagnoseDtosDatas, fsiDiagnoseDtosData)
  7145. }
  7146. fisEncounterDtosData["fsi_diagnose_dtos"] = fsiDiagnoseDtosDatas
  7147. fisEncounterDtosData["dr_codg"] = fed.DrCodg
  7148. fisEncounterDtosData["adm_dept_codg"] = fed.AdmDeptCodg
  7149. fisEncounterDtosData["adm_dept_name"] = fed.AdmDeptName
  7150. fisEncounterDtosData["dscg_dept_codg"] = fed.DscgDeptCodg
  7151. fisEncounterDtosData["dscg_dept_name"] = fed.DscgDeptName
  7152. fisEncounterDtosData["med_mdtrt_type"] = fed.MedMdtrtType
  7153. fisEncounterDtosData["med_type"] = fed.MedType
  7154. for _, fod := range fods {
  7155. fsiOrderDtosData := make(map[string]interface{})
  7156. //医嘱集合
  7157. fsiOrderDtosData["rx_id"] = fod.RxID
  7158. fsiOrderDtosData["rxno"] = fod.Rxno
  7159. fsiOrderDtosData["grpno"] = fod.Grpno
  7160. fsiOrderDtosData["long_drord_flag"] = fod.LongDrordFlag
  7161. fsiOrderDtosData["hilist_type"] = fod.HilistType
  7162. fsiOrderDtosData["chrg_type"] = fod.ChrgType
  7163. fsiOrderDtosData["drord_bhvr"] = fod.DrordBhvr
  7164. fsiOrderDtosData["hilist_code"] = fod.HosplistCode
  7165. fsiOrderDtosData["hilist_name"] = fod.HosplistName
  7166. fsiOrderDtosData["hilist_dosform"] = fod.HilistDosform
  7167. fsiOrderDtosData["hilist_lv"] = fod.HilistLv
  7168. fsiOrderDtosData["hilist_pric"] = fod.HilistPric
  7169. fsiOrderDtosData["lv1_hosp_item_pric"] = fod.Lv1HospItemPric
  7170. fsiOrderDtosData["lv2_hosp_item_pric"] = fod.Lv2HospItemPric
  7171. fsiOrderDtosData["lv3_hosp_item_pric"] = fod.Lv3HospItemPric
  7172. fsiOrderDtosData["hilist_memo"] = fod.HilistMemo
  7173. fsiOrderDtosData["hosplist_code"] = fod.HosplistCode
  7174. fsiOrderDtosData["hosplist_name"] = fod.HosplistName
  7175. fsiOrderDtosData["hosplist_dosform"] = fod.HosplistDosform
  7176. fsiOrderDtosData["cnt"] = fod.Cnt
  7177. fsiOrderDtosData["pric"] = fod.Pric
  7178. fsiOrderDtosData["sumamt"] = fod.Sumamt
  7179. fsiOrderDtosData["ownpay_amt"] = fod.OwnpayAmt
  7180. fsiOrderDtosData["selfpay_amt"] = fod.SelfpayAmt
  7181. fsiOrderDtosData["spec"] = fod.Spec
  7182. fsiOrderDtosData["spec_unt"] = fod.SpecUnt
  7183. fsiOrderDtosData["drord_begn_date"] = fod.DrordBegnDate
  7184. fsiOrderDtosData["drord_stop_date"] = fod.DrordStopDate
  7185. fsiOrderDtosData["drord_dept_codg"] = fod.DrordDeptCodg
  7186. fsiOrderDtosData["drord_dept_name"] = fod.DrordDeptName
  7187. fsiOrderDtosData["drord_dr_codg"] = fod.DrordDrCodg
  7188. fsiOrderDtosData["drord_dr_name"] = fod.DrordDrName
  7189. fsiOrderDtosData["drord_dr_profttl"] = fod.DrordDrProfttl
  7190. fsiOrderDtosData["curr_drord_flag"] = fod.CurrDrordFlag
  7191. fsiOrderDtosDatas = append(fsiOrderDtosDatas, fsiOrderDtosData)
  7192. }
  7193. fisEncounterDtosData["fsi_order_dtos"] = fsiOrderDtosDatas
  7194. fisEncounterDtosData["matn_stas"] = fed.MatnStas
  7195. fisEncounterDtosData["medfee_sumamt"] = fed.MedfeeSumamt
  7196. fisEncounterDtosData["ownpay_amt"] = fed.OwnpayAmt
  7197. fisEncounterDtosData["selfpay_amt"] = fed.SelfpayAmt
  7198. fisEncounterDtosData["acct_payamt"] = fed.AcctPayamt
  7199. fisEncounterDtosData["ma_amt"] = fed.MaAmt
  7200. fisEncounterDtosData["hifp_payamt"] = fed.HifpPayamt
  7201. fisEncounterDtosData["setl_totlnum"] = fed.SetlTotlnum
  7202. fisEncounterDtosData["insutype"] = fed.Insutype
  7203. fisEncounterDtosData["reim_flag"] = fed.ReimFlag
  7204. fisEncounterDtosData["out_setl_flag"] = fed.OutSetlFlag
  7205. //手术操作
  7206. for _, fopd := range fopds {
  7207. fsiOperationDtosData["setl_list_oprn_id"] = fopd.Setl_list_oprn_id
  7208. fsiOperationDtosData["oprn_code"] = fopd.Oprn_code
  7209. fsiOperationDtosData["oprn_name"] = fopd.Oprn_name
  7210. fsiOperationDtosData["main_oprn_flag"] = fopd.Main_oprn_flag
  7211. fsiOperationDtosData["oprn_date"] = fopd.Oprn_date
  7212. fsiOperationDtosData["anst_way"] = fopd.Anst_way
  7213. fsiOperationDtosData["oper_dr_name"] = fopd.Oper_dr_name
  7214. fsiOperationDtosData["oper_dr_code"] = fopd.Oper_dr_code
  7215. fsiOperationDtosData["anst_dr_name"] = fopd.Anst_dr_name
  7216. fsiOperationDtosData["anst_dr_code"] = fopd.Anst_dr_code
  7217. fsiOperationDtosDatas = append(fsiOperationDtosDatas, fsiOperationDtosData)
  7218. }
  7219. fisEncounterDtosData["fsi_operation_dtos"] = fsiOperationDtosDatas
  7220. patientDtosinputData["patn_id"] = pd.PatnID
  7221. patientDtosinputData["patn_name"] = pd.PatnName
  7222. patientDtosinputData["gend"] = pd.Gend
  7223. patientDtosinputData["brdy"] = pd.Brdy
  7224. patientDtosinputData["poolarea"] = pd.Poolarea
  7225. patientDtosinputData["curr_mdtrt_id"] = pd.CurrMdtrtID
  7226. patientDtosinputData["fsi_his_data_dto"] = ""
  7227. patientDtosinputData["fsi_encounter_dtos"] = fisEncounterDtosData
  7228. inputData["syscode"] = "LinkDialysis"
  7229. inputData["trig_scen"] = trig_scen
  7230. inputData["rule_ids"] = ""
  7231. inputData["task_id"] = ""
  7232. inputData["patient_dtos"] = patientDtosinputData
  7233. input["data"] = inputData
  7234. inputMessage["infno"] = "3102"
  7235. inputMessage["input"] = input //交易输入
  7236. bytesData, err := json.Marshal(inputMessage)
  7237. fmt.Println(string(bytesData))
  7238. if err != nil {
  7239. fmt.Println(err.Error())
  7240. return err.Error(), ""
  7241. }
  7242. reader := bytes.NewReader(bytesData)
  7243. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7244. gdyb_url := beego.AppConfig.String("gdyb_url")
  7245. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7246. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7247. url := gdyb_url + "3102"
  7248. request, err := http.NewRequest("POST", url, reader)
  7249. if err != nil {
  7250. fmt.Println(err.Error())
  7251. return err.Error(), ""
  7252. }
  7253. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  7254. request.Header.Set("x-tif-paasid", gdyb_paasid)
  7255. request.Header.Set("x-tif-signature", signature)
  7256. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  7257. request.Header.Set("x-tif-nonce", nonce)
  7258. client := http.Client{}
  7259. resp, err := client.Do(request)
  7260. if err != nil {
  7261. fmt.Println(err.Error())
  7262. return err.Error(), ""
  7263. }
  7264. respBytes, err := ioutil.ReadAll(resp.Body)
  7265. if err != nil {
  7266. fmt.Println(err.Error())
  7267. return err.Error(), ""
  7268. }
  7269. str := string(respBytes)
  7270. fmt.Println(str)
  7271. return str, string(bytesData)
  7272. }
  7273. // 分页函数
  7274. func paginate(data []map[string]interface{}, pageSize int) [][]map[string]interface{} {
  7275. var pages [][]map[string]interface{}
  7276. totalItems := len(data)
  7277. for i := 0; i < totalItems; i += pageSize {
  7278. end := i + pageSize
  7279. if end > totalItems {
  7280. end = totalItems
  7281. }
  7282. pages = append(pages, data[i:end])
  7283. }
  7284. return pages
  7285. }
  7286. func Gzyb3501(struct3501 models.Struct3501, secret_key string) (string, string) {
  7287. // 生成签名
  7288. nonce := GetRandomString(32)
  7289. timestamp := time.Now().Unix()
  7290. signature := setSignature(timestamp, nonce, secret_key)
  7291. // 生成输入报文
  7292. //inputMessage := SetInputMessage(timestamp, struct3501.OrgName, struct3501.Opter, struct3501.FixmedinsHilistId, struct3501.InsuplcAdmdvs, struct3501.MdtrtareaAdmvs, struct3501.Cainfo,"")
  7293. sign := GetSignInInfo(struct3501.FixmedinsCode)
  7294. inputMessage := SetGZInputMessage(nonce, timestamp, struct3501.OrgName, struct3501.Opter, struct3501.FixmedinsCode, struct3501.InsuplcAdmdvs, struct3501.MdtrtareaAdmvs, sign)
  7295. input := make(map[string]interface{})
  7296. inputData := make(map[string]interface{})
  7297. inputMessage["infno"] = "3501" // 交易编码
  7298. inputData["med_list_codg"] = struct3501.MedListCodg // 定点医药机构目录编号
  7299. inputData["fixmedins_hilist_id"] = struct3501.FixmedinsHilistId // 定点医药机构目录编号
  7300. inputData["fixmedins_hilist_name"] = struct3501.OrgName // 定点医药机构目录名称
  7301. inputData["rx_flag"] = struct3501.RxFlag //
  7302. inputData["invdate"] = struct3501.Invdate // 人员编号 (来自1101接口返回)
  7303. inputData["inv_cnt"] = struct3501.InvCnt // 人员编号 (来自1101接口返回)
  7304. inputData["manu_lotnum"] = struct3501.ManuLotnum // 人员编号 (来自1101接口返回)
  7305. inputData["fixmedins_bchno"] = struct3501.FixmedinsBchno // 人员编号 (来自1101接口返回)
  7306. inputData["manu_date"] = struct3501.ManuDate // 人员编号 (来自1101接口返回)
  7307. inputData["expy_end"] = struct3501.ExpyEnd // 人员编号 (来自1101接口返回)
  7308. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  7309. input["invinfo"] = inputData
  7310. inputMessage["input"] = input //交易输入
  7311. bytesData, err := json.Marshal(inputMessage)
  7312. fmt.Println(string(bytesData))
  7313. if err != nil {
  7314. fmt.Println(err.Error())
  7315. return err.Error(), ""
  7316. }
  7317. reader := bytes.NewReader(bytesData)
  7318. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7319. gdyb_url := beego.AppConfig.String("gdyb_url")
  7320. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7321. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7322. url := gdyb_url + "3501"
  7323. request, err := http.NewRequest("POST", url, reader)
  7324. if err != nil {
  7325. fmt.Println(err.Error())
  7326. return err.Error(), ""
  7327. }
  7328. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  7329. request.Header.Set("x-tif-paasid", gdyb_paasid)
  7330. request.Header.Set("x-tif-signature", signature)
  7331. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  7332. request.Header.Set("x-tif-nonce", nonce)
  7333. client := http.Client{}
  7334. resp, err := client.Do(request)
  7335. if err != nil {
  7336. fmt.Println(err.Error())
  7337. return err.Error(), ""
  7338. }
  7339. respBytes, err := ioutil.ReadAll(resp.Body)
  7340. if err != nil {
  7341. fmt.Println(err.Error())
  7342. return err.Error(), ""
  7343. }
  7344. str := string(respBytes)
  7345. fmt.Println(str)
  7346. return str, string(bytesData)
  7347. }
  7348. func Gzyb3502(struct3502 models.Struct3502, secret_key string) (string, string) {
  7349. // 生成签名
  7350. nonce := GetRandomString(32)
  7351. timestamp := time.Now().Unix()
  7352. signature := setSignature(timestamp, nonce, secret_key)
  7353. sign := GetSignInInfo(struct3502.FixmedinsCode)
  7354. inputMessage := SetGZInputMessage(nonce, timestamp, struct3502.OrgName, struct3502.Opter, struct3502.FixmedinsCode, struct3502.InsuplcAdmdvs, struct3502.MdtrtareaAdmvs, sign)
  7355. // 生成输入报文
  7356. //inputMessage := SetGdInputMessage(timestamp, struct3502.OrgName, struct3502.Opter, struct3502.FixmedinsCode, struct3502.InsuplcAdmdvs, struct3502.MdtrtareaAdmvs, struct3502.Cainfo,sign)
  7357. input := make(map[string]interface{})
  7358. inputData := make(map[string]interface{})
  7359. inputMessage["infno"] = "3502" // 交易编码
  7360. inputData["med_list_codg"] = struct3502.MedListCodg // 定点医药机构目录编号
  7361. inputData["inv_chg_type"] = struct3502.InvChgType // 定点医药机构目录编号
  7362. inputData["fixmedins_hilist_id"] = struct3502.FixmedinsHilistId // 定点医药机构目录编号
  7363. inputData["fixmedins_hilist_name"] = struct3502.FixmedinsHilistName // 定点医药机构目录名称
  7364. inputData["fixmedins_bchno"] = struct3502.FixmedinsBchno // 人员编号 (来自1101接口返回)
  7365. inputData["pric"] = struct3502.Pric // 人员编号 (来自1101接口返回)
  7366. inputData["cnt"] = struct3502.Cnt // 人员编号 (来自1101接口返回)
  7367. inputData["rx_flag"] = struct3502.RxFlag //
  7368. inputData["inv_chg_time"] = struct3502.InvChgTime // 人员编号 (来自1101接口返回)
  7369. inputData["inv_chg_opter_name"] = "" // 人员编号 (来自1101接口返回)
  7370. inputData["memo"] = struct3502.Memo // 人员编号 (来自1101接口返回)
  7371. inputData["trdn_flag"] = "" // 人员编号 (来自1101接口返回)
  7372. feedetail := make([]map[string]interface{}, 0)
  7373. codes := strings.Split(struct3502.DrugTracCodg, ",")
  7374. for _, item := range codes {
  7375. druginputData := make(map[string]interface{})
  7376. druginputData["drug_trac_codg"] = item
  7377. feedetail = append(feedetail, druginputData)
  7378. }
  7379. inputData["drugtracinfo"] = feedetail
  7380. input["invinfo"] = inputData
  7381. inputMessage["input"] = input //交易输入
  7382. bytesData, err := json.Marshal(inputMessage)
  7383. fmt.Println(string(bytesData))
  7384. if err != nil {
  7385. fmt.Println(err.Error())
  7386. return err.Error(), ""
  7387. }
  7388. reader := bytes.NewReader(bytesData)
  7389. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7390. //gdyb_url := beego.AppConfig.String("gdyb_url")
  7391. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7392. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7393. url := "http://hosp-gz.gd.hsip.gov.cn/ebus/gdyb_api/prd/hsa/hgs/" + "3502"
  7394. request, err := http.NewRequest("POST", url, reader)
  7395. if err != nil {
  7396. fmt.Println(err.Error())
  7397. return err.Error(), ""
  7398. }
  7399. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  7400. request.Header.Set("x-tif-paasid", gdyb_paasid)
  7401. request.Header.Set("x-tif-signature", signature)
  7402. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  7403. request.Header.Set("x-tif-nonce", nonce)
  7404. client := http.Client{}
  7405. resp, err := client.Do(request)
  7406. if err != nil {
  7407. fmt.Println(err.Error())
  7408. return err.Error(), ""
  7409. }
  7410. respBytes, err := ioutil.ReadAll(resp.Body)
  7411. if err != nil {
  7412. fmt.Println(err.Error())
  7413. return err.Error(), ""
  7414. }
  7415. str := string(respBytes)
  7416. fmt.Println(str)
  7417. return str, string(bytesData)
  7418. }
  7419. func Gzyb3503(struct3503 models.Struct3503, secret_key string) (string, string) {
  7420. // 生成签名
  7421. nonce := GetRandomString(32)
  7422. timestamp := time.Now().Unix()
  7423. signature := setSignature(timestamp, nonce, secret_key)
  7424. // 生成输入报文
  7425. sign := GetSignInInfo(struct3503.FixmedinsCode)
  7426. inputMessage := SetGZInputMessage(nonce, timestamp, struct3503.OrgName, struct3503.Opter, struct3503.FixmedinsCode, struct3503.InsuplcAdmdvs, struct3503.MdtrtareaAdmvs, sign)
  7427. input := make(map[string]interface{})
  7428. inputMessage["infno"] = "3503"
  7429. item := struct3503
  7430. feedetailInfo := make(map[string]interface{})
  7431. feedetailInfo["med_list_codg"] = item.MedListCodg
  7432. feedetailInfo["fixmedins_hilist_id"] = item.FixmedinsHilistId
  7433. feedetailInfo["fixmedins_hilist_name"] = item.FixmedinsHilistName
  7434. feedetailInfo["dynt_no"] = ""
  7435. feedetailInfo["fixmedins_bchno"] = item.FixmedinsBchno // 人员编号 (来自1101接口返回)
  7436. feedetailInfo["spler_name"] = item.SplerName // 人员编号 (来自1101接口返回)
  7437. feedetailInfo["spler_pmtno"] = "" // 人员编号 (来自1101接口返回)
  7438. feedetailInfo["manu_lotnum"] = item.ManuLotnum // 人员编号 (来自1101接口返回)
  7439. feedetailInfo["prodentp_name"] = item.ProdentpName // 人员编号 (来自1101接口返回)
  7440. feedetailInfo["aprvno"] = item.Aprvno // 人员编号 (来自1101接口返回)
  7441. feedetailInfo["manu_date"] = item.ManuDate // 人员编号 (来自1101接口返回)
  7442. feedetailInfo["expy_end"] = item.ExpyEnd // 人员编号 (来自1101接口返回)
  7443. feedetailInfo["finl_trns_pric"] = item.FinlTrnsPric // 人员编号 (来自1101接口返回)
  7444. feedetailInfo["purc_retn_cnt"] = item.PurcRetnCnt // 人员编号 (来自1101接口返回)
  7445. feedetailInfo["purc_invo_codg"] = item.PurcInvoCodg // 人员编号 (来自1101接口返回)
  7446. feedetailInfo["purc_invo_no"] = item.PurcInvoNo // 人员编号 (来自1101接口返回)
  7447. feedetailInfo["rx_flag"] = item.RxFlag // 人员编号 (来自1101接口返回)
  7448. feedetailInfo["purc_retn_stoin_time"] = item.PurcRetnStoinTime // 人员编号 (来自1101接口返回)
  7449. feedetailInfo["purc_retn_opter_name"] = item.PurcRetnOpterName // 人员编号 (来自1101接口返回)
  7450. feedetailInfo["prod_geay_flag"] = "" // 人员编号 (来自1101接口返回)
  7451. feedetailInfo["memo"] = "" // 人员编号 (来自1101接口返回)
  7452. input["purcinfo"] = feedetailInfo
  7453. inputMessage["input"] = input //交易输入
  7454. bytesData, err := json.Marshal(inputMessage)
  7455. fmt.Println(string(bytesData))
  7456. if err != nil {
  7457. fmt.Println(err.Error())
  7458. return err.Error(), ""
  7459. }
  7460. reader := bytes.NewReader(bytesData)
  7461. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7462. gdyb_url := beego.AppConfig.String("gdyb_url")
  7463. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7464. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7465. url := gdyb_url + "3503"
  7466. request, err := http.NewRequest("POST", url, reader)
  7467. if err != nil {
  7468. fmt.Println(err.Error())
  7469. return err.Error(), ""
  7470. }
  7471. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  7472. request.Header.Set("x-tif-paasid", gdyb_paasid)
  7473. request.Header.Set("x-tif-signature", signature)
  7474. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  7475. request.Header.Set("x-tif-nonce", nonce)
  7476. client := http.Client{}
  7477. resp, err := client.Do(request)
  7478. if err != nil {
  7479. fmt.Println(err.Error())
  7480. return err.Error(), ""
  7481. }
  7482. respBytes, err := ioutil.ReadAll(resp.Body)
  7483. if err != nil {
  7484. fmt.Println(err.Error())
  7485. return err.Error(), ""
  7486. }
  7487. str := string(respBytes)
  7488. fmt.Println(str)
  7489. return str, string(bytesData)
  7490. }
  7491. func Gzyb3504(struct3504 models.Struct3504, secret_key string) (string, string) {
  7492. // 生成签名
  7493. nonce := GetRandomString(32)
  7494. timestamp := time.Now().Unix()
  7495. signature := setSignature(timestamp, nonce, secret_key)
  7496. // 生成输入报文
  7497. //inputMessage := SetGdInputMessage(timestamp, struct3504.OrgName, struct3504.Opter, struct3504.FixmedinsCode, struct3504.InsuplcAdmdvs, struct3504.MdtrtareaAdmvs, struct3504.Cainfo)
  7498. sign := GetSignInInfo(struct3504.FixmedinsCode)
  7499. inputMessage := SetGZInputMessage(nonce, timestamp, struct3504.OrgName, struct3504.Opter, struct3504.FixmedinsCode, struct3504.InsuplcAdmdvs, struct3504.MdtrtareaAdmvs, sign)
  7500. input := make(map[string]interface{})
  7501. inputData := make(map[string]interface{})
  7502. inputMessage["infno"] = "3504" // 交易编码
  7503. inputData["med_list_codg"] = struct3504.MedListCodg // 定点医药机构目录编号
  7504. inputData["fixmedins_hilist_id"] = struct3504.FixmedinsHilistId // 定点医药机构目录编号
  7505. inputData["fixmedins_hilist_name"] = struct3504.FixmedinsHilistName // 定点医药机构目录名称
  7506. inputData["fixmedins_bchno"] = struct3504.FixmedinsBchno // 人员编号 (来自1101接口返回)
  7507. inputData["spler_name"] = struct3504.SplerName // 人员编号 (来自1101接口返回)
  7508. inputData["spler_pmtno"] = "" // 人员编号 (来自1101接口返回)
  7509. inputData["manu_date"] = struct3504.ManuDate // 人员编号 (来自1101接口返回)
  7510. inputData["expy_end"] = struct3504.ExpyEnd // 人员编号 (来自1101接口返回)
  7511. inputData["finl_trns_pric"] = struct3504.FinlTrnsPric // 人员编号 (来自1101接口返回)
  7512. inputData["purc_retn_cnt"] = struct3504.PurcRetnCnt // 人员编号 (来自1101接口返回)
  7513. inputData["purc_invo_codg"] = struct3504.PurcInvoCodg // 人员编号 (来自1101接口返回)
  7514. inputData["purc_invo_no"] = struct3504.PurcInvoNo // 人员编号 (来自1101接口返回)
  7515. inputData["rx_flag"] = struct3504.RxFlag
  7516. inputData["purc_retn_stoin_time"] = struct3504.PurcRetnStoin
  7517. inputData["purc_retn_opter_name"] = struct3504.PurcRetnStoin
  7518. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  7519. inputData["medins_prod_purc_no"] = "" // 人员编号 (来自1101接口返回)
  7520. input["purcinfo"] = inputData
  7521. inputMessage["input"] = input //交易输入
  7522. bytesData, err := json.Marshal(inputMessage)
  7523. fmt.Println(string(bytesData))
  7524. if err != nil {
  7525. fmt.Println(err.Error())
  7526. return err.Error(), ""
  7527. }
  7528. reader := bytes.NewReader(bytesData)
  7529. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7530. gdyb_url := beego.AppConfig.String("gdyb_url")
  7531. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7532. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7533. url := gdyb_url + "3504"
  7534. request, err := http.NewRequest("POST", url, reader)
  7535. if err != nil {
  7536. fmt.Println(err.Error())
  7537. return err.Error(), ""
  7538. }
  7539. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  7540. request.Header.Set("x-tif-paasid", gdyb_paasid)
  7541. request.Header.Set("x-tif-signature", signature)
  7542. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  7543. request.Header.Set("x-tif-nonce", nonce)
  7544. client := http.Client{}
  7545. resp, err := client.Do(request)
  7546. if err != nil {
  7547. fmt.Println(err.Error())
  7548. return err.Error(), ""
  7549. }
  7550. respBytes, err := ioutil.ReadAll(resp.Body)
  7551. if err != nil {
  7552. fmt.Println(err.Error())
  7553. return err.Error(), ""
  7554. }
  7555. str := string(respBytes)
  7556. fmt.Println(str)
  7557. return str, string(bytesData)
  7558. }
  7559. func Gzyb3505(struct3505 models.Struct3505, secret_key string) (string, string) {
  7560. // 生成签名
  7561. nonce := GetRandomString(32)
  7562. timestamp := time.Now().Unix()
  7563. signature := setSignature(timestamp, nonce, secret_key)
  7564. // 生成输入报文
  7565. //inputMessage := SetGdInputMessage(timestamp, struct3505.OrgName, struct3505.Opter, struct3505.FixmedinsHilistId, struct3505.InsuplcAdmdvs, struct3505.MdtrtareaAdmvs, struct3505.Cainfo)
  7566. sign := GetSignInInfo(struct3505.FixmedinsCode)
  7567. inputMessage := SetGZInputMessage(nonce, timestamp, struct3505.OrgName, struct3505.Opter, struct3505.FixmedinsCode, struct3505.InsuplcAdmdvs, struct3505.MdtrtareaAdmvs, sign)
  7568. input := make(map[string]interface{})
  7569. inputData := make(map[string]interface{})
  7570. inputMessage["infno"] = "3505" // 交易编码
  7571. inputData["med_list_codg"] = struct3505.MedListCodg // 定点医药机构目录编号
  7572. inputData["fixmedins_hilist_id"] = struct3505.FixmedinsHilistId // 定点医药机构目录编号
  7573. inputData["fixmedins_hilist_name"] = struct3505.FixmedinsHilistName // 定点医药机构目录名称
  7574. inputData["fixmedins_bchno"] = struct3505.FixmedinsBchno // 人员编号 (来自1101接口返回)
  7575. inputData["prsc_dr_cert_type"] = struct3505.PrscDrCertType // 人员编号 (来自1101接口返回)
  7576. inputData["prsc_dr_certno"] = struct3505.PrscDrCertno // 人员编号 (来自1101接口返回)
  7577. inputData["prsc_dr_name"] = struct3505.PrscDrName // 人员编号 (来自1101接口返回)
  7578. inputData["phar_cert_type"] = struct3505.PharCertType // 人员编号 (来自1101接口返回)
  7579. inputData["phar_certno"] = struct3505.PharCertno // 人员编号 (来自1101接口返回)
  7580. inputData["phar_name"] = struct3505.PharName // 人员编号 (来自1101接口返回)
  7581. inputData["phar_prac_cert_no"] = struct3505.PharPracCertNo // 人员编号 (来自1101接口返回)
  7582. inputData["hi_feesetl_type"] = struct3505.HiFeesetlType // 人员编号 (来自1101接口返回)
  7583. inputData["setl_id"] = struct3505.SetlId // 人员编号 (来自1101接口返回)
  7584. inputData["mdtrt_sn"] = struct3505.MdtrtSn // 人员编号 (来自1101接口返回)
  7585. inputData["psn_no"] = struct3505.PsnNo // 人员编号 (来自1101接口返回)
  7586. inputData["psn_cert_type"] = struct3505.PsnCertType // 人员编号 (来自1101接口返回)
  7587. inputData["certno"] = struct3505.CertNo // 人员编号 (来自1101接口返回)
  7588. inputData["psn_name"] = struct3505.PsnName // 人员编号 (来自1101接口返回)
  7589. inputData["manu_lotnum"] = struct3505.ManuLotnum // 人员编号 (来自1101接口返回)
  7590. inputData["manu_date"] = struct3505.ManuDate // 人员编号 (来自1101接口返回)
  7591. inputData["expy_end"] = struct3505.ExpyEnd // 人员编号 (来自1101接口返回)
  7592. inputData["rx_flag"] = struct3505.RxFlag // 人员编号 (来自1101接口返回)
  7593. inputData["trdn_flag"] = struct3505.TrdnFlag // 人员编号 (来自1101接口返回)
  7594. inputData["finl_trns_pric"] = struct3505.FinlTrnsPric // 人员编号 (来自1101接口返回)
  7595. inputData["rxno"] = struct3505.Rxno // 人员编号 (来自1101接口返回)
  7596. inputData["rx_circ_flag"] = struct3505.RxCircFlag // 人员编号 (来自1101接口返回)
  7597. inputData["rtal_docno"] = struct3505.RtalDocno // 人员编号 (来自1101接口返回)
  7598. inputData["stoout_no"] = struct3505.StooutNo // 人员编号 (来自1101接口返回)
  7599. inputData["MDTRT_SETL_TYPE"] = struct3505.MdtrtSetlType // 人员编号 (来自1101接口返回)
  7600. inputData["bchno"] = struct3505.Bchno // 人员编号 (来自1101接口返回)
  7601. codes := strings.Split(struct3505.DrugTracCodg, ",")
  7602. inputData["drug_trac_codg"] = codes[0] // 人员编号 (来自1101接口返回)
  7603. inputData["drug_prod_barc"] = struct3505.DrugProdBarc // 人员编号 (来自1101接口返回)
  7604. inputData["shelf_posi"] = struct3505.ShelfPosi // 人员编号 (来自1101接口返回)
  7605. inputData["sel_retn_cnt"] = struct3505.SelRetnCnt // 人员编号 (来自1101接口返回)
  7606. inputData["sel_retn_time"] = struct3505.SelRetnTime // 人员编号 (来自1101接口返回)
  7607. inputData["sel_retn_opter_name"] = struct3505.SelRetnOpterName // 人员编号 (来自1101接口返回)
  7608. inputData["memo"] = struct3505.Memo // 人员编号 (来自1101接口返回)
  7609. //drug_trac_cod .g
  7610. feedetail := make([]map[string]interface{}, 0)
  7611. //codes = strings.Split(struct3505.DrugTracCodg, ",")
  7612. for _, item := range codes {
  7613. if len(item) > 0 {
  7614. druginputData := make(map[string]interface{})
  7615. druginputData["drug_trac_codg"] = item
  7616. feedetail = append(feedetail, druginputData)
  7617. }
  7618. }
  7619. inputData["drugtracinfo"] = feedetail
  7620. input["selinfo"] = inputData
  7621. inputMessage["input"] = input //交易输入
  7622. input["selinfo"] = inputData
  7623. inputMessage["input"] = input //交易输入
  7624. bytesData, err := json.Marshal(inputMessage)
  7625. fmt.Println(string(bytesData))
  7626. if err != nil {
  7627. fmt.Println(err.Error())
  7628. return err.Error(), ""
  7629. }
  7630. reader := bytes.NewReader(bytesData)
  7631. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7632. //gdyb_url := ""
  7633. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7634. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7635. //url := "" + "3505"
  7636. url := "http://hosp-gz.gd.hsip.gov.cn/ebus/gdyb_api/prd/hsa/hgs/" + "3505"
  7637. fmt.Println(gdyb_paasid)
  7638. fmt.Println(url)
  7639. request, err := http.NewRequest("POST", url, reader)
  7640. if err != nil {
  7641. fmt.Println(err.Error())
  7642. return err.Error(), ""
  7643. }
  7644. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  7645. request.Header.Set("x-tif-paasid", gdyb_paasid)
  7646. request.Header.Set("x-tif-signature", signature)
  7647. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  7648. request.Header.Set("x-tif-nonce", nonce)
  7649. client := http.Client{}
  7650. resp, err := client.Do(request)
  7651. if err != nil {
  7652. fmt.Println(err.Error())
  7653. return err.Error(), ""
  7654. }
  7655. respBytes, err := ioutil.ReadAll(resp.Body)
  7656. if err != nil {
  7657. fmt.Println(err.Error())
  7658. return err.Error(), ""
  7659. }
  7660. str := string(respBytes)
  7661. fmt.Println(str)
  7662. return str, string(bytesData)
  7663. }
  7664. func Gzyb3506(struct3506 models.Struct3506, secret_key string) (string, string) {
  7665. // 生成签名
  7666. nonce := GetRandomString(32)
  7667. timestamp := time.Now().Unix()
  7668. signature := setSignature(timestamp, nonce, secret_key)
  7669. // 生成输入报文
  7670. //inputMessage := SetGdInputMessage(timestamp, struct3506.OrgName, struct3506.Opter, struct3506.FixmedinsCode, struct3506.InsuplcAdmdvs, struct3506.MdtrtareaAdmvs, struct3506.Cainfo)
  7671. sign := GetSignInInfo(struct3506.FixmedinsCode)
  7672. inputMessage := SetGZInputMessage(nonce, timestamp, struct3506.OrgName, struct3506.Opter, struct3506.FixmedinsCode, struct3506.InsuplcAdmdvs, struct3506.MdtrtareaAdmvs, sign)
  7673. input := make(map[string]interface{})
  7674. inputData := make(map[string]interface{})
  7675. inputMessage["infno"] = "3506" // 交易编码
  7676. inputData["med_list_codg"] = struct3506.MedListCodg // 定点医药机构目录编号
  7677. inputData["fixmedins_hilist_id"] = struct3506.FixmedinsHilistId // 定点医药机构目录编号
  7678. inputData["fixmedins_hilist_name"] = struct3506.OrgName // 定点医药机构目录名称
  7679. inputData["fixmedins_bchno"] = struct3506.FixmedinsBchno // 人员编号 (来自1101接口返回)
  7680. inputData["setl_id"] = struct3506.SetlId // 人员编号 (来自1101接口返回)
  7681. inputData["psn_no"] = struct3506.PsnNo // 人员编号 (来自1101接口返回)
  7682. inputData["psn_cert_type"] = struct3506.PsnCertType // 人员编号 (来自1101接口返回)
  7683. inputData["certno"] = struct3506.Certno // 人员编号 (来自1101接口返回)
  7684. inputData["psn_name"] = struct3506.PsnName // 人员编号 (来自1101接口返回)
  7685. inputData["manu_lotnum"] = struct3506.ManuLotnum // 人员编号 (来自1101接口返回)
  7686. inputData["manu_date"] = struct3506.ManuDate // 人员编号 (来自1101接口返回)
  7687. inputData["expy_end"] = struct3506.ExpyEnd // 人员编号 (来自1101接口返回)
  7688. inputData["rx_flag"] = struct3506.RxFlag // 人员编号 (来自1101接口返回)
  7689. inputData["trdn_flag"] = struct3506.TrdnFlag // 人员编号 (来自1101接口返回)
  7690. inputData["finl_trns_pric"] = struct3506.FinlTrnsPric // 人员编号 (来自1101接口返回)
  7691. inputData["sel_retn_cnt"] = struct3506.SelRetnCnt // 人员编号 (来自1101接口返回)
  7692. inputData["sel_retn_time"] = struct3506.SelRetnTime // 人员编号 (来自1101接口返回)
  7693. inputData["sel_retn_opter_name"] = struct3506.SelRetnOpterName // 人员编号 (来自1101接口返回)
  7694. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  7695. inputData["medins_prod_sel_no"] = "" // 人员编号 (来自1101接口返回)
  7696. input["selinfo"] = inputData
  7697. inputMessage["input"] = input //交易输入
  7698. bytesData, err := json.Marshal(inputMessage)
  7699. fmt.Println(string(bytesData))
  7700. if err != nil {
  7701. fmt.Println(err.Error())
  7702. return err.Error(), ""
  7703. }
  7704. reader := bytes.NewReader(bytesData)
  7705. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7706. gdyb_url := beego.AppConfig.String("gdyb_url")
  7707. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7708. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7709. url := gdyb_url + "3506"
  7710. request, err := http.NewRequest("POST", url, reader)
  7711. if err != nil {
  7712. fmt.Println(err.Error())
  7713. return err.Error(), ""
  7714. }
  7715. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  7716. request.Header.Set("x-tif-paasid", gdyb_paasid)
  7717. request.Header.Set("x-tif-signature", signature)
  7718. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  7719. request.Header.Set("x-tif-nonce", nonce)
  7720. client := http.Client{}
  7721. resp, err := client.Do(request)
  7722. if err != nil {
  7723. fmt.Println(err.Error())
  7724. return err.Error(), ""
  7725. }
  7726. respBytes, err := ioutil.ReadAll(resp.Body)
  7727. if err != nil {
  7728. fmt.Println(err.Error())
  7729. return err.Error(), ""
  7730. }
  7731. str := string(respBytes)
  7732. fmt.Println(str)
  7733. return str, string(bytesData)
  7734. }
  7735. func Gzyb3507(struct3507 models.Struct3507, secret_key string) (string, string) {
  7736. // 生成签名
  7737. nonce := GetRandomString(32)
  7738. timestamp := time.Now().Unix()
  7739. signature := setSignature(timestamp, nonce, secret_key)
  7740. // 生成输入报文
  7741. //inputMessage := SetGdInputMessage(timestamp, struct3507.OrgName, struct3507.Opter, struct3507.FixmedinsCode, struct3507.InsuplcAdmdvs, struct3507.MdtrtareaAdmvs, struct3507.Cainfo)
  7742. sign := GetSignInInfo(struct3507.FixmedinsCode)
  7743. inputMessage := SetGZInputMessage(nonce, timestamp, struct3507.OrgName, struct3507.Opter, struct3507.FixmedinsCode, struct3507.InsuplcAdmdvs, struct3507.MdtrtareaAdmvs, sign)
  7744. input := make(map[string]interface{})
  7745. inputData := make(map[string]interface{})
  7746. inputMessage["infno"] = "3507" // 交易编码
  7747. inputData["fixmedins_bchno"] = struct3507.FixmedinsCode // 人员编号 (来自1101接口返回)
  7748. inputData["inv_data_type"] = struct3507.InvDataType // 人员编号 (来自1101接口返回)
  7749. input["data"] = inputData
  7750. inputMessage["input"] = input //交易输入
  7751. bytesData, err := json.Marshal(inputMessage)
  7752. fmt.Println(string(bytesData))
  7753. if err != nil {
  7754. fmt.Println(err.Error())
  7755. return err.Error(), ""
  7756. }
  7757. reader := bytes.NewReader(bytesData)
  7758. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7759. gdyb_url := beego.AppConfig.String("gdyb_url")
  7760. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7761. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7762. url := gdyb_url + "3507"
  7763. request, err := http.NewRequest("POST", url, reader)
  7764. if err != nil {
  7765. fmt.Println(err.Error())
  7766. return err.Error(), ""
  7767. }
  7768. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  7769. request.Header.Set("x-tif-paasid", gdyb_paasid)
  7770. request.Header.Set("x-tif-signature", signature)
  7771. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  7772. request.Header.Set("x-tif-nonce", nonce)
  7773. client := http.Client{}
  7774. resp, err := client.Do(request)
  7775. if err != nil {
  7776. fmt.Println(err.Error())
  7777. return err.Error(), ""
  7778. }
  7779. respBytes, err := ioutil.ReadAll(resp.Body)
  7780. if err != nil {
  7781. fmt.Println(err.Error())
  7782. return err.Error(), ""
  7783. }
  7784. str := string(respBytes)
  7785. fmt.Println(str)
  7786. return str, string(bytesData)
  7787. }
  7788. func Gzyb3508(struct3508 models.Struct3508, secret_key string) (string, string) {
  7789. // 生成签名
  7790. nonce := GetRandomString(32)
  7791. timestamp := time.Now().Unix()
  7792. signature := setSignature(timestamp, nonce, secret_key)
  7793. // 生成输入报文
  7794. //inputMessage := SetGdInputMessage(timestamp, struct3508.OrgName, struct3508.Opter, struct3508.FixmedinsCode, struct3508.InsuplcAdmdvs, struct3508.MdtrtareaAdmvs, struct3508.Cainfo)
  7795. sign := GetSignInInfo(struct3508.FixmedinsCode)
  7796. inputMessage := SetGZInputMessage(nonce, timestamp, struct3508.OrgName, struct3508.Opter, struct3508.FixmedinsCode, struct3508.InsuplcAdmdvs, struct3508.MdtrtareaAdmvs, sign)
  7797. input := make(map[string]interface{})
  7798. inputData := make(map[string]interface{})
  7799. inputMessage["infno"] = "3508"
  7800. inputData["fixmedins_code"] = struct3508.FixmedinsCode
  7801. inputData["medins_list_codg"] = struct3508.MedListCodg
  7802. inputData["fixmedins_bchno"] = ""
  7803. inputData["begndate"] = struct3508.Begndate
  7804. inputData["enddate"] = struct3508.Enddate
  7805. inputData["medins_prod_inv_no"] = ""
  7806. inputData["medins_list_name"] = ""
  7807. inputData["rx_flag"] = ""
  7808. inputData["list_sp_item_flag"] = ""
  7809. inputData["trdn_flag"] = ""
  7810. inputData["invdate"] = ""
  7811. inputData["manu_lotnum"] = ""
  7812. inputData["manu_date"] = ""
  7813. inputData["expy_end"] = ""
  7814. inputData["memo"] = ""
  7815. inputData["vali_flag"] = ""
  7816. inputData["rid"] = ""
  7817. inputData["crter_id"] = ""
  7818. inputData["crter_name"] = ""
  7819. inputData["crte_optins_no"] = ""
  7820. inputData["opter_id"] = ""
  7821. inputData["opter_name"] = ""
  7822. inputData["optins_no"] = ""
  7823. inputData["poolarea_no"] = ""
  7824. inputData["fixmedins_bchno"] = ""
  7825. inputData["inv_data_type"] = ""
  7826. input["data"] = inputData
  7827. inputMessage["input"] = input //交易输入
  7828. bytesData, err := json.Marshal(inputMessage)
  7829. fmt.Println(string(bytesData))
  7830. if err != nil {
  7831. fmt.Println(err.Error())
  7832. return err.Error(), ""
  7833. }
  7834. reader := bytes.NewReader(bytesData)
  7835. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7836. gdyb_url := beego.AppConfig.String("gdyb_url")
  7837. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7838. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7839. url := gdyb_url + "3508"
  7840. request, err := http.NewRequest("POST", url, reader)
  7841. if err != nil {
  7842. fmt.Println(err.Error())
  7843. return err.Error(), ""
  7844. }
  7845. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  7846. request.Header.Set("x-tif-paasid", gdyb_paasid)
  7847. request.Header.Set("x-tif-signature", signature)
  7848. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  7849. request.Header.Set("x-tif-nonce", nonce)
  7850. client := http.Client{}
  7851. resp, err := client.Do(request)
  7852. if err != nil {
  7853. fmt.Println(err.Error())
  7854. return err.Error(), ""
  7855. }
  7856. respBytes, err := ioutil.ReadAll(resp.Body)
  7857. if err != nil {
  7858. fmt.Println(err.Error())
  7859. return err.Error(), ""
  7860. }
  7861. str := string(respBytes)
  7862. fmt.Println(str)
  7863. return str, string(bytesData)
  7864. }
  7865. func Gzyb3509(struct3509 models.Struct3509, secret_key string) (string, string) {
  7866. // 生成签名
  7867. nonce := GetRandomString(32)
  7868. timestamp := time.Now().Unix()
  7869. signature := setSignature(timestamp, nonce, secret_key)
  7870. // 生成输入报文
  7871. //inputMessage := SetGdInputMessage(timestamp, struct3509.OrgName, struct3509.Opter, struct3509.FixmedinsCode, struct3509.InsuplcAdmdvs, struct3509.MdtrtareaAdmvs, struct3509.Cainfo)
  7872. sign := GetSignInInfo(struct3509.FixmedinsCode)
  7873. inputMessage := SetGZInputMessage(nonce, timestamp, struct3509.OrgName, struct3509.Opter, struct3509.FixmedinsCode, struct3509.InsuplcAdmdvs, struct3509.MdtrtareaAdmvs, sign)
  7874. input := make(map[string]interface{})
  7875. inputData := make(map[string]interface{})
  7876. inputMessage["infno"] = "3509"
  7877. inputData["fixmedins_code"] = struct3509.FixmedinsCode
  7878. //inputData["med_list_codg"] = struct3509.MedinsListCodg
  7879. inputData["medins_list_codg"] = struct3509.MedListCodg
  7880. inputData["fixmedins_bchno"] = ""
  7881. inputData["begndate"] = struct3509.Begndate
  7882. inputData["enddate"] = struct3509.Enddate
  7883. inputData["medins_prod_inv_no"] = ""
  7884. inputData["medins_list_name"] = ""
  7885. inputData["rx_flag"] = ""
  7886. inputData["list_sp_item_flag"] = ""
  7887. inputData["trdn_flag"] = ""
  7888. inputData["invdate"] = ""
  7889. inputData["manu_lotnum"] = ""
  7890. inputData["manu_date"] = ""
  7891. inputData["expy_end"] = ""
  7892. inputData["memo"] = ""
  7893. inputData["vali_flag"] = ""
  7894. inputData["rid"] = ""
  7895. inputData["crter_id"] = ""
  7896. inputData["crter_name"] = ""
  7897. inputData["crte_optins_no"] = ""
  7898. inputData["opter_id"] = ""
  7899. inputData["opter_name"] = ""
  7900. inputData["optins_no"] = ""
  7901. inputData["poolarea_no"] = ""
  7902. inputData["fixmedins_bchno"] = ""
  7903. inputData["inv_data_type"] = ""
  7904. input["data"] = inputData
  7905. inputMessage["input"] = input //交易输入
  7906. bytesData, err := json.Marshal(inputMessage)
  7907. fmt.Println(string(bytesData))
  7908. if err != nil {
  7909. fmt.Println(err.Error())
  7910. return err.Error(), ""
  7911. }
  7912. reader := bytes.NewReader(bytesData)
  7913. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7914. gdyb_url := beego.AppConfig.String("gdyb_url")
  7915. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7916. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7917. url := gdyb_url + "3509"
  7918. request, err := http.NewRequest("POST", url, reader)
  7919. if err != nil {
  7920. fmt.Println(err.Error())
  7921. return err.Error(), ""
  7922. }
  7923. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  7924. request.Header.Set("x-tif-paasid", gdyb_paasid)
  7925. request.Header.Set("x-tif-signature", signature)
  7926. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  7927. request.Header.Set("x-tif-nonce", nonce)
  7928. client := http.Client{}
  7929. resp, err := client.Do(request)
  7930. if err != nil {
  7931. fmt.Println(err.Error())
  7932. return err.Error(), ""
  7933. }
  7934. respBytes, err := ioutil.ReadAll(resp.Body)
  7935. if err != nil {
  7936. fmt.Println(err.Error())
  7937. return err.Error(), ""
  7938. }
  7939. str := string(respBytes)
  7940. fmt.Println(str)
  7941. return str, string(bytesData)
  7942. }
  7943. func Gzyb3510(struct3510 models.Struct3510, secret_key string) (string, string) {
  7944. // 生成签名
  7945. nonce := GetRandomString(32)
  7946. timestamp := time.Now().Unix()
  7947. signature := setSignature(timestamp, nonce, secret_key)
  7948. // 生成输入报文
  7949. //inputMessage := SetGdInputMessage(timestamp, struct3510.OrgName, struct3510.Opter, struct3510.FixmedinsCode, struct3510.InsuplcAdmdvs, struct3510.MdtrtareaAdmvs, struct3510.Cainfo)
  7950. sign := GetSignInInfo(struct3510.FixmedinsCode)
  7951. inputMessage := SetGZInputMessage(nonce, timestamp, struct3510.OrgName, struct3510.Opter, struct3510.FixmedinsCode, struct3510.InsuplcAdmdvs, struct3510.MdtrtareaAdmvs, sign)
  7952. input := make(map[string]interface{})
  7953. inputData := make(map[string]interface{})
  7954. inputMessage["infno"] = "3510"
  7955. inputData["fixmedins_code"] = struct3510.FixmedinsCode
  7956. //inputData["medins_list_codg"] = struct3510.MedinsListCodg
  7957. inputData["medins_list_codg"] = struct3510.MedListCodg
  7958. inputData["fixmedins_bchno"] = ""
  7959. inputData["begndate"] = struct3510.Begndate
  7960. inputData["enddate"] = struct3510.Enddate
  7961. inputData["medins_prod_inv_no"] = ""
  7962. inputData["medins_list_name"] = ""
  7963. inputData["rx_flag"] = ""
  7964. inputData["list_sp_item_flag"] = ""
  7965. inputData["trdn_flag"] = ""
  7966. inputData["invdate"] = ""
  7967. inputData["manu_lotnum"] = ""
  7968. inputData["manu_date"] = ""
  7969. inputData["expy_end"] = ""
  7970. inputData["memo"] = ""
  7971. inputData["vali_flag"] = ""
  7972. inputData["rid"] = ""
  7973. inputData["crter_id"] = ""
  7974. inputData["crter_name"] = ""
  7975. inputData["crte_optins_no"] = ""
  7976. inputData["opter_id"] = ""
  7977. inputData["opter_name"] = ""
  7978. inputData["optins_no"] = ""
  7979. inputData["poolarea_no"] = ""
  7980. inputData["fixmedins_bchno"] = ""
  7981. inputData["inv_data_type"] = ""
  7982. input["data"] = inputData
  7983. inputMessage["input"] = input //交易输入
  7984. bytesData, err := json.Marshal(inputMessage)
  7985. fmt.Println(string(bytesData))
  7986. if err != nil {
  7987. fmt.Println(err.Error())
  7988. return err.Error(), ""
  7989. }
  7990. reader := bytes.NewReader(bytesData)
  7991. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7992. gdyb_url := beego.AppConfig.String("gdyb_url")
  7993. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7994. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7995. url := gdyb_url + "3510"
  7996. request, err := http.NewRequest("POST", url, reader)
  7997. if err != nil {
  7998. fmt.Println(err.Error())
  7999. return err.Error(), ""
  8000. }
  8001. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  8002. request.Header.Set("x-tif-paasid", gdyb_paasid)
  8003. request.Header.Set("x-tif-signature", signature)
  8004. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  8005. request.Header.Set("x-tif-nonce", nonce)
  8006. client := http.Client{}
  8007. resp, err := client.Do(request)
  8008. if err != nil {
  8009. fmt.Println(err.Error())
  8010. return err.Error(), ""
  8011. }
  8012. respBytes, err := ioutil.ReadAll(resp.Body)
  8013. if err != nil {
  8014. fmt.Println(err.Error())
  8015. return err.Error(), ""
  8016. }
  8017. str := string(respBytes)
  8018. fmt.Println(str)
  8019. return str, string(bytesData)
  8020. }
  8021. func Gzyb3511(struct3511 models.Struct3511, secret_key string) (string, string) {
  8022. // 生成签名
  8023. nonce := GetRandomString(32)
  8024. timestamp := time.Now().Unix()
  8025. signature := setSignature(timestamp, nonce, secret_key)
  8026. // 生成输入报文
  8027. //inputMessage := SetGdInputMessage(timestamp, struct3511.OrgName, struct3511.Opter, struct3511.FixmedinsCode, struct3511.InsuplcAdmdvs, struct3511.MdtrtareaAdmvs, struct3511.Cainfo)
  8028. sign := GetSignInInfo(struct3511.FixmedinsCode)
  8029. inputMessage := SetGZInputMessage(nonce, timestamp, struct3511.OrgName, struct3511.Opter, struct3511.FixmedinsCode, struct3511.InsuplcAdmdvs, struct3511.MdtrtareaAdmvs, sign)
  8030. input := make(map[string]interface{})
  8031. inputData := make(map[string]interface{})
  8032. inputMessage["infno"] = "3511"
  8033. inputData["fixmedins_code"] = struct3511.FixmedinsCode
  8034. //inputData["medins_list_codg"] = struct3511.MedinsListCodg
  8035. inputData["medins_list_codg"] = struct3511.MedListCodg
  8036. inputData["fixmedins_bchno"] = ""
  8037. inputData["begndate"] = struct3511.Begndate
  8038. inputData["enddate"] = struct3511.Enddate
  8039. inputData["medins_prod_inv_no"] = ""
  8040. inputData["medins_list_name"] = ""
  8041. inputData["rx_flag"] = ""
  8042. inputData["list_sp_item_flag"] = ""
  8043. inputData["trdn_flag"] = ""
  8044. inputData["invdate"] = ""
  8045. inputData["manu_lotnum"] = ""
  8046. inputData["manu_date"] = ""
  8047. inputData["expy_end"] = ""
  8048. inputData["memo"] = ""
  8049. inputData["vali_flag"] = ""
  8050. inputData["rid"] = ""
  8051. inputData["crter_id"] = ""
  8052. inputData["crter_name"] = ""
  8053. inputData["crte_optins_no"] = ""
  8054. inputData["opter_id"] = ""
  8055. inputData["opter_name"] = ""
  8056. inputData["optins_no"] = ""
  8057. inputData["poolarea_no"] = ""
  8058. inputData["fixmedins_bchno"] = ""
  8059. inputData["inv_data_type"] = ""
  8060. input["data"] = inputData
  8061. inputMessage["input"] = input //交易输入
  8062. bytesData, err := json.Marshal(inputMessage)
  8063. fmt.Println(string(bytesData))
  8064. if err != nil {
  8065. fmt.Println(err.Error())
  8066. return err.Error(), ""
  8067. }
  8068. reader := bytes.NewReader(bytesData)
  8069. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  8070. gdyb_url := beego.AppConfig.String("gdyb_url")
  8071. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  8072. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  8073. url := gdyb_url + "3511"
  8074. request, err := http.NewRequest("POST", url, reader)
  8075. if err != nil {
  8076. fmt.Println(err.Error())
  8077. return err.Error(), ""
  8078. }
  8079. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  8080. request.Header.Set("x-tif-paasid", gdyb_paasid)
  8081. request.Header.Set("x-tif-signature", signature)
  8082. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  8083. request.Header.Set("x-tif-nonce", nonce)
  8084. client := http.Client{}
  8085. resp, err := client.Do(request)
  8086. if err != nil {
  8087. fmt.Println(err.Error())
  8088. return err.Error(), ""
  8089. }
  8090. respBytes, err := ioutil.ReadAll(resp.Body)
  8091. if err != nil {
  8092. fmt.Println(err.Error())
  8093. return err.Error(), ""
  8094. }
  8095. str := string(respBytes)
  8096. fmt.Println(str)
  8097. return str, string(bytesData)
  8098. }
  8099. func Gzyb3512(struct3512 models.Struct3512, secret_key string) (string, string) {
  8100. // 生成签名
  8101. nonce := GetRandomString(32)
  8102. timestamp := time.Now().Unix()
  8103. signature := setSignature(timestamp, nonce, secret_key)
  8104. // 生成输入报文
  8105. //inputMessage := SetGdInputMessage(timestamp, struct3512.OrgName, struct3512.Opter, struct3512.FixmedinsCode, struct3512.InsuplcAdmdvs, struct3512.MdtrtareaAdmvs, struct3512.Cainfo)
  8106. sign := GetSignInInfo(struct3512.FixmedinsCode)
  8107. inputMessage := SetGZInputMessage(nonce, timestamp, struct3512.OrgName, struct3512.Opter, struct3512.FixmedinsCode, struct3512.InsuplcAdmdvs, struct3512.MdtrtareaAdmvs, sign)
  8108. input := make(map[string]interface{})
  8109. inputData := make(map[string]interface{})
  8110. inputMessage["infno"] = "3512"
  8111. inputData["fixmedins_code"] = struct3512.FixmedinsCode
  8112. //inputData["medins_list_codg"] = struct3512.MedinsListCodg
  8113. inputData["medins_list_codg"] = struct3512.MedListCodg
  8114. inputData["fixmedins_bchno"] = ""
  8115. inputData["begndate"] = struct3512.Begndate
  8116. inputData["enddate"] = struct3512.Enddate
  8117. inputData["medins_prod_inv_no"] = ""
  8118. inputData["medins_list_name"] = ""
  8119. inputData["rx_flag"] = ""
  8120. inputData["list_sp_item_flag"] = ""
  8121. inputData["trdn_flag"] = ""
  8122. inputData["invdate"] = ""
  8123. inputData["manu_lotnum"] = ""
  8124. inputData["manu_date"] = ""
  8125. inputData["expy_end"] = ""
  8126. inputData["memo"] = ""
  8127. inputData["vali_flag"] = ""
  8128. inputData["rid"] = ""
  8129. inputData["crter_id"] = ""
  8130. inputData["crter_name"] = ""
  8131. inputData["crte_optins_no"] = ""
  8132. inputData["opter_id"] = ""
  8133. inputData["opter_name"] = ""
  8134. inputData["optins_no"] = ""
  8135. inputData["poolarea_no"] = ""
  8136. inputData["fixmedins_bchno"] = ""
  8137. inputData["inv_data_type"] = ""
  8138. input["data"] = inputData
  8139. inputMessage["input"] = input //交易输入
  8140. bytesData, err := json.Marshal(inputMessage)
  8141. fmt.Println(string(bytesData))
  8142. if err != nil {
  8143. fmt.Println(err.Error())
  8144. return err.Error(), ""
  8145. }
  8146. reader := bytes.NewReader(bytesData)
  8147. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  8148. gdyb_url := beego.AppConfig.String("gdyb_url")
  8149. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  8150. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  8151. url := gdyb_url + "3512"
  8152. request, err := http.NewRequest("POST", url, reader)
  8153. if err != nil {
  8154. fmt.Println(err.Error())
  8155. return err.Error(), ""
  8156. }
  8157. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  8158. request.Header.Set("x-tif-paasid", gdyb_paasid)
  8159. request.Header.Set("x-tif-signature", signature)
  8160. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  8161. request.Header.Set("x-tif-nonce", nonce)
  8162. client := http.Client{}
  8163. resp, err := client.Do(request)
  8164. if err != nil {
  8165. fmt.Println(err.Error())
  8166. return err.Error(), ""
  8167. }
  8168. respBytes, err := ioutil.ReadAll(resp.Body)
  8169. if err != nil {
  8170. fmt.Println(err.Error())
  8171. return err.Error(), ""
  8172. }
  8173. str := string(respBytes)
  8174. fmt.Println(str)
  8175. return str, string(bytesData)
  8176. }
  8177. func Gzyb3513(struct3513 models.Struct3513, secret_key string) (string, string) {
  8178. // 生成签名
  8179. nonce := GetRandomString(32)
  8180. timestamp := time.Now().Unix()
  8181. signature := setSignature(timestamp, nonce, secret_key)
  8182. // 生成输入报文
  8183. //inputMessage := SetGdInputMessage(timestamp, struct3513.OrgName, struct3513.Opter, struct3513.FixmedinsCode, struct3513.InsuplcAdmdvs, struct3513.MdtrtareaAdmvs, struct3513.Cainfo)
  8184. sign := GetSignInInfo(struct3513.FixmedinsCode)
  8185. inputMessage := SetGZInputMessage(nonce, timestamp, struct3513.OrgName, struct3513.Opter, struct3513.FixmedinsCode, struct3513.InsuplcAdmdvs, struct3513.MdtrtareaAdmvs, sign)
  8186. input := make(map[string]interface{})
  8187. inputData := make(map[string]interface{})
  8188. inputMessage["infno"] = "3513"
  8189. inputData["fixmedins_code"] = struct3513.FixmedinsCode
  8190. //inputData["medins_list_codg"] = struct3513.MedinsListCodg
  8191. inputData["medins_list_codg"] = struct3513.MedListCodg
  8192. inputData["fixmedins_bchno"] = ""
  8193. inputData["begndate"] = struct3513.Begndate
  8194. inputData["enddate"] = struct3513.Enddate
  8195. inputData["medins_prod_inv_no"] = ""
  8196. inputData["med_list_codg"] = ""
  8197. inputData["medins_list_name"] = ""
  8198. inputData["rx_flag"] = ""
  8199. inputData["list_sp_item_flag"] = ""
  8200. inputData["trdn_flag"] = ""
  8201. inputData["invdate"] = ""
  8202. inputData["manu_lotnum"] = ""
  8203. inputData["manu_date"] = ""
  8204. inputData["expy_end"] = ""
  8205. inputData["memo"] = ""
  8206. inputData["vali_flag"] = ""
  8207. inputData["rid"] = ""
  8208. inputData["crter_id"] = ""
  8209. inputData["crter_name"] = ""
  8210. inputData["crte_optins_no"] = ""
  8211. inputData["opter_id"] = ""
  8212. inputData["opter_name"] = ""
  8213. inputData["optins_no"] = ""
  8214. inputData["poolarea_no"] = ""
  8215. inputData["fixmedins_bchno"] = ""
  8216. inputData["inv_data_type"] = ""
  8217. input["data"] = inputData
  8218. inputMessage["input"] = input //交易输入
  8219. bytesData, err := json.Marshal(inputMessage)
  8220. fmt.Println(string(bytesData))
  8221. if err != nil {
  8222. fmt.Println(err.Error())
  8223. return err.Error(), ""
  8224. }
  8225. reader := bytes.NewReader(bytesData)
  8226. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  8227. gdyb_url := beego.AppConfig.String("gdyb_url")
  8228. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  8229. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  8230. url := gdyb_url + "3513"
  8231. request, err := http.NewRequest("POST", url, reader)
  8232. if err != nil {
  8233. fmt.Println(err.Error())
  8234. return err.Error(), ""
  8235. }
  8236. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  8237. request.Header.Set("x-tif-paasid", gdyb_paasid)
  8238. request.Header.Set("x-tif-signature", signature)
  8239. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  8240. request.Header.Set("x-tif-nonce", nonce)
  8241. client := http.Client{}
  8242. resp, err := client.Do(request)
  8243. if err != nil {
  8244. fmt.Println(err.Error())
  8245. return err.Error(), ""
  8246. }
  8247. respBytes, err := ioutil.ReadAll(resp.Body)
  8248. if err != nil {
  8249. fmt.Println(err.Error())
  8250. return err.Error(), ""
  8251. }
  8252. str := string(respBytes)
  8253. fmt.Println(str)
  8254. return str, string(bytesData)
  8255. }
  8256. // 生成基础报文
  8257. func SetGZInputMessage(nonce string, timestamp int64, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, sign string) map[string]interface{} {
  8258. // 生成签名
  8259. tempTime := time.Unix(timestamp, 0)
  8260. //timeFormat := tempTime.Format("20060102150405")
  8261. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  8262. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  8263. month := time.Unix(1557042972, 0).Format("1")
  8264. year := time.Now().Format("2006")
  8265. month = time.Now().Format("01")
  8266. day := time.Now().Format("02")
  8267. hour := time.Now().Format("15")
  8268. min := time.Now().Format("04")
  8269. sec := time.Now().Format("05")
  8270. msec := time.Now().Format("000")
  8271. // 生成输入报文
  8272. inputMessage := make(map[string]interface{})
  8273. inputMessage["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  8274. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  8275. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  8276. inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  8277. inputMessage["dev_no"] = "" // 设备编号
  8278. inputMessage["dev_safe_info"] = "" // 设备安全信息
  8279. inputMessage["cainfo"] = "" // 数字签名信息
  8280. inputMessage["signtype"] = "SM3" // 签名类型
  8281. inputMessage["infver"] = "V1.0" // 接收方系统代码
  8282. inputMessage["opter_type"] = "1" // 经办人类别
  8283. inputMessage["opter"] = doctor // 经办人
  8284. inputMessage["opter_name"] = doctor // 经办人姓名
  8285. inputMessage["inf_time"] = timeFormatOne // 交易时间
  8286. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  8287. inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  8288. inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号
  8289. //inputMessage["sign_no"] = "GZYBCS4101A20220202"
  8290. return inputMessage
  8291. }
  8292. func Gdyb3103(org_name string, opera string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, warm_type int64, ids string, dspo_way int64, desc string) (string, string) {
  8293. fmt.Println(opera)
  8294. // 生成签名
  8295. nonce := GetRandomString(32)
  8296. timestamp := time.Now().Unix()
  8297. signature := setSignature(timestamp, nonce, secret_key)
  8298. // 生成输入报文
  8299. inputMessage := SetInputMessagenosign(nonce, timestamp, org_name, opera, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  8300. input := make(map[string]interface{})
  8301. inputData := make(map[string]interface{})
  8302. inputMessage["infno"] = "3103" // 交易编码
  8303. inputData["warn_type"] = warm_type // 人员编号 (来自1101接口返回)
  8304. id_arr := strings.Split(ids, "~")
  8305. feedetail := make([]map[string]interface{}, 0)
  8306. for _, item := range id_arr {
  8307. feedetailInfo := make(map[string]interface{})
  8308. feedetailInfo["warn_rslt_id"] = item
  8309. feedetailInfo["dspo_way"] = dspo_way // 就诊 ID(来自2201接口返回)
  8310. feedetailInfo["dspo_way_rea"] = desc // 人员编号 (来自1101接口返回)
  8311. feedetail = append(feedetail, feedetailInfo)
  8312. }
  8313. inputData["warns"] = feedetail
  8314. input["data"] = inputData
  8315. inputMessage["input"] = input //交易输入
  8316. var requestLog string
  8317. bytesData, err := json.Marshal(inputMessage)
  8318. requestLog = string(bytesData)
  8319. fmt.Println(string(bytesData))
  8320. if err != nil {
  8321. fmt.Println(err.Error())
  8322. return err.Error(), ""
  8323. }
  8324. reader := bytes.NewReader(bytesData)
  8325. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2201"
  8326. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2201"
  8327. gdyb_url := beego.AppConfig.String("gdyb_url")
  8328. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  8329. var url string
  8330. url = gdyb_url + "3103"
  8331. {
  8332. request, err := http.NewRequest("POST", url, reader)
  8333. if err != nil {
  8334. fmt.Println(err.Error())
  8335. return err.Error(), ""
  8336. }
  8337. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  8338. request.Header.Set("x-tif-paasid", gdyb_paasid)
  8339. request.Header.Set("x-tif-signature", signature)
  8340. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  8341. request.Header.Set("x-tif-nonce", nonce)
  8342. client := http.Client{}
  8343. resp, err := client.Do(request)
  8344. if err != nil {
  8345. fmt.Println(err.Error())
  8346. return err.Error(), ""
  8347. }
  8348. respBytes, err := ioutil.ReadAll(resp.Body)
  8349. if err != nil {
  8350. fmt.Println(err.Error())
  8351. return err.Error(), ""
  8352. }
  8353. str := string(respBytes)
  8354. fmt.Println(str)
  8355. return str, requestLog
  8356. }
  8357. }