gdyb_service.go 373KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489
  1. package service
  2. import (
  3. "bytes"
  4. //"crypto/md5"
  5. "crypto/sha256"
  6. "encoding/hex"
  7. "encoding/json"
  8. "fmt"
  9. "gdyb/models"
  10. //"strings"
  11. //"gdyb/utils"
  12. "github.com/astaxie/beego"
  13. "github.com/axgle/mahonia"
  14. "io"
  15. "io/ioutil"
  16. "math/rand"
  17. "mime/multipart"
  18. "net"
  19. "net/http"
  20. "os"
  21. "os/exec"
  22. "path/filepath"
  23. "strconv"
  24. "syscall"
  25. "time"
  26. "unsafe"
  27. )
  28. const (
  29. SceretKey = "RhaDw4H0RUbWYyTxmRKM1eSeN0qyGLds" // secretKey 私钥
  30. )
  31. // 机构信息
  32. 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 {
  33. // 生成签名
  34. nonce := GetRandomString(32)
  35. timestamp := time.Now().Unix()
  36. signature := setSignature(timestamp, nonce, secret_key)
  37. // 生成输入报文
  38. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  39. input := make(map[string]interface{})
  40. inputData := make(map[string]interface{})
  41. inputMessage["infno"] = "1201" // 交易编码
  42. inputData["fixmedins_type"] = "1"
  43. inputData["fixmedins_name"] = org_name
  44. inputData["fixmedins_code"] = fixmedins_code
  45. input["medinsinfo"] = inputData
  46. inputMessage["input"] = input //交易输入
  47. bytesData, err := json.Marshal(inputMessage)
  48. fmt.Println(string(bytesData))
  49. if err != nil {
  50. fmt.Println(err.Error())
  51. return err.Error()
  52. }
  53. reader := bytes.NewReader(bytesData)
  54. gdyb_url := beego.AppConfig.String("gdyb_url")
  55. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  56. url := gdyb_url + "1201"
  57. request, err := http.NewRequest("POST", url, reader)
  58. if err != nil {
  59. fmt.Println(err.Error())
  60. return err.Error()
  61. }
  62. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  63. request.Header.Set("x-tif-paasid", gdyb_paasid)
  64. request.Header.Set("x-tif-signature", signature)
  65. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  66. request.Header.Set("x-tif-nonce", nonce)
  67. client := http.Client{}
  68. resp, err := client.Do(request)
  69. if err != nil {
  70. fmt.Println(err.Error())
  71. return err.Error()
  72. }
  73. respBytes, err := ioutil.ReadAll(resp.Body)
  74. if err != nil {
  75. fmt.Println(err.Error())
  76. return err.Error()
  77. }
  78. fmt.Println(string(respBytes))
  79. str2 := string(respBytes)
  80. return str2
  81. }
  82. // 人员基本信息
  83. 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) {
  84. //生成签名
  85. nonce := GetRandomString(32)
  86. timestamp := time.Now().Unix()
  87. signature := setSignature(timestamp, nonce, secret_key)
  88. //生成输入报文
  89. inputMessage := SetInputMessagenosign(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  90. input := make(map[string]interface{})
  91. inputData := make(map[string]interface{})
  92. inputMessage["infno"] = "1101" // 交易编码
  93. if certificates == "3" {
  94. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  95. inputData["certno"] = certNo // 证件号码
  96. inputData["psn_cert_type"] = "06" // 人员证件类型
  97. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  98. } else {
  99. if id_card_type == 1 {
  100. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  101. inputData["card_sn"] = card_sn // 卡识别码
  102. inputData["certno"] = certNo // 证件号码
  103. inputData["psn_cert_type"] = "" // 人员证件类型
  104. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  105. } else {
  106. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  107. inputData["card_sn"] = "" // 卡识别码
  108. inputData["certno"] = certNo // 证件号码
  109. inputData["psn_cert_type"] = "" // 人员证件类型
  110. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  111. }
  112. }
  113. inputData["begntime"] = "" // 开始时间
  114. inputData["psn_name"] = "" // 人员姓名
  115. input["data"] = inputData
  116. inputMessage["input"] = input //交易输入
  117. var inputLog string
  118. bytesData, err := json.Marshal(inputMessage)
  119. inputLog = string(bytesData)
  120. fmt.Println(string(bytesData))
  121. if err != nil {
  122. fmt.Println(err.Error())
  123. return err.Error(), ""
  124. }
  125. reader := bytes.NewReader(bytesData)
  126. gdyb_url := beego.AppConfig.String("gdyb_url")
  127. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  128. var url string
  129. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  130. url = gdyb_url
  131. } else {
  132. url = gdyb_url + "1101"
  133. }
  134. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  135. request, err := http.NewRequest("POST", url, reader)
  136. if err != nil {
  137. fmt.Println(err.Error())
  138. return err.Error(), ""
  139. }
  140. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  141. request.Header.Set("x-tif-paasid", gdyb_paasid)
  142. request.Header.Set("x-tif-signature", signature)
  143. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  144. request.Header.Set("x-tif-nonce", nonce)
  145. client := http.Client{}
  146. resp, err := client.Do(request)
  147. if err != nil {
  148. fmt.Println(err.Error())
  149. return err.Error(), ""
  150. }
  151. respBytes, err := ioutil.ReadAll(resp.Body)
  152. if err != nil {
  153. fmt.Println(err.Error())
  154. return err.Error(), ""
  155. }
  156. fmt.Println(string(respBytes))
  157. str := string(respBytes)
  158. return str, inputLog
  159. }
  160. func Gdyb1101A(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, name string) string {
  161. //生成签名
  162. nonce := GetRandomString(32)
  163. timestamp := time.Now().Unix()
  164. signature := setSignature(timestamp, nonce, secret_key)
  165. //生成输入报文
  166. inputMessage := SetInputMessagenosign(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  167. input := make(map[string]interface{})
  168. inputData := make(map[string]interface{})
  169. inputMessage["infno"] = "1101" // 交易编码
  170. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  171. inputData["card_sn"] = "" // 卡识别码
  172. inputData["certno"] = certNo // 证件号码
  173. inputData["psn_cert_type"] = "01" // 人员证件类型
  174. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  175. inputData["begntime"] = "" // 开始时间
  176. inputData["psn_name"] = name // 人员姓名
  177. input["data"] = inputData
  178. inputMessage["input"] = input //交易输入
  179. bytesData, err := json.Marshal(inputMessage)
  180. fmt.Println(string(bytesData))
  181. if err != nil {
  182. fmt.Println(err.Error())
  183. return err.Error()
  184. }
  185. reader := bytes.NewReader(bytesData)
  186. gdyb_url := beego.AppConfig.String("gdyb_url")
  187. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  188. var url string
  189. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  190. url = gdyb_url
  191. } else {
  192. url = gdyb_url + "1101"
  193. }
  194. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  195. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  196. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  197. if insuplc_admdvs == "421300" {
  198. var json2 string
  199. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101A", string(bytesData), json2)
  200. out, err := cmd.Output()
  201. if err != nil {
  202. fmt.Println("error:", err.Error())
  203. }
  204. fmt.Println(string(out))
  205. return hex.EncodeToString(out)
  206. } else {
  207. request, err := http.NewRequest("POST", url, reader)
  208. if err != nil {
  209. fmt.Println(err.Error())
  210. return err.Error()
  211. }
  212. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  213. request.Header.Set("x-tif-paasid", gdyb_paasid)
  214. request.Header.Set("x-tif-signature", signature)
  215. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  216. request.Header.Set("x-tif-nonce", nonce)
  217. client := http.Client{}
  218. resp, err := client.Do(request)
  219. if err != nil {
  220. fmt.Println(err.Error())
  221. return err.Error()
  222. }
  223. respBytes, err := ioutil.ReadAll(resp.Body)
  224. if err != nil {
  225. fmt.Println(err.Error())
  226. return err.Error()
  227. }
  228. fmt.Println(string(respBytes))
  229. str := string(respBytes)
  230. return str
  231. }
  232. }
  233. // 门诊挂号
  234. 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) {
  235. fmt.Println(opera)
  236. // 生成签名
  237. nonce := GetRandomString(32)
  238. timestamp := time.Now().Unix()
  239. signature := setSignature(timestamp, nonce, secret_key)
  240. tempTime := time.Unix(timestamp, 0)
  241. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  242. // 生成输入报文
  243. inputMessage := SetInputMessagenosign(nonce, timestamp, org_name, opera, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  244. input := make(map[string]interface{})
  245. inputData := make(map[string]interface{})
  246. inputMessage["infno"] = "2201" // 交易编码
  247. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  248. inputData["insutype"] = insutype // 险种类型(来自1101接口返回)
  249. inputData["begntime"] = timeFormatOne // 开始时间
  250. if id_card_type == 1 {
  251. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  252. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  253. } else {
  254. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  255. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  256. }
  257. inputData["ipt_otp_no"] = ipt_otp_no // 住院/门诊号
  258. inputData["atddr_no"] = doctor_id // 医师编码
  259. inputData["dr_name"] = doctor_name // 医师姓名
  260. inputData["dept_code"] = dept_code // 科室编码
  261. inputData["dept_name"] = dept // 科室名称
  262. inputData["caty"] = "A03.06" // 科别
  263. input["data"] = inputData
  264. inputMessage["input"] = input //交易输入
  265. var requestLog string
  266. bytesData, err := json.Marshal(inputMessage)
  267. requestLog = string(bytesData)
  268. fmt.Println(string(bytesData))
  269. if err != nil {
  270. fmt.Println(err.Error())
  271. return err.Error(), ""
  272. }
  273. reader := bytes.NewReader(bytesData)
  274. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2201"
  275. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2201"
  276. gdyb_url := beego.AppConfig.String("gdyb_url")
  277. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  278. var url string
  279. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  280. url = gdyb_url
  281. } else {
  282. url = gdyb_url + "2201"
  283. }
  284. if insuplc_admdvs == "421300" {
  285. var json2 string
  286. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2201", string(bytesData), json2)
  287. out, err := cmd.Output()
  288. if err != nil {
  289. fmt.Println("error:", err.Error())
  290. }
  291. fmt.Println(string(out))
  292. return hex.EncodeToString(out), requestLog
  293. } else {
  294. request, err := http.NewRequest("POST", url, reader)
  295. if err != nil {
  296. fmt.Println(err.Error())
  297. return err.Error(), ""
  298. }
  299. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  300. request.Header.Set("x-tif-paasid", gdyb_paasid)
  301. request.Header.Set("x-tif-signature", signature)
  302. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  303. request.Header.Set("x-tif-nonce", nonce)
  304. client := http.Client{}
  305. resp, err := client.Do(request)
  306. if err != nil {
  307. fmt.Println(err.Error())
  308. return err.Error(), ""
  309. }
  310. respBytes, err := ioutil.ReadAll(resp.Body)
  311. if err != nil {
  312. fmt.Println(err.Error())
  313. return err.Error(), ""
  314. }
  315. str := string(respBytes)
  316. fmt.Println(str)
  317. return str, requestLog
  318. }
  319. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2201"
  320. }
  321. 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) {
  322. fmt.Println(opera)
  323. // 生成签名
  324. nonce := GetRandomString(32)
  325. timestamp := time.Now().Unix()
  326. signature := setSignature(timestamp, nonce, secret_key)
  327. //tempTime := time.Unix(timestamp, 0)
  328. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  329. inputMessage := make(map[string]interface{})
  330. //tempTime := time.Unix(timestamp, 0)
  331. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  332. // 生成输入报文
  333. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  334. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, opera)
  335. } else {
  336. inputMessage = SetInputMessage(nonce, timestamp, org_name, opera, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  337. }
  338. // 生成输入报文
  339. //inputMessage := SetInputMessagenosign(nonce, timestamp, org_name, opera, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  340. input := make(map[string]interface{})
  341. inputData := make(map[string]interface{})
  342. inputMessage["infno"] = "2201" // 交易编码
  343. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  344. inputData["insutype"] = insutype // 险种类型(来自1101接口返回)
  345. inputData["begntime"] = record_time // 开始时间
  346. if id_card_type == 1 {
  347. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  348. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  349. } else if id_card_type == 4 {
  350. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  351. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  352. } else {
  353. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  354. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  355. }
  356. inputData["ipt_otp_no"] = ipt_otp_no // 住院/门诊号
  357. inputData["atddr_no"] = doctor_id // 医师编码
  358. inputData["dr_name"] = doctor_name // 医师姓名
  359. inputData["dept_code"] = dept_code // 科室编码
  360. inputData["dept_name"] = dept // 科室名称
  361. inputData["caty"] = "A03.06" // 科别
  362. input["data"] = inputData
  363. inputMessage["input"] = input //交易输入
  364. var requestLog string
  365. bytesData, err := json.Marshal(inputMessage)
  366. requestLog = string(bytesData)
  367. fmt.Println(string(bytesData))
  368. if err != nil {
  369. fmt.Println(err.Error())
  370. return err.Error(), ""
  371. }
  372. reader := bytes.NewReader(bytesData)
  373. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2201"
  374. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2201"
  375. gdyb_url := beego.AppConfig.String("gdyb_url")
  376. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  377. var url string
  378. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  379. url = gdyb_url
  380. } else {
  381. url = gdyb_url + "2201"
  382. }
  383. if insuplc_admdvs == "421300" {
  384. var json2 string
  385. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2201", string(bytesData), json2)
  386. out, err := cmd.Output()
  387. if err != nil {
  388. fmt.Println("error:", err.Error())
  389. }
  390. fmt.Println(string(out))
  391. return hex.EncodeToString(out), requestLog
  392. } else {
  393. fmt.Println(url)
  394. fmt.Println(gdyb_paasid)
  395. fmt.Println(secret_key)
  396. request, err := http.NewRequest("POST", url, reader)
  397. if err != nil {
  398. fmt.Println(err.Error())
  399. return err.Error(), ""
  400. }
  401. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  402. request.Header.Set("x-tif-paasid", gdyb_paasid)
  403. request.Header.Set("x-tif-signature", signature)
  404. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  405. request.Header.Set("x-tif-nonce", nonce)
  406. client := http.Client{}
  407. resp, err := client.Do(request)
  408. if err != nil {
  409. fmt.Println(err.Error())
  410. return err.Error(), ""
  411. }
  412. respBytes, err := ioutil.ReadAll(resp.Body)
  413. if err != nil {
  414. fmt.Println(err.Error())
  415. return err.Error(), ""
  416. }
  417. str := string(respBytes)
  418. fmt.Println(str)
  419. return str, requestLog
  420. }
  421. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2201"
  422. }
  423. // 门诊挂号撤销
  424. 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) {
  425. // 生成签名
  426. nonce := GetRandomString(32)
  427. timestamp := time.Now().Unix()
  428. signature := setSignature(timestamp, nonce, secret_key)
  429. // 生成输入报文
  430. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  431. inputMessage := make(map[string]interface{})
  432. //tempTime := time.Unix(timestamp, 0)
  433. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  434. // 生成输入报文
  435. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  436. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  437. } else {
  438. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  439. }
  440. input := make(map[string]interface{})
  441. inputData := make(map[string]interface{})
  442. inputMessage["infno"] = "2202" // 交易编码
  443. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  444. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  445. inputData["ipt_otp_no"] = ipt_otp_no // 住院/门诊号
  446. input["data"] = inputData
  447. inputMessage["input"] = input //交易输入
  448. var requestLog string
  449. bytesData, err := json.Marshal(inputMessage)
  450. fmt.Println(string(bytesData))
  451. requestLog = string(bytesData)
  452. if err != nil {
  453. fmt.Println(err.Error())
  454. return err.Error(), ""
  455. }
  456. reader := bytes.NewReader(bytesData)
  457. gdyb_url := beego.AppConfig.String("gdyb_url")
  458. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  459. var url string
  460. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  461. url = gdyb_url
  462. } else {
  463. url = gdyb_url + "2202"
  464. }
  465. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2202"
  466. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2202"
  467. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2202"
  468. if insuplc_admdvs == "421300" {
  469. var json2 string
  470. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2202", string(bytesData), json2)
  471. out, err := cmd.Output()
  472. if err != nil {
  473. fmt.Println("error:", err.Error())
  474. }
  475. fmt.Println(string(out))
  476. return hex.EncodeToString(out), requestLog
  477. } else {
  478. request, err := http.NewRequest("POST", url, reader)
  479. if err != nil {
  480. fmt.Println(err.Error())
  481. return err.Error(), ""
  482. }
  483. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  484. request.Header.Set("x-tif-paasid", gdyb_paasid)
  485. request.Header.Set("x-tif-signature", signature)
  486. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  487. request.Header.Set("x-tif-nonce", nonce)
  488. client := http.Client{}
  489. resp, err := client.Do(request)
  490. if err != nil {
  491. fmt.Println(err.Error())
  492. return err.Error(), ""
  493. }
  494. respBytes, err := ioutil.ReadAll(resp.Body)
  495. if err != nil {
  496. fmt.Println(err.Error())
  497. return err.Error(), ""
  498. }
  499. str := string(respBytes)
  500. fmt.Println(str)
  501. return str, requestLog
  502. }
  503. }
  504. // 门诊就诊信息上传
  505. 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) {
  506. // 生成签名
  507. nonce := GetRandomString(32)
  508. timestamp := time.Now().Unix()
  509. signature := setSignature(timestamp, nonce, secret_key)
  510. inputMessage := make(map[string]interface{})
  511. //tempTime := time.Unix(timestamp, 0)
  512. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  513. // 生成输入报文
  514. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  515. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, op_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, op_name)
  516. } else {
  517. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  518. }
  519. //inputMessage := SetInputMessage1111(nonce, timestamp, org_name, op_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs,op_name)
  520. input := make(map[string]interface{})
  521. inputData := make(map[string]interface{})
  522. diseinfo := make([]map[string]interface{}, 0)
  523. if med_type == "1111" || med_type == "1112" {
  524. med_type = "11"
  525. }
  526. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  527. inputMessage["infno"] = "2203" // 交易编码
  528. } else {
  529. inputMessage["infno"] = "2203" // 交易编码
  530. }
  531. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  532. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  533. inputData["med_type"] = med_type // 医疗类别 16门诊特殊病
  534. inputData["begntime"] = begin_time // 开始时间
  535. //inputData["begntime"] = // 开始时间
  536. inputData["main_cond_dscr"] = "" // 主要病情描述
  537. inputData["dise_codg"] = sick_code // 病种编码
  538. inputData["dise_name"] = sick_name // 病种名称
  539. if med_type == "12" {
  540. inputData["dise_codg"] = "" // 病种编码
  541. inputData["dise_name"] = "" // 病种名称
  542. }
  543. inputData["birctrl_type"] = "" // 计划生育手术类别
  544. inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
  545. for index, item := range config {
  546. diseinfo_sun := make(map[string]interface{})
  547. diseinfo_sun["diag_type"] = "1" // 诊断类别
  548. diseinfo_sun["diag_srt_no"] = index + 1 // 诊断排序号
  549. diseinfo_sun["diag_code"] = item.CountryCode // 诊断代码
  550. diseinfo_sun["diag_name"] = item.ClassName // 诊断名称
  551. diseinfo_sun["diag_dept"] = department // 诊断科室
  552. diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
  553. diseinfo_sun["dise_dor_name"] = doctor_name // 诊断医生姓名
  554. diseinfo_sun["diag_time"] = begin_time // 诊断时间
  555. diseinfo_sun["vali_flag"] = "1" // 有效标志
  556. diseinfo = append(diseinfo, diseinfo_sun)
  557. }
  558. input["diseinfo"] = diseinfo
  559. input["mdtrtinfo"] = inputData
  560. inputMessage["input"] = input //交易输入
  561. var requestLog string
  562. bytesData, err := json.Marshal(inputMessage)
  563. fmt.Println(string(bytesData))
  564. requestLog = string(bytesData)
  565. if err != nil {
  566. fmt.Println(err.Error())
  567. return err.Error(), ""
  568. }
  569. reader := bytes.NewReader(bytesData)
  570. gdyb_url := beego.AppConfig.String("gdyb_url")
  571. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  572. var url string
  573. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  574. url = gdyb_url
  575. } else {
  576. url = gdyb_url + "2203"
  577. }
  578. if insuplc_admdvs == "421300" {
  579. var json2 string
  580. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2203", string(bytesData), json2)
  581. out, err := cmd.Output()
  582. if err != nil {
  583. fmt.Println("error:", err.Error())
  584. }
  585. fmt.Println(string(out))
  586. return hex.EncodeToString(out), requestLog
  587. } else {
  588. request, err := http.NewRequest("POST", url, reader)
  589. if err != nil {
  590. fmt.Println(err.Error())
  591. return err.Error(), ""
  592. }
  593. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  594. request.Header.Set("x-tif-paasid", gdyb_paasid)
  595. request.Header.Set("x-tif-signature", signature)
  596. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  597. request.Header.Set("x-tif-nonce", nonce)
  598. client := http.Client{}
  599. resp, err := client.Do(request)
  600. if err != nil {
  601. fmt.Println(err.Error())
  602. return err.Error(), ""
  603. }
  604. respBytes, err := ioutil.ReadAll(resp.Body)
  605. if err != nil {
  606. fmt.Println(err.Error())
  607. return err.Error(), ""
  608. }
  609. str := string(respBytes)
  610. fmt.Println(str)
  611. return str, requestLog
  612. }
  613. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2203"
  614. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  615. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  616. }
  617. 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) {
  618. // 生成签名
  619. nonce := GetRandomString(32)
  620. timestamp := time.Now().Unix()
  621. signature := setSignature(timestamp, nonce, secret_key)
  622. //tempTime := time.Unix(timestamp, 0)
  623. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  624. // 生成输入报文
  625. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  626. input := make(map[string]interface{})
  627. inputData := make(map[string]interface{})
  628. diseinfo := make([]map[string]interface{}, 0)
  629. if med_type == "1111" || med_type == "1112" {
  630. med_type = "11"
  631. }
  632. inputMessage["infno"] = "2203" // 交易编码
  633. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  634. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  635. inputData["med_type"] = med_type // 医疗类别 16门诊特殊病
  636. inputData["begntime"] = begin_time // 开始时间
  637. //inputData["begntime"] = // 开始时间
  638. inputData["main_cond_dscr"] = "" // 主要病情描述
  639. inputData["dise_codg"] = sick_code // 病种编码
  640. inputData["dise_name"] = sick_name // 病种名称
  641. if med_type == "12" {
  642. inputData["dise_codg"] = "" // 病种编码
  643. inputData["dise_name"] = "" // 病种名称
  644. }
  645. inputData["birctrl_type"] = "" // 计划生育手术类别
  646. inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
  647. for index, item := range config {
  648. diseinfo_sun := make(map[string]interface{})
  649. diseinfo_sun["diag_type"] = "1" // 诊断类别
  650. diseinfo_sun["diag_srt_no"] = index // 诊断排序号
  651. diseinfo_sun["diag_code"] = item.CountryCode // 诊断代码
  652. diseinfo_sun["diag_name"] = item.ClassName // 诊断名称
  653. diseinfo_sun["diag_dept"] = department // 诊断科室
  654. diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
  655. diseinfo_sun["dise_dor_name"] = doctor_name // 诊断医生姓名
  656. diseinfo_sun["diag_time"] = begin_time // 诊断时间
  657. diseinfo_sun["vali_flag"] = "1" // 有效标志
  658. diseinfo = append(diseinfo, diseinfo_sun)
  659. }
  660. input["diseinfo"] = diseinfo
  661. input["mdtrtinfo"] = inputData
  662. inputMessage["input"] = input //交易输入
  663. var requestLog string
  664. bytesData, err := json.Marshal(inputMessage)
  665. fmt.Println(string(bytesData))
  666. requestLog = string(bytesData)
  667. if err != nil {
  668. fmt.Println(err.Error())
  669. return err.Error(), ""
  670. }
  671. reader := bytes.NewReader(bytesData)
  672. gdyb_url := beego.AppConfig.String("gdyb_url")
  673. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  674. var url string
  675. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  676. url = gdyb_url
  677. } else {
  678. url = gdyb_url + "2203"
  679. }
  680. if insuplc_admdvs == "421300" {
  681. var json2 string
  682. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2203", string(bytesData), json2)
  683. out, err := cmd.Output()
  684. if err != nil {
  685. fmt.Println("error:", err.Error())
  686. }
  687. fmt.Println(string(out))
  688. return hex.EncodeToString(out), requestLog
  689. } else {
  690. request, err := http.NewRequest("POST", url, reader)
  691. if err != nil {
  692. fmt.Println(err.Error())
  693. return err.Error(), ""
  694. }
  695. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  696. request.Header.Set("x-tif-paasid", gdyb_paasid)
  697. request.Header.Set("x-tif-signature", signature)
  698. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  699. request.Header.Set("x-tif-nonce", nonce)
  700. client := http.Client{}
  701. resp, err := client.Do(request)
  702. if err != nil {
  703. fmt.Println(err.Error())
  704. return err.Error(), ""
  705. }
  706. respBytes, err := ioutil.ReadAll(resp.Body)
  707. if err != nil {
  708. fmt.Println(err.Error())
  709. return err.Error(), ""
  710. }
  711. str := string(respBytes)
  712. fmt.Println(str)
  713. return str, requestLog
  714. }
  715. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2203"
  716. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  717. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  718. }
  719. // 门诊就诊信息上传
  720. 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) {
  721. // 生成签名
  722. nonce := GetRandomString(32)
  723. timestamp := time.Now().Unix()
  724. signature := setSignature(timestamp, nonce, secret_key)
  725. tempTime := time.Unix(timestamp, 0)
  726. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  727. // 生成输入报文
  728. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  729. input := make(map[string]interface{})
  730. inputData := make(map[string]interface{})
  731. diseinfo := make([]map[string]interface{}, 0)
  732. if med_type == "1111" || med_type == "1112" {
  733. med_type = "11"
  734. }
  735. inputMessage["infno"] = "2203A" // 交易编码
  736. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  737. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  738. inputData["med_type"] = med_type // 医疗类别 16门诊特殊病
  739. inputData["begntime"] = begin_time // 开始时间
  740. inputData["main_cond_dscr"] = "" // 主要病情描述
  741. inputData["dise_codg"] = sick_code // 病种编码
  742. inputData["dise_name"] = sick_name // 病种名称
  743. inputData["birctrl_type"] = "" // 计划生育手术类别
  744. inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
  745. inputData["matn_type"] = "" // 生育类别
  746. inputData["geso_val"] = "" // 孕周数
  747. for index, item := range config {
  748. diseinfo_sun := make(map[string]interface{})
  749. diseinfo_sun["diag_type"] = "1" // 诊断类别
  750. diseinfo_sun["diag_srt_no"] = index // 诊断排序号
  751. diseinfo_sun["diag_code"] = item.CountryCode // 诊断代码
  752. diseinfo_sun["diag_name"] = item.ClassName // 诊断名称
  753. diseinfo_sun["diag_dept"] = department // 诊断科室
  754. diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
  755. diseinfo_sun["dise_dor_name"] = doctor // 诊断医生姓名
  756. diseinfo_sun["diag_time"] = timeFormatOne // 诊断时间
  757. diseinfo_sun["vali_flag"] = "1" // 有效标志
  758. diseinfo = append(diseinfo, diseinfo_sun)
  759. }
  760. input["diseinfo"] = diseinfo
  761. input["mdtrtinfo"] = inputData
  762. inputMessage["input"] = input //交易输入
  763. var requestLog string
  764. bytesData, err := json.Marshal(inputMessage)
  765. fmt.Println(string(bytesData))
  766. requestLog = string(bytesData)
  767. if err != nil {
  768. fmt.Println(err.Error())
  769. return err.Error(), ""
  770. }
  771. reader := bytes.NewReader(bytesData)
  772. gdyb_url := beego.AppConfig.String("gdyb_url")
  773. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  774. var url string
  775. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  776. url = gdyb_url
  777. } else {
  778. url = gdyb_url + "2203"
  779. }
  780. if insuplc_admdvs == "421300" {
  781. var json2 string
  782. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2203A", string(bytesData), json2)
  783. out, err := cmd.Output()
  784. if err != nil {
  785. fmt.Println("error:", err.Error())
  786. }
  787. fmt.Println(string(out))
  788. return hex.EncodeToString(out), requestLog
  789. } else {
  790. request, err := http.NewRequest("POST", url, reader)
  791. if err != nil {
  792. fmt.Println(err.Error())
  793. return err.Error(), ""
  794. }
  795. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  796. request.Header.Set("x-tif-paasid", gdyb_paasid)
  797. request.Header.Set("x-tif-signature", signature)
  798. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  799. request.Header.Set("x-tif-nonce", nonce)
  800. client := http.Client{}
  801. resp, err := client.Do(request)
  802. if err != nil {
  803. fmt.Println(err.Error())
  804. return err.Error(), ""
  805. }
  806. respBytes, err := ioutil.ReadAll(resp.Body)
  807. if err != nil {
  808. fmt.Println(err.Error())
  809. return err.Error(), ""
  810. }
  811. str := string(respBytes)
  812. fmt.Println(str)
  813. return str, requestLog
  814. }
  815. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2203A"
  816. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  817. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  818. }
  819. 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) {
  820. // 生成签名
  821. nonce := GetRandomString(32)
  822. timestamp := time.Now().Unix()
  823. signature := setSignature(timestamp, nonce, secret_key)
  824. tempTime := time.Unix(timestamp, 0)
  825. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  826. // 生成输入报文
  827. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  828. input := make(map[string]interface{})
  829. inputData := make(map[string]interface{})
  830. diseinfo := make([]map[string]interface{}, 0)
  831. inputMessage["infno"] = "2203" // 交易编码
  832. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  833. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  834. inputData["med_type"] = "14" // 医疗类别 16门诊特殊病
  835. inputData["begntime"] = begin_time // 开始时间
  836. inputData["main_cond_dscr"] = "" // 主要病情描述
  837. inputData["dise_codg"] = sick_code // 病种编码
  838. inputData["dise_name"] = sick_name // 病种名称
  839. inputData["birctrl_type"] = "" // 计划生育手术类别
  840. inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
  841. inputData["matn_type"] = "" // 生育类别
  842. inputData["geso_val"] = "" // 孕周数
  843. for index, item := range config {
  844. diseinfo_sun := make(map[string]interface{})
  845. diseinfo_sun["diag_type"] = "1" // 诊断类别
  846. diseinfo_sun["diag_srt_no"] = index // 诊断排序号
  847. diseinfo_sun["diag_code"] = item.CountryCode // 诊断代码
  848. diseinfo_sun["diag_name"] = item.ClassName // 诊断名称
  849. diseinfo_sun["diag_dept"] = department // 诊断科室
  850. diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
  851. diseinfo_sun["dise_dor_name"] = doctor // 诊断医生姓名
  852. diseinfo_sun["diag_time"] = timeFormatOne // 诊断时间
  853. diseinfo_sun["vali_flag"] = "1" // 有效标志
  854. diseinfo = append(diseinfo, diseinfo_sun)
  855. }
  856. input["diseinfo"] = diseinfo
  857. input["mdtrtinfo"] = inputData
  858. inputMessage["input"] = input //交易输入
  859. var requestLog string
  860. bytesData, err := json.Marshal(inputMessage)
  861. fmt.Println(string(bytesData))
  862. requestLog = string(bytesData)
  863. if err != nil {
  864. fmt.Println(err.Error())
  865. return err.Error(), ""
  866. }
  867. reader := bytes.NewReader(bytesData)
  868. gdyb_url := beego.AppConfig.String("gdyb_url")
  869. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  870. var url string
  871. url = gdyb_url + "2203"
  872. if insuplc_admdvs == "421300" {
  873. var json2 string
  874. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2203A", string(bytesData), json2)
  875. out, err := cmd.Output()
  876. if err != nil {
  877. fmt.Println("error:", err.Error())
  878. }
  879. fmt.Println(string(out))
  880. return hex.EncodeToString(out), requestLog
  881. } else {
  882. request, err := http.NewRequest("POST", url, reader)
  883. if err != nil {
  884. fmt.Println(err.Error())
  885. return err.Error(), ""
  886. }
  887. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  888. request.Header.Set("x-tif-paasid", gdyb_paasid)
  889. request.Header.Set("x-tif-signature", signature)
  890. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  891. request.Header.Set("x-tif-nonce", nonce)
  892. client := http.Client{}
  893. resp, err := client.Do(request)
  894. if err != nil {
  895. fmt.Println(err.Error())
  896. return err.Error(), ""
  897. }
  898. respBytes, err := ioutil.ReadAll(resp.Body)
  899. if err != nil {
  900. fmt.Println(err.Error())
  901. return err.Error(), ""
  902. }
  903. str := string(respBytes)
  904. fmt.Println(str)
  905. return str, requestLog
  906. }
  907. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2203A"
  908. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  909. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  910. }
  911. type Custom struct {
  912. DetItemFeeSumamt string
  913. Cut string
  914. FeedetlSn string
  915. Price string
  916. MedListCodg string
  917. LmtUsedFlag int64
  918. HospApprFlag int64
  919. DoctorNumber string
  920. DoctorName string
  921. ProvinceDrugMedListCodg string
  922. ProvinceGoodMedListCodg string
  923. IsUser int64
  924. FeeOcurTime string
  925. Unit string
  926. }
  927. type RequestResult struct {
  928. Output Output `json:"output" form:"output"`
  929. Infcode int64 `gorm:"column:infcode" json:"infcode" form:"infcode"`
  930. WarnMsg string `gorm:"column:warn_msg" json:"warn_msg" form:"warn_msg"`
  931. Cainfo string `gorm:"column:cainfo" json:"cainfo" form:"cainfo"`
  932. ErrMsg string `gorm:"column:err_msg" json:"err_msg" form:"err_msg"`
  933. RespondTime string `gorm:"column:respond_time" json:"respond_time" form:"respond_time"`
  934. InfRefmsgid string `gorm:"column:inf_refmsgid" json:"inf_refmsgid" form:"inf_refmsgid"`
  935. }
  936. type Output struct {
  937. Result Result `json:"result" form:"result"`
  938. }
  939. type Result struct {
  940. BasMednFlag string `json:"bas_medn_flag" form:"bas_medn_flag"`
  941. MedChrgitmType string `json:"med_chrgitm_type" form:"med_chrgitm_type"`
  942. DetItemFeeSumamt int64 `json:"det_item_fee_sumamt" form:"det_item_fee_sumamt"`
  943. HiNegoDrugFlag string `json:"hi_nego_drug_flag" form:"hi_nego_drug_flag"`
  944. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
  945. FeedtlSn int64 `json:"feedtl_sn" form:"feedtl_sn"`
  946. UploadDate int64 `json:"upload_date" form:"upload_date"`
  947. AdviceId int64 `json:"advice_id" form:"advice_id"`
  948. Cnt int64 `json:"cnt" form:"cnt"`
  949. Pric float64 `json:"pric" form:"pric"`
  950. PatientId int64 `json:"patient_id" form:"patient_id"`
  951. PricUplmtAmt float64 `json:"pric_uplmt_amt" form:"pric_uplmt_amt"`
  952. SelfpayProp float64 `json:"selfpay_prop" form:"selfpay_prop"`
  953. OverlmtAmt float64 `json:"overlmt_amt" form:"overlmt_amt"`
  954. PreselfpayAmt float64 `json:"preselfpay_amt" form:"preselfpay_amt"`
  955. Status int64 `json:"status" form:"status"`
  956. Memo string `json:"memo" form:"memo"`
  957. FeedetlSn string `json:"feedetl_sn" form:"feedetl_sn"`
  958. Mtime int64 `json:"mtime" form:"mtime"`
  959. InscpScpAmt float64 `json:"inscp_scp_amt" form:"inscp_scp_amt"`
  960. DrtReimFlag string `json:"drt_reim_flag" form:"drt_reim_flag"`
  961. Ctime int64 `json:"ctime" form:"ctime"`
  962. ListSpItemFlag string `json:"list_sp_item_flag" form:"list_sp_item_flag"`
  963. ChldMedcFlag string `json:"chld_medc_flag" form:"chld_medc_flag"`
  964. LmtUsedFlag string `json:"lmt_used_flag" form:"lmt_used_flag"`
  965. ChrgitmLv string `json:"chrgitm_lv" form:"chrgitm_lv"`
  966. UserOrgId int64 `json:"user_org_id" form:"user_org_id"`
  967. HisPatientId int64 `json:"his_patient_id" form:"his_patient_id"`
  968. OrderId int64 `json:"order_id" form:"order_id"`
  969. }
  970. // 门诊费用明细信息上传
  971. 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) {
  972. // 生成签名
  973. nonce := GetRandomString(32)
  974. timestamp := time.Now().Unix()
  975. signature := setSignature(timestamp, nonce, secret_key)
  976. //tempTime := time.Unix(timestamp, 0)
  977. //timeFormat := tempTime.Format("20060102150405")
  978. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  979. //chrgBchno := rand.Intn(100000) + 10000
  980. var customs []*Custom
  981. inputMessage := make(map[string]interface{})
  982. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  983. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  984. } else {
  985. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  986. }
  987. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  988. for _, item := range hisPrescription {
  989. role, _ := GetAdminUserInfoByID(item.UserOrgId, new_doctor_id)
  990. tm := time.Unix(item.PreTime, 0)
  991. if item.Type == 1 { //药品
  992. for _, subItem := range item.HisDoctorAdviceInfo {
  993. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 && subItem.BaseDrugLib.IsUser != 1 {
  994. //var randNum int
  995. //randNum = rand.Intn(10000) + 1000
  996. role, _ := GetAdminUserInfoByID(item.UserOrgId, new_doctor_id)
  997. cus := &Custom{
  998. DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  999. Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  1000. FeedetlSn: subItem.FeedetlSn,
  1001. Price: fmt.Sprintf("%.2f", subItem.Price),
  1002. MedListCodg: subItem.BaseDrugLib.MedicalInsuranceNumber,
  1003. HospApprFlag: subItem.HospApprFlag,
  1004. DoctorNumber: role.DoctorNumber,
  1005. DoctorName: role.UserName,
  1006. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  1007. }
  1008. customs = append(customs, cus)
  1009. }
  1010. }
  1011. }
  1012. if item.Type == 2 { //项目
  1013. for _, subItem := range item.HisPrescriptionProject {
  1014. //var randNum int
  1015. //randNum = rand.Intn(10000) + 1000
  1016. if subItem.Type == 2 {
  1017. if len(subItem.HisProject.MedicalCode) > 0 {
  1018. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1019. cus := &Custom{
  1020. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  1021. Cut: fmt.Sprintf("%.4f", cnt),
  1022. FeedetlSn: subItem.FeedetlSn,
  1023. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  1024. MedListCodg: subItem.HisProject.MedicalCode,
  1025. DoctorNumber: role.DoctorNumber,
  1026. DoctorName: role.UserName,
  1027. HospApprFlag: -1,
  1028. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  1029. }
  1030. customs = append(customs, cus)
  1031. }
  1032. } else if subItem.Type == 3 {
  1033. if len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  1034. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1035. cus := &Custom{
  1036. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  1037. Cut: fmt.Sprintf("%.4f", cnt),
  1038. FeedetlSn: subItem.FeedetlSn,
  1039. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  1040. MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
  1041. HospApprFlag: -1,
  1042. DoctorNumber: role.DoctorNumber,
  1043. DoctorName: role.UserName,
  1044. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  1045. }
  1046. customs = append(customs, cus)
  1047. }
  1048. }
  1049. }
  1050. }
  1051. for _, subItem := range item.HisAdditionalCharge {
  1052. if len(subItem.XtHisAddtionConfig.Code) > 0 {
  1053. cus := &Custom{
  1054. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*float64(subItem.Count)),
  1055. Cut: fmt.Sprintf("%.4f", float64(subItem.Count)),
  1056. FeedetlSn: subItem.FeedetlSn,
  1057. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  1058. MedListCodg: subItem.XtHisAddtionConfig.Code,
  1059. HospApprFlag: -1,
  1060. DoctorNumber: role.DoctorNumber,
  1061. DoctorName: role.UserName,
  1062. }
  1063. customs = append(customs, cus)
  1064. }
  1065. }
  1066. }
  1067. // 生成输入报文
  1068. input := make(map[string]interface{})
  1069. feedetail := make([]map[string]interface{}, 0)
  1070. inputMessage["infno"] = "2204" // 交易编码
  1071. //chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  1072. for _, item := range customs {
  1073. feedetailInfo := make(map[string]interface{})
  1074. feedetailInfo["feedetl_sn"] = item.FeedetlSn
  1075. feedetailInfo["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1076. feedetailInfo["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1077. feedetailInfo["chrg_bchno"] = chrg_bchno // 收费批次号
  1078. feedetailInfo["dise_codg"] = diag_code // 病种编码
  1079. feedetailInfo["rxno"] = "" // 处方号
  1080. feedetailInfo["rx_circ_flag"] = "0" // 外购处方标志
  1081. feedetailInfo["fee_ocur_time"] = item.FeeOcurTime // 费用发生时间
  1082. feedetailInfo["med_list_codg"] = item.MedListCodg // 医疗目录编码
  1083. feedetailInfo["medins_list_codg"] = item.MedListCodg // 医药机构目录编码
  1084. feedetailInfo["det_item_fee_sumamt"] = item.DetItemFeeSumamt // 明细项目费用总额
  1085. feedetailInfo["cnt"] = item.Cut // 数量
  1086. feedetailInfo["pric"] = item.Price // 单价
  1087. feedetailInfo["sin_dos_dscr"] = "1" // 单次剂量描述
  1088. feedetailInfo["used_frqu_dscr"] = "" // 使用频次描述
  1089. feedetailInfo["prd_days"] = "0" // 周期天数
  1090. feedetailInfo["medc_way_dscr"] = "" // 用药途径描述
  1091. feedetailInfo["bilg_dept_codg"] = dept_code // 开单科室编码
  1092. feedetailInfo["bilg_dept_name"] = dept // 开单科室名称
  1093. feedetailInfo["bilg_dr_codg"] = item.DoctorNumber // 开单医生编码
  1094. feedetailInfo["bilg_dr_name"] = item.DoctorName // 开单医师姓名
  1095. feedetailInfo["acord_dept_codg"] = "" // 受单科室编码
  1096. feedetailInfo["acord_dept_name"] = "" // 受单科室名称
  1097. feedetailInfo["orders_dr_code"] = item.DoctorNumber // 受单医生编码
  1098. feedetailInfo["orders_dr_name"] = item.DoctorName // 受单医生姓名
  1099. if balance_accounts_type == "8" {
  1100. feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
  1101. } else {
  1102. if item.HospApprFlag != -1 {
  1103. if item.HospApprFlag == 1 {
  1104. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  1105. } else if item.HospApprFlag == 2 {
  1106. feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
  1107. } else if item.HospApprFlag == 3 {
  1108. feedetailInfo["hosp_appr_flag"] = "0" // 医院审批标志
  1109. } else {
  1110. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  1111. }
  1112. } else {
  1113. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  1114. }
  1115. }
  1116. //feedetailInfo["tcmdrug_used_way"] = "" // 中药使用方式
  1117. feedetailInfo["etip_flag"] = "0" // 外检标志
  1118. feedetailInfo["etip_hosp_code"] = "" // 外检医院编码
  1119. feedetailInfo["dscg_tkdrug_flag"] = "" // 出院带药标志
  1120. feedetailInfo["matn_fee_flag"] = "" // 生育费用标志
  1121. feedetail = append(feedetail, feedetailInfo)
  1122. }
  1123. input["feedetail"] = feedetail
  1124. inputMessage["input"] = input //交易输入
  1125. var requestLog string
  1126. bytesData, err := json.Marshal(inputMessage)
  1127. fmt.Println("----------")
  1128. fmt.Println(string(bytesData))
  1129. fmt.Println("----------")
  1130. requestLog = string(bytesData)
  1131. if err != nil {
  1132. fmt.Println(err.Error())
  1133. return "", ""
  1134. }
  1135. reader := bytes.NewReader(bytesData)
  1136. gdyb_url := beego.AppConfig.String("gdyb_url")
  1137. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1138. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1139. var url string
  1140. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  1141. url = gdyb_url
  1142. } else {
  1143. url = gdyb_url + "2204"
  1144. }
  1145. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2204"
  1146. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2204"
  1147. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2204"
  1148. if insuplc_admdvs == "421300" {
  1149. var json2 string
  1150. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2204", string(bytesData), json2)
  1151. out, err := cmd.Output()
  1152. if err != nil {
  1153. fmt.Println("error:", err.Error())
  1154. }
  1155. fmt.Println(string(out))
  1156. return hex.EncodeToString(out), requestLog
  1157. } else {
  1158. request, err := http.NewRequest("POST", url, reader)
  1159. if err != nil {
  1160. fmt.Println(err.Error())
  1161. return "", ""
  1162. }
  1163. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1164. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1165. request.Header.Set("x-tif-signature", signature)
  1166. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1167. request.Header.Set("x-tif-nonce", nonce)
  1168. client := http.Client{}
  1169. resp, err := client.Do(request)
  1170. if err != nil {
  1171. fmt.Println(err.Error())
  1172. return "", ""
  1173. }
  1174. respBytes, err := ioutil.ReadAll(resp.Body)
  1175. if err != nil {
  1176. fmt.Println(err.Error())
  1177. return "", ""
  1178. }
  1179. return string(respBytes), requestLog
  1180. }
  1181. //var result RequestResult
  1182. //json.Unmarshal(respBytes, &result)
  1183. //return &result
  1184. }
  1185. 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) {
  1186. // 生成签名
  1187. nonce := GetRandomString(32)
  1188. timestamp := time.Now().Unix()
  1189. signature := setSignature(timestamp, nonce, secret_key)
  1190. //tempTime := time.Unix(timestamp, 0)
  1191. //timeFormat := tempTime.Format("20060102150405")
  1192. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  1193. //chrgBchno := rand.Intn(100000) + 10000
  1194. var customs []*Custom
  1195. for _, item := range hisPrescription {
  1196. tm := time.Unix(item.PreTime, 0)
  1197. if item.Type == 1 { //药品
  1198. for _, subItem := range item.HisDoctorAdviceInfo {
  1199. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 && subItem.BaseDrugLib.IsUser != 1 {
  1200. //var randNum int
  1201. //randNum = rand.Intn(10000) + 1000
  1202. cus := &Custom{
  1203. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber),
  1204. Cut: fmt.Sprintf("%.4f", subItem.PrescribingNumber),
  1205. FeedetlSn: subItem.FeedetlSn,
  1206. Price: fmt.Sprintf("%.4f", subItem.Price),
  1207. MedListCodg: subItem.BaseDrugLib.MedicalInsuranceNumber,
  1208. HospApprFlag: subItem.HospApprFlag,
  1209. DoctorNumber: new_doctor_id,
  1210. DoctorName: new_doctor_name,
  1211. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  1212. }
  1213. customs = append(customs, cus)
  1214. }
  1215. }
  1216. }
  1217. if item.Type == 2 { //项目
  1218. for _, subItem := range item.HisPrescriptionProject {
  1219. //var randNum int
  1220. //randNum = rand.Intn(10000) + 1000
  1221. if subItem.Type == 2 {
  1222. if len(subItem.HisProject.MedicalCode) > 0 {
  1223. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1224. cus := &Custom{
  1225. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  1226. Cut: fmt.Sprintf("%.4f", cnt),
  1227. FeedetlSn: subItem.FeedetlSn,
  1228. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  1229. MedListCodg: subItem.HisProject.MedicalCode,
  1230. DoctorNumber: new_doctor_id,
  1231. DoctorName: new_doctor_name,
  1232. HospApprFlag: -1,
  1233. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  1234. }
  1235. customs = append(customs, cus)
  1236. }
  1237. } else if subItem.Type == 3 {
  1238. if len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  1239. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1240. cus := &Custom{
  1241. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  1242. Cut: fmt.Sprintf("%.4f", cnt),
  1243. FeedetlSn: subItem.FeedetlSn,
  1244. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  1245. MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
  1246. HospApprFlag: -1,
  1247. DoctorNumber: new_doctor_id,
  1248. DoctorName: new_doctor_name,
  1249. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  1250. }
  1251. customs = append(customs, cus)
  1252. }
  1253. }
  1254. }
  1255. }
  1256. for _, subItem := range item.HisAdditionalCharge {
  1257. if len(subItem.XtHisAddtionConfig.Code) > 0 {
  1258. cus := &Custom{
  1259. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*float64(subItem.Count)),
  1260. Cut: fmt.Sprintf("%.4f", float64(subItem.Count)),
  1261. FeedetlSn: subItem.FeedetlSn,
  1262. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  1263. MedListCodg: subItem.XtHisAddtionConfig.Code,
  1264. HospApprFlag: -1,
  1265. DoctorNumber: new_doctor_id,
  1266. DoctorName: new_doctor_name,
  1267. }
  1268. customs = append(customs, cus)
  1269. }
  1270. }
  1271. }
  1272. // 生成输入报文
  1273. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1274. input := make(map[string]interface{})
  1275. feedetail := make([]map[string]interface{}, 0)
  1276. inputMessage["infno"] = "2204" // 交易编码
  1277. //chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  1278. for _, item := range customs {
  1279. feedetailInfo := make(map[string]interface{})
  1280. feedetailInfo["feedetl_sn"] = item.FeedetlSn
  1281. feedetailInfo["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1282. feedetailInfo["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1283. feedetailInfo["chrg_bchno"] = chrg_bchno // 收费批次号
  1284. feedetailInfo["dise_codg"] = diag_code // 病种编码
  1285. feedetailInfo["rxno"] = "" // 处方号
  1286. feedetailInfo["rx_circ_flag"] = "0" // 外购处方标志
  1287. feedetailInfo["fee_ocur_time"] = item.FeeOcurTime // 费用发生时间
  1288. feedetailInfo["med_list_codg"] = item.MedListCodg // 医疗目录编码
  1289. feedetailInfo["medins_list_codg"] = fixmedins_code // 医药机构目录编码
  1290. feedetailInfo["det_item_fee_sumamt"] = item.DetItemFeeSumamt // 明细项目费用总额
  1291. feedetailInfo["cnt"] = item.Cut // 数量
  1292. feedetailInfo["pric"] = item.Price // 单价
  1293. feedetailInfo["sin_dos_dscr"] = "" // 单次剂量描述
  1294. feedetailInfo["used_frqu_dscr"] = "" // 使用频次描述
  1295. feedetailInfo["prd_days"] = "0" // 周期天数
  1296. feedetailInfo["medc_way_dscr"] = "" // 用药途径描述
  1297. feedetailInfo["bilg_dept_codg"] = dept_code // 开单科室编码
  1298. feedetailInfo["bilg_dept_name"] = dept // 开单科室名称
  1299. feedetailInfo["bilg_dr_codg"] = item.DoctorNumber // 开单医生编码
  1300. feedetailInfo["bilg_dr_name"] = item.DoctorName // 开单医师姓名
  1301. feedetailInfo["acord_dept_codg"] = "" // 受单科室编码
  1302. feedetailInfo["acord_dept_name"] = "" // 受单科室名称
  1303. feedetailInfo["orders_dr_code"] = item.DoctorNumber // 受单医生编码
  1304. feedetailInfo["orders_dr_name"] = item.DoctorName // 受单医生姓名
  1305. if balance_accounts_type == "8" {
  1306. feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
  1307. } else {
  1308. if item.HospApprFlag != -1 {
  1309. if item.HospApprFlag == 1 {
  1310. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  1311. } else if item.HospApprFlag == 2 {
  1312. feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
  1313. } else if item.HospApprFlag == 3 {
  1314. feedetailInfo["hosp_appr_flag"] = "0" // 医院审批标志
  1315. } else {
  1316. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  1317. }
  1318. } else {
  1319. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  1320. }
  1321. }
  1322. //feedetailInfo["tcmdrug_used_way"] = "" // 中药使用方式
  1323. feedetailInfo["etip_flag"] = "" // 外检标志
  1324. feedetailInfo["etip_hosp_code"] = "" // 外检医院编码
  1325. feedetailInfo["dscg_tkdrug_flag"] = "" // 出院带药标志
  1326. feedetailInfo["matn_fee_flag"] = "" // 生育费用标志
  1327. feedetail = append(feedetail, feedetailInfo)
  1328. }
  1329. input["feedetail"] = feedetail
  1330. inputMessage["input"] = input //交易输入
  1331. var requestLog string
  1332. bytesData, err := json.Marshal(inputMessage)
  1333. fmt.Println("----------")
  1334. fmt.Println(string(bytesData))
  1335. fmt.Println("----------")
  1336. requestLog = string(bytesData)
  1337. if err != nil {
  1338. fmt.Println(err.Error())
  1339. return "", ""
  1340. }
  1341. reader := bytes.NewReader(bytesData)
  1342. gdyb_url := beego.AppConfig.String("gdyb_url")
  1343. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1344. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1345. var url string
  1346. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  1347. url = gdyb_url
  1348. } else {
  1349. url = gdyb_url + "2204"
  1350. }
  1351. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2204"
  1352. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2204"
  1353. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2204"
  1354. if insuplc_admdvs == "421300" {
  1355. var json2 string
  1356. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2204", string(bytesData), json2)
  1357. out, err := cmd.Output()
  1358. if err != nil {
  1359. fmt.Println("error:", err.Error())
  1360. }
  1361. fmt.Println(string(out))
  1362. return hex.EncodeToString(out), requestLog
  1363. } else {
  1364. request, err := http.NewRequest("POST", url, reader)
  1365. if err != nil {
  1366. fmt.Println(err.Error())
  1367. return "", ""
  1368. }
  1369. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1370. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1371. request.Header.Set("x-tif-signature", signature)
  1372. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1373. request.Header.Set("x-tif-nonce", nonce)
  1374. client := http.Client{}
  1375. resp, err := client.Do(request)
  1376. if err != nil {
  1377. fmt.Println(err.Error())
  1378. return "", ""
  1379. }
  1380. respBytes, err := ioutil.ReadAll(resp.Body)
  1381. if err != nil {
  1382. fmt.Println(err.Error())
  1383. return "", ""
  1384. }
  1385. return string(respBytes), requestLog
  1386. }
  1387. //var result RequestResult
  1388. //json.Unmarshal(respBytes, &result)
  1389. //return &result
  1390. }
  1391. // 门诊费用明细信息撤销
  1392. 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) {
  1393. // 生成签名
  1394. nonce := GetRandomString(32)
  1395. timestamp := time.Now().Unix()
  1396. signature := setSignature(timestamp, nonce, secret_key)
  1397. inputMessage := make(map[string]interface{})
  1398. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  1399. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  1400. } else {
  1401. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1402. }
  1403. // 生成输入报文
  1404. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1405. input := make(map[string]interface{})
  1406. inputData := make(map[string]interface{})
  1407. inputMessage["infno"] = "2205" // 交易编码
  1408. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1409. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  1410. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1411. input["data"] = inputData
  1412. inputMessage["input"] = input //交易输入
  1413. bytesData, err := json.Marshal(inputMessage)
  1414. fmt.Println(string(bytesData))
  1415. var requestLog string
  1416. requestLog = string(bytesData)
  1417. if err != nil {
  1418. fmt.Println(err.Error())
  1419. return err.Error(), ""
  1420. }
  1421. reader := bytes.NewReader(bytesData)
  1422. gdyb_url := beego.AppConfig.String("gdyb_url")
  1423. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1424. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1425. //url := gdyb_url + "2205"
  1426. var url string
  1427. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  1428. url = gdyb_url
  1429. } else {
  1430. url = gdyb_url + "2205"
  1431. }
  1432. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2205"
  1433. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2205"
  1434. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2205"
  1435. if insuplc_admdvs == "421300" {
  1436. var json2 string
  1437. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2205", string(bytesData), json2)
  1438. out, err := cmd.Output()
  1439. if err != nil {
  1440. fmt.Println("error:", err.Error())
  1441. }
  1442. fmt.Println(string(out))
  1443. return hex.EncodeToString(out), requestLog
  1444. } else {
  1445. request, err := http.NewRequest("POST", url, reader)
  1446. fmt.Println(err)
  1447. fmt.Println(request)
  1448. if err != nil {
  1449. fmt.Println(err.Error())
  1450. return err.Error(), ""
  1451. }
  1452. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1453. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1454. request.Header.Set("x-tif-signature", signature)
  1455. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1456. request.Header.Set("x-tif-nonce", nonce)
  1457. client := http.Client{}
  1458. resp, err := client.Do(request)
  1459. if err != nil {
  1460. fmt.Println(err.Error())
  1461. return err.Error(), ""
  1462. }
  1463. respBytes, err := ioutil.ReadAll(resp.Body)
  1464. if err != nil {
  1465. fmt.Println(err.Error())
  1466. return err.Error(), ""
  1467. }
  1468. str := string(respBytes)
  1469. fmt.Println(str)
  1470. return str, requestLog
  1471. }
  1472. }
  1473. // 门诊预结算
  1474. //
  1475. // func Gdyb2206(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string, total string, org_name string, doctor string, secret_key string) string {
  1476. 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) {
  1477. // 生成签名
  1478. nonce := GetRandomString(32)
  1479. timestamp := time.Now().Unix()
  1480. signature := setSignature(timestamp, nonce, secret_key)
  1481. inputMessage := make(map[string]interface{})
  1482. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  1483. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  1484. } else {
  1485. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1486. }
  1487. // 生成输入报文
  1488. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1489. input := make(map[string]interface{})
  1490. inputData := make(map[string]interface{})
  1491. inputMessage["infno"] = "2206" // 交易编码
  1492. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1493. if certificates == 3 {
  1494. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  1495. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1496. } else {
  1497. if id_card_type == 1 {
  1498. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  1499. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1500. } else if id_card_type == 4 {
  1501. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  1502. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1503. } else {
  1504. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  1505. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1506. }
  1507. }
  1508. if insuplc_admdvs == "421300" {
  1509. if med_type == "11" || med_type == "1112" || med_type == "1111" {
  1510. inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
  1511. } else if med_type == "14" {
  1512. inputData["med_type"] = "140110" // 医疗类别 11 普通门诊 12 门诊挂号
  1513. }
  1514. } else {
  1515. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  1516. }
  1517. inputData["medfee_sumamt"] = total // 医疗费总额
  1518. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  1519. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1520. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  1521. inputData["acct_used_flag"] = "0" // 个人账户使用标志 0否 1是
  1522. inputData["insutype"] = insutype // 险种类型
  1523. inputData["invono"] = "" // 发票号
  1524. input["data"] = inputData
  1525. inputMessage["input"] = input //交易输入
  1526. var requestLog string
  1527. bytesData, err := json.Marshal(inputMessage)
  1528. requestLog = string(bytesData)
  1529. fmt.Println(string(bytesData))
  1530. if err != nil {
  1531. fmt.Println(err.Error())
  1532. return err.Error(), ""
  1533. }
  1534. reader := bytes.NewReader(bytesData)
  1535. gdyb_url := beego.AppConfig.String("gdyb_url")
  1536. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1537. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1538. //url := gdyb_url + "2206"
  1539. var url string
  1540. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  1541. url = gdyb_url
  1542. } else {
  1543. url = gdyb_url + "2206"
  1544. }
  1545. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2206"
  1546. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2206"
  1547. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2206"
  1548. if insuplc_admdvs == "421300" {
  1549. var json2 string
  1550. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2206", string(bytesData), json2)
  1551. out, err := cmd.Output()
  1552. if err != nil {
  1553. fmt.Println("error:", err.Error())
  1554. }
  1555. fmt.Println(string(out))
  1556. return hex.EncodeToString(out), requestLog
  1557. } else {
  1558. request, err := http.NewRequest("POST", url, reader)
  1559. if err != nil {
  1560. fmt.Println(err.Error())
  1561. return err.Error(), ""
  1562. }
  1563. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1564. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1565. request.Header.Set("x-tif-signature", signature)
  1566. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1567. request.Header.Set("x-tif-nonce", nonce)
  1568. client := http.Client{}
  1569. resp, err := client.Do(request)
  1570. if err != nil {
  1571. fmt.Println(err.Error())
  1572. return err.Error(), ""
  1573. }
  1574. respBytes, err := ioutil.ReadAll(resp.Body)
  1575. if err != nil {
  1576. fmt.Println(err.Error())
  1577. return err.Error(), ""
  1578. }
  1579. str := string(respBytes)
  1580. fmt.Println(str)
  1581. return str, requestLog
  1582. }
  1583. }
  1584. // 门诊结算
  1585. 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) {
  1586. // 生成签名
  1587. nonce := GetRandomString(32)
  1588. timestamp := time.Now().Unix()
  1589. signature := setSignature(timestamp, nonce, secret_key)
  1590. // 生成输入报文
  1591. inputMessage := make(map[string]interface{})
  1592. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  1593. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  1594. } else {
  1595. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1596. }
  1597. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1598. input := make(map[string]interface{})
  1599. inputData := make(map[string]interface{})
  1600. inputMessage["infno"] = "2207" // 交易编码
  1601. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1602. if certificates == 3 {
  1603. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  1604. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1605. } else {
  1606. if id_card_type == 1 {
  1607. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  1608. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1609. } else if id_card_type == 4 {
  1610. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  1611. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  1612. } else {
  1613. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  1614. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1615. }
  1616. }
  1617. if med_type == "1111" || med_type == "1112" {
  1618. med_type = "11"
  1619. }
  1620. if insuplc_admdvs == "421300" {
  1621. if med_type == "11" {
  1622. inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
  1623. } else if med_type == "14" {
  1624. inputData["med_type"] = "140101" // 医疗类别 11 普通门诊 12 门诊挂号
  1625. }
  1626. } else {
  1627. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  1628. }
  1629. inputData["medfee_sumamt"] = total // 医疗费总额
  1630. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  1631. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1632. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  1633. inputData["acct_used_flag"] = acct_used_flag // 个人账户使用标志 0否 1是
  1634. inputData["insutype"] = insutype // 险种类型
  1635. inputData["invono"] = "" // 发票号
  1636. inputData["fulamt_ownpay_amt"] = fulamt_ownpay_amt //
  1637. inputData["overlmt_selfpay"] = overlmt_selfpay //
  1638. inputData["preselfpay_amt"] = preselfpay_amt //
  1639. inputData["inscp_scp_amt"] = inscp_scp_amt //
  1640. input["data"] = inputData
  1641. inputMessage["input"] = input //交易输入
  1642. bytesData, err := json.Marshal(inputMessage)
  1643. fmt.Println(string(bytesData))
  1644. if err != nil {
  1645. fmt.Println(err.Error())
  1646. return err.Error(), ""
  1647. }
  1648. reader := bytes.NewReader(bytesData)
  1649. gdyb_url := beego.AppConfig.String("gdyb_url")
  1650. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1651. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1652. //url := gdyb_url + "2207"
  1653. var url string
  1654. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  1655. url = gdyb_url
  1656. } else {
  1657. url = gdyb_url + "2207"
  1658. }
  1659. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2207"
  1660. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  1661. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  1662. if insuplc_admdvs == "421300" {
  1663. var json2 string
  1664. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2207", string(bytesData), json2)
  1665. out, err := cmd.Output()
  1666. if err != nil {
  1667. fmt.Println("error:", err.Error())
  1668. }
  1669. mjson, _ := json.Marshal(inputMessage)
  1670. str2 := string(mjson)
  1671. fmt.Println(string(out))
  1672. return hex.EncodeToString(out), str2
  1673. } else {
  1674. request, err := http.NewRequest("POST", url, reader)
  1675. if err != nil {
  1676. fmt.Println(err.Error())
  1677. return err.Error(), ""
  1678. }
  1679. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1680. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1681. request.Header.Set("x-tif-signature", signature)
  1682. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1683. request.Header.Set("x-tif-nonce", nonce)
  1684. client := http.Client{}
  1685. resp, err := client.Do(request)
  1686. if err != nil {
  1687. fmt.Println(err.Error())
  1688. return err.Error(), ""
  1689. }
  1690. respBytes, err := ioutil.ReadAll(resp.Body)
  1691. if err != nil {
  1692. fmt.Println(err.Error())
  1693. return err.Error(), ""
  1694. }
  1695. str := string(respBytes)
  1696. fmt.Println(str)
  1697. mjson, _ := json.Marshal(inputMessage)
  1698. str2 := string(mjson)
  1699. return str, str2
  1700. }
  1701. }
  1702. 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) {
  1703. // 生成签名
  1704. nonce := GetRandomString(32)
  1705. timestamp := time.Now().Unix()
  1706. signature := setSignature(timestamp, nonce, secret_key)
  1707. // 生成输入报文
  1708. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1709. input := make(map[string]interface{})
  1710. inputData := make(map[string]interface{})
  1711. inputMessage["infno"] = "2207A" // 交易编码
  1712. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1713. if certificates == 3 {
  1714. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  1715. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1716. } else {
  1717. if id_card_type == 1 {
  1718. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  1719. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1720. } else {
  1721. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  1722. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1723. }
  1724. }
  1725. if med_type == "1111" || med_type == "1112" {
  1726. med_type = "11"
  1727. }
  1728. if insuplc_admdvs == "421300" {
  1729. if med_type == "11" {
  1730. inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
  1731. } else if med_type == "14" {
  1732. inputData["med_type"] = "140101" // 医疗类别 11 普通门诊 12 门诊挂号
  1733. }
  1734. } else {
  1735. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  1736. }
  1737. inputData["medfee_sumamt"] = total // 医疗费总额
  1738. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  1739. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1740. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  1741. inputData["acct_used_flag"] = acct_used_flag // 个人账户使用标志 0否 1是
  1742. inputData["insutype"] = insutype // 险种类型
  1743. inputData["invono"] = "" // 发票号
  1744. inputData["fulamt_ownpay_amt"] = fulamt_ownpay_amt //
  1745. inputData["overlmt_selfpay"] = overlmt_selfpay //
  1746. inputData["preselfpay_amt"] = preselfpay_amt //
  1747. inputData["inscp_scp_amt"] = inscp_scp_amt //
  1748. input["data"] = inputData
  1749. inputMessage["input"] = input //交易输入
  1750. bytesData, err := json.Marshal(inputMessage)
  1751. fmt.Println(string(bytesData))
  1752. if err != nil {
  1753. fmt.Println(err.Error())
  1754. return err.Error(), ""
  1755. }
  1756. reader := bytes.NewReader(bytesData)
  1757. gdyb_url := beego.AppConfig.String("gdyb_url")
  1758. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1759. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1760. //url := gdyb_url + "2207"
  1761. var url string
  1762. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  1763. url = gdyb_url
  1764. } else {
  1765. url = gdyb_url + "2207"
  1766. }
  1767. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2207"
  1768. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  1769. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  1770. if insuplc_admdvs == "421300" {
  1771. var json2 string
  1772. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2207", string(bytesData), json2)
  1773. out, err := cmd.Output()
  1774. if err != nil {
  1775. fmt.Println("error:", err.Error())
  1776. }
  1777. mjson, _ := json.Marshal(inputMessage)
  1778. str2 := string(mjson)
  1779. fmt.Println(string(out))
  1780. return hex.EncodeToString(out), str2
  1781. } else {
  1782. request, err := http.NewRequest("POST", url, reader)
  1783. if err != nil {
  1784. fmt.Println(err.Error())
  1785. return err.Error(), ""
  1786. }
  1787. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1788. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1789. request.Header.Set("x-tif-signature", signature)
  1790. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1791. request.Header.Set("x-tif-nonce", nonce)
  1792. client := http.Client{}
  1793. resp, err := client.Do(request)
  1794. if err != nil {
  1795. fmt.Println(err.Error())
  1796. return err.Error(), ""
  1797. }
  1798. respBytes, err := ioutil.ReadAll(resp.Body)
  1799. if err != nil {
  1800. fmt.Println(err.Error())
  1801. return err.Error(), ""
  1802. }
  1803. str := string(respBytes)
  1804. fmt.Println(str)
  1805. mjson, _ := json.Marshal(inputMessage)
  1806. str2 := string(mjson)
  1807. return str, str2
  1808. }
  1809. }
  1810. // 门诊结算撤销
  1811. 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) {
  1812. // 生成签名
  1813. nonce := GetRandomString(32)
  1814. timestamp := time.Now().Unix()
  1815. signature := setSignature(timestamp, nonce, secret_key)
  1816. inputMessage := make(map[string]interface{})
  1817. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  1818. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  1819. } else {
  1820. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1821. }
  1822. // 生成输入报文
  1823. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1824. input := make(map[string]interface{})
  1825. inputData := make(map[string]interface{})
  1826. inputMessage["infno"] = "2208" // 交易编码
  1827. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1828. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1829. inputData["setl_id"] = setlId // 结算 ID
  1830. input["data"] = inputData
  1831. inputMessage["input"] = input //交易输入
  1832. bytesData, err := json.Marshal(inputMessage)
  1833. fmt.Println(string(bytesData))
  1834. if err != nil {
  1835. fmt.Println(err.Error())
  1836. return err.Error(), ""
  1837. }
  1838. reader := bytes.NewReader(bytesData)
  1839. gdyb_url := beego.AppConfig.String("gdyb_url")
  1840. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1841. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1842. //url := gdyb_url + "2208"
  1843. var url string
  1844. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  1845. url = gdyb_url
  1846. } else {
  1847. url = gdyb_url + "2208"
  1848. }
  1849. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2208"
  1850. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2208"
  1851. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2208"
  1852. if insuplc_admdvs == "421300" {
  1853. var json2 string
  1854. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2208", string(bytesData), json2)
  1855. out, err := cmd.Output()
  1856. if err != nil {
  1857. fmt.Println("error:", err.Error())
  1858. }
  1859. mjson, _ := json.Marshal(inputMessage)
  1860. str2 := string(mjson)
  1861. fmt.Println(string(out))
  1862. return hex.EncodeToString(out), str2
  1863. } else {
  1864. request, err := http.NewRequest("POST", url, reader)
  1865. if err != nil {
  1866. fmt.Println(err.Error())
  1867. return err.Error(), ""
  1868. }
  1869. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1870. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1871. request.Header.Set("x-tif-signature", signature)
  1872. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1873. request.Header.Set("x-tif-nonce", nonce)
  1874. client := http.Client{}
  1875. resp, err := client.Do(request)
  1876. if err != nil {
  1877. fmt.Println(err.Error())
  1878. return err.Error(), ""
  1879. }
  1880. respBytes, err := ioutil.ReadAll(resp.Body)
  1881. if err != nil {
  1882. fmt.Println(err.Error())
  1883. return err.Error(), ""
  1884. }
  1885. str := string(respBytes)
  1886. fmt.Println(str)
  1887. mjson, _ := json.Marshal(inputMessage)
  1888. str2 := string(mjson)
  1889. return str, str2
  1890. }
  1891. }
  1892. // 确认订单
  1893. func Gdyb6201(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, order models.HisOrder) string {
  1894. // 生成签名
  1895. nonce := GetRandomString(32)
  1896. timestamp := time.Now().Unix()
  1897. signature := setSignature(timestamp, nonce, secret_key)
  1898. // 生成输入报文
  1899. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1900. input := make(map[string]interface{})
  1901. inputData := make(map[string]interface{})
  1902. inputMessage["infno"] = "6201" // 交易编码
  1903. inputData["mdtrt_id"] = order.MdtrtId
  1904. inputData["chrg_bchno"] = order.Number
  1905. inputData["psn_no"] = order.PsnNo
  1906. inputData["psn_name"] = order.PsnName
  1907. inputData["psn_cert_type"] = order.PsnCertType
  1908. inputData["certno"] = order.Certno
  1909. inputData["insutype"] = order.Insutype
  1910. inputData["med_type"] = order.MedType
  1911. inputData["medfee_sumamt"] = order.MedfeeSumamt
  1912. inputData["fulamt_ownpay_amt"] = order.FulamtOwnpayAmt
  1913. inputData["overlmt_selfpay"] = order.OverlmtSelfPay
  1914. inputData["preselfpay_amt"] = order.PreselfpayAmt
  1915. inputData["inscp_scp_amt"] = order.InscpScpAmt
  1916. inputData["act_pay_dedc"] = order.ActPayDedc
  1917. inputData["hifp_pay"] = order.HifpPay
  1918. inputData["pool_prop_selfpay"] = order.PoolPropSelfpay
  1919. inputData["cvlserv_pay"] = order.CvlservPay
  1920. inputData["hifes_pay"] = order.HifesPay
  1921. inputData["hifmi_pay"] = order.HifmiPay
  1922. inputData["hifob_pay"] = order.HifobPay
  1923. inputData["maf_pay"] = order.MafPay
  1924. inputData["oth_pay"] = order.OthPay
  1925. inputData["fund_pay_sumamt"] = order.FundPaySumamt
  1926. inputData["psn_part_amt"] = order.PsnPartAmt
  1927. inputData["acct_pay"] = order.AcctPay
  1928. inputData["psn_cash_pay"] = order.PsnCashPay
  1929. inputData["hosp_part_amt"] = order.HospPartAmt
  1930. inputData["acct_mulaid_pay"] = order.AcctMulaidPay
  1931. input["data"] = inputData
  1932. inputMessage["input"] = input //交易输入
  1933. bytesData, err := json.Marshal(inputMessage)
  1934. fmt.Println(string(bytesData))
  1935. if err != nil {
  1936. fmt.Println(err.Error())
  1937. return err.Error()
  1938. }
  1939. reader := bytes.NewReader(bytesData)
  1940. gdyb_url := beego.AppConfig.String("gdyb_url")
  1941. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1942. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1943. url := gdyb_url + "6201"
  1944. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/6201"
  1945. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/6201"
  1946. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  1947. request, err := http.NewRequest("POST", url, reader)
  1948. if err != nil {
  1949. fmt.Println(err.Error())
  1950. return err.Error()
  1951. }
  1952. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1953. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1954. request.Header.Set("x-tif-signature", signature)
  1955. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1956. request.Header.Set("x-tif-nonce", nonce)
  1957. client := http.Client{}
  1958. resp, err := client.Do(request)
  1959. if err != nil {
  1960. fmt.Println(err.Error())
  1961. return err.Error()
  1962. }
  1963. respBytes, err := ioutil.ReadAll(resp.Body)
  1964. if err != nil {
  1965. fmt.Println(err.Error())
  1966. return err.Error()
  1967. }
  1968. str := string(respBytes)
  1969. fmt.Println(str)
  1970. return str
  1971. }
  1972. // 医药机构费用结算对总账 func Gdyb3201( org_name string, doctor string, secret_key string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) string {
  1973. func Gdyb3201(baseParams models.BaseParams, businessParams models.BusinessParams, admin_user_id int64) string {
  1974. fmt.Println("11222333-----")
  1975. fmt.Println(baseParams)
  1976. fmt.Println(businessParams)
  1977. // 生成签名
  1978. nonce := GetRandomString(32)
  1979. timestamp := time.Now().Unix()
  1980. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1981. inputMessage := make(map[string]interface{})
  1982. if baseParams.MdtrtareaAdmvs == "450721" || baseParams.MdtrtareaAdmvs == "450127" {
  1983. inputMessage = SetInputMessage1111(nonce, timestamp, baseParams.OrgName, admin_user_id, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.Doctor)
  1984. } else {
  1985. inputMessage = SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1986. //inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1987. }
  1988. // 生成输入报文
  1989. input := make(map[string]interface{})
  1990. inputData := make(map[string]interface{})
  1991. inputMessage["infno"] = "3201" // 交易编码
  1992. inputData["insutype"] = businessParams.Insutype // 险种
  1993. if baseParams.MdtrtareaAdmvs == "450721" {
  1994. if businessParams.Insutype == "390" {
  1995. inputData["clr_type"] = "99971" // 就诊 ID(来自2201接口返回)
  1996. } else {
  1997. inputData["clr_type"] = "99970" // 就诊 ID(来自2201接口返回)
  1998. }
  1999. } else {
  2000. inputData["clr_type"] = businessParams.ClrType // 就诊 ID(来自2201接口返回)
  2001. }
  2002. inputData["setl_optins"] = businessParams.SetlOptins // 结算经办机构
  2003. inputData["stmt_begndate"] = businessParams.StmtBegndate // 对帐开始时间
  2004. inputData["stmt_enddate"] = businessParams.StmtEnddate //对帐结束时间
  2005. inputData["medfee_sumamt"] = businessParams.MedfeeSumamt //医疗费总额
  2006. inputData["fund_pay_sumamt"] = businessParams.FundPaySumamt //基金支付总额
  2007. inputData["acct_pay"] = businessParams.AcctPay //个人账户支付金额
  2008. inputData["fixmedins_setl_cnt"] = businessParams.FixmedinsSetlCnt //定点医药机构结算笔数
  2009. inputData["refd_setl_flag"] = 0 // 就诊 ID(来自2201接口返回)
  2010. input["data"] = inputData
  2011. inputMessage["input"] = input //交易输入
  2012. bytesData, err := json.Marshal(inputMessage)
  2013. fmt.Println(string(bytesData))
  2014. if err != nil {
  2015. fmt.Println(err.Error())
  2016. return err.Error()
  2017. }
  2018. reader := bytes.NewReader(bytesData)
  2019. gdyb_url := beego.AppConfig.String("gdyb_url")
  2020. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2021. var url string
  2022. if baseParams.MdtrtareaAdmvs == "150499" || baseParams.MdtrtareaAdmvs == "450721" {
  2023. url = gdyb_url
  2024. } else {
  2025. url = gdyb_url + "3201"
  2026. }
  2027. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2028. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3201"
  2029. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3201"
  2030. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3201"
  2031. request, err := http.NewRequest("POST", url, reader)
  2032. if err != nil {
  2033. fmt.Println(err.Error())
  2034. return err.Error()
  2035. }
  2036. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2037. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2038. request.Header.Set("x-tif-signature", signature)
  2039. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2040. request.Header.Set("x-tif-nonce", nonce)
  2041. client := http.Client{}
  2042. resp, err := client.Do(request)
  2043. if err != nil {
  2044. fmt.Println(err.Error())
  2045. return err.Error()
  2046. }
  2047. respBytes, err := ioutil.ReadAll(resp.Body)
  2048. if err != nil {
  2049. fmt.Println(err.Error())
  2050. return err.Error()
  2051. }
  2052. str := string(respBytes)
  2053. fmt.Println(str)
  2054. return str
  2055. }
  2056. type Params struct {
  2057. FileName string `json:"file_name"` //产品ID
  2058. In []byte `json:"in"` //
  2059. FixmedinsCode string `json:"fixmedins_code"` //调用环境生产为1 沙盒2
  2060. }
  2061. // 文件上传
  2062. func Gdyb9101(baseParams models.BaseParams, file_name string, file_byte []byte) string {
  2063. // 生成签名
  2064. nonce := GetRandomString(32)
  2065. timestamp := time.Now().Unix()
  2066. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  2067. //buf := new(bytes.Buffer)
  2068. //buf.ReadFrom(strings.NewReader(string(file_byte)))
  2069. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  2070. input := make(map[string]interface{})
  2071. inputData := make(map[string]interface{})
  2072. inputMessage["infno"] = "9101" // 交易编码
  2073. inputData["file_name"] = file_name //文件名
  2074. inputData["in"] = file_byte //文件数据
  2075. inputData["fixmedins_code"] = baseParams.FixmedinsCode //编码
  2076. input["fsUploadIn"] = inputData
  2077. inputMessage["input"] = input //交易输入
  2078. bytesData, err := json.Marshal(inputMessage)
  2079. fmt.Println(string(bytesData))
  2080. if err != nil {
  2081. fmt.Println(err.Error())
  2082. return err.Error()
  2083. }
  2084. reader := bytes.NewReader(bytesData)
  2085. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/9101"
  2086. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9101"
  2087. gdyb_url := beego.AppConfig.String("gdyb_url")
  2088. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2089. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2090. url := gdyb_url + "9101"
  2091. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9101"
  2092. request, err := http.NewRequest("POST", url, reader)
  2093. if err != nil {
  2094. fmt.Println(err.Error())
  2095. return err.Error()
  2096. }
  2097. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2098. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2099. request.Header.Set("x-tif-signature", signature)
  2100. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2101. request.Header.Set("x-tif-nonce", nonce)
  2102. client := http.Client{}
  2103. resp, err := client.Do(request)
  2104. if err != nil {
  2105. fmt.Println(err.Error())
  2106. return err.Error()
  2107. }
  2108. respBytes, err := ioutil.ReadAll(resp.Body)
  2109. if err != nil {
  2110. fmt.Println(err.Error())
  2111. return err.Error()
  2112. }
  2113. str := string(respBytes)
  2114. fmt.Println(str)
  2115. return str
  2116. }
  2117. func Gdyb9102(baseParams models.BaseParams, file_name string, file_qury_no string) string {
  2118. // 生成签名
  2119. nonce := GetRandomString(32)
  2120. timestamp := time.Now().Unix()
  2121. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  2122. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  2123. input := make(map[string]interface{})
  2124. inputData := make(map[string]interface{})
  2125. inputMessage["infno"] = "9102" // 交易编码
  2126. inputData["file_name"] = file_name //文件名
  2127. inputData["file_qury_no"] = file_qury_no //文件数据
  2128. inputData["fixmedins_code"] = baseParams.FixmedinsCode //编码
  2129. input["fsDownloadIn"] = inputData
  2130. inputMessage["input"] = input //交易输入
  2131. bytesData, err := json.Marshal(inputMessage)
  2132. fmt.Println(string(bytesData))
  2133. if err != nil {
  2134. fmt.Println(err.Error())
  2135. return err.Error()
  2136. }
  2137. reader := bytes.NewReader(bytesData)
  2138. gdyb_url := beego.AppConfig.String("gdyb_url")
  2139. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2140. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2141. url := gdyb_url + "9102"
  2142. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/9102"
  2143. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9102"
  2144. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9102"
  2145. request, err := http.NewRequest("POST", url, reader)
  2146. if err != nil {
  2147. fmt.Println(err.Error())
  2148. return err.Error()
  2149. }
  2150. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2151. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2152. request.Header.Set("x-tif-signature", signature)
  2153. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2154. request.Header.Set("x-tif-nonce", nonce)
  2155. client := http.Client{}
  2156. resp, err := client.Do(request)
  2157. if err != nil {
  2158. fmt.Println(err.Error())
  2159. return err.Error()
  2160. }
  2161. respBytes, err := ioutil.ReadAll(resp.Body)
  2162. if err != nil {
  2163. fmt.Println(err.Error())
  2164. return err.Error()
  2165. }
  2166. str := string(respBytes)
  2167. enc := mahonia.NewEncoder("gbk")
  2168. //output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  2169. fmt.Println(enc.ConvertString(str))
  2170. return str
  2171. }
  2172. func Gdyb3202(baseParams models.BaseParams, businessParams models.BusinessParams) string {
  2173. // 生成签名
  2174. nonce := GetRandomString(32)
  2175. timestamp := time.Now().Unix()
  2176. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  2177. // 生成输入报文
  2178. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  2179. input := make(map[string]interface{})
  2180. inputData := make(map[string]interface{})
  2181. inputMessage["infno"] = "3202" // 交易编码
  2182. inputData["file_qury_no"] = businessParams.FileQuryNo // 险种
  2183. inputData["setl_optins"] = baseParams.InsuplcAdmdvs // 结算经办机构
  2184. inputData["stmt_begndate"] = businessParams.StmtBegndate // 对帐开始时间
  2185. inputData["stmt_enddate"] = businessParams.StmtEnddate //对帐结束时间
  2186. inputData["medfee_sumamt"] = businessParams.MedfeeSumamt //医疗费总额
  2187. inputData["fund_pay_sumamt"] = businessParams.FundPaySumamt //基金支付总额
  2188. inputData["cash_payamt"] = businessParams.CashPayamt //现金支付金额
  2189. inputData["fixmedins_setl_cnt"] = businessParams.FixmedinsSetlCnt //定点医药机构结算笔数
  2190. inputData["clr_type"] = "11" // 就诊 ID(来自2201接口返回)
  2191. inputData["refd_setl_flag"] = 1 // 就诊 ID(来自2201接口返回)
  2192. input["data"] = inputData
  2193. inputMessage["input"] = input //交易输入
  2194. bytesData, err := json.Marshal(inputMessage)
  2195. fmt.Println(string(bytesData))
  2196. if err != nil {
  2197. fmt.Println(err.Error())
  2198. return err.Error()
  2199. }
  2200. reader := bytes.NewReader(bytesData)
  2201. gdyb_url := beego.AppConfig.String("gdyb_url")
  2202. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2203. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2204. url := gdyb_url + "3202"
  2205. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3202"
  2206. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3202"
  2207. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3202"
  2208. request, err := http.NewRequest("POST", url, reader)
  2209. if err != nil {
  2210. fmt.Println(err.Error())
  2211. return err.Error()
  2212. }
  2213. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2214. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2215. request.Header.Set("x-tif-signature", signature)
  2216. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2217. request.Header.Set("x-tif-nonce", nonce)
  2218. client := http.Client{}
  2219. resp, err := client.Do(request)
  2220. if err != nil {
  2221. fmt.Println(err.Error())
  2222. return err.Error()
  2223. }
  2224. respBytes, err := ioutil.ReadAll(resp.Body)
  2225. if err != nil {
  2226. fmt.Println(err.Error())
  2227. return err.Error()
  2228. }
  2229. str := string(respBytes)
  2230. fmt.Println(str)
  2231. return str
  2232. }
  2233. func Gdyb5203(baseParams models.BaseParams, businessParams models.BusinessParams) string {
  2234. fmt.Println("~~~~~~1")
  2235. fmt.Println(baseParams)
  2236. fmt.Println(businessParams)
  2237. // 生成签名
  2238. nonce := GetRandomString(32)
  2239. timestamp := time.Now().Unix()
  2240. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  2241. fmt.Println("~~~~~~2")
  2242. // 生成输入报文
  2243. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  2244. input := make(map[string]interface{})
  2245. inputData := make(map[string]interface{})
  2246. inputMessage["infno"] = "5203" // 交易编码
  2247. inputData["psn_no"] = businessParams.PsnNo
  2248. inputData["setl_id"] = businessParams.SetlId
  2249. inputData["mdtrt_id"] = businessParams.MdtrtId
  2250. input["data"] = inputData
  2251. inputMessage["input"] = input //交易输入
  2252. bytesData, err := json.Marshal(inputMessage)
  2253. fmt.Println(string(bytesData))
  2254. fmt.Println("~~~~~~")
  2255. fmt.Println("~~~~~~")
  2256. fmt.Println(string(bytesData))
  2257. if err != nil {
  2258. fmt.Println(err.Error())
  2259. return err.Error()
  2260. }
  2261. reader := bytes.NewReader(bytesData)
  2262. gdyb_url := beego.AppConfig.String("gdyb_url")
  2263. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2264. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2265. //url := gdyb_url + "5203"
  2266. var url string
  2267. if baseParams.FixmedinsCode == "H15049901371" || baseParams.MdtrtareaAdmvs == "450127" || baseParams.MdtrtareaAdmvs == "450721" {
  2268. url = gdyb_url
  2269. } else {
  2270. url = gdyb_url + "5203"
  2271. }
  2272. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5203"
  2273. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
  2274. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
  2275. request, err := http.NewRequest("POST", url, reader)
  2276. if err != nil {
  2277. fmt.Println(err.Error())
  2278. return err.Error()
  2279. }
  2280. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2281. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2282. request.Header.Set("x-tif-signature", signature)
  2283. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2284. request.Header.Set("x-tif-nonce", nonce)
  2285. client := http.Client{}
  2286. resp, err := client.Do(request)
  2287. if err != nil {
  2288. fmt.Println(err.Error())
  2289. return err.Error()
  2290. }
  2291. respBytes, err := ioutil.ReadAll(resp.Body)
  2292. if err != nil {
  2293. fmt.Println(err.Error())
  2294. return err.Error()
  2295. }
  2296. str := string(respBytes)
  2297. fmt.Println(str)
  2298. return str
  2299. }
  2300. func Gdyb5204(baseParams models.BaseParams, businessParams models.BusinessParams) string {
  2301. // 生成签名
  2302. nonce := GetRandomString(32)
  2303. timestamp := time.Now().Unix()
  2304. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  2305. // 生成输入报文
  2306. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  2307. input := make(map[string]interface{})
  2308. inputData := make(map[string]interface{})
  2309. inputMessage["infno"] = "5204" // 交易编码
  2310. inputData["psn_no"] = businessParams.PsnNo
  2311. inputData["setl_id"] = businessParams.SetlId
  2312. inputData["mdtrt_id"] = businessParams.MdtrtId
  2313. input["data"] = inputData
  2314. inputMessage["input"] = input //交易输入
  2315. bytesData, err := json.Marshal(inputMessage)
  2316. fmt.Println(string(bytesData))
  2317. if err != nil {
  2318. fmt.Println(err.Error())
  2319. return err.Error()
  2320. }
  2321. reader := bytes.NewReader(bytesData)
  2322. gdyb_url := beego.AppConfig.String("gdyb_url")
  2323. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2324. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2325. //url := gdyb_url + "5203"
  2326. var url string
  2327. if baseParams.FixmedinsCode == "H15049901371" || baseParams.MdtrtareaAdmvs == "450127" || baseParams.MdtrtareaAdmvs == "450721" {
  2328. url = gdyb_url
  2329. } else {
  2330. url = gdyb_url + "5204"
  2331. }
  2332. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5203"
  2333. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
  2334. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
  2335. request, err := http.NewRequest("POST", url, reader)
  2336. if err != nil {
  2337. fmt.Println(err.Error())
  2338. return err.Error()
  2339. }
  2340. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2341. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2342. request.Header.Set("x-tif-signature", signature)
  2343. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2344. request.Header.Set("x-tif-nonce", nonce)
  2345. client := http.Client{}
  2346. resp, err := client.Do(request)
  2347. if err != nil {
  2348. fmt.Println(err.Error())
  2349. return err.Error()
  2350. }
  2351. respBytes, err := ioutil.ReadAll(resp.Body)
  2352. if err != nil {
  2353. fmt.Println(err.Error())
  2354. return err.Error()
  2355. }
  2356. str := string(respBytes)
  2357. fmt.Println(str)
  2358. return str
  2359. }
  2360. func Gdyb2001(baseParams models.BaseParams, psn_no string, insutype string, med_type string) string {
  2361. if med_type == "1111" || med_type == "1112" {
  2362. med_type = "11"
  2363. }
  2364. // 生成签名
  2365. nonce := GetRandomString(32)
  2366. timestamp := time.Now().Unix()
  2367. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  2368. // 生成输入报文
  2369. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  2370. input := make(map[string]interface{})
  2371. inputData := make(map[string]interface{})
  2372. inputMessage["infno"] = "2001" // 交易编码
  2373. inputData["psn_no"] = psn_no
  2374. inputData["insutype"] = insutype
  2375. inputData["fixmedins_code"] = baseParams.FixmedinsCode
  2376. inputData["med_type"] = med_type
  2377. inputData["begntime"] = "2021-01-01 00:00:00"
  2378. input["data"] = inputData
  2379. inputMessage["input"] = input //交易输入
  2380. bytesData, err := json.Marshal(inputMessage)
  2381. fmt.Println(string(bytesData))
  2382. if err != nil {
  2383. fmt.Println(err.Error())
  2384. return err.Error()
  2385. }
  2386. reader := bytes.NewReader(bytesData)
  2387. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3301"
  2388. gdyb_url := beego.AppConfig.String("gdyb_url")
  2389. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2390. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2391. url := gdyb_url
  2392. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3301"
  2393. request, err := http.NewRequest("POST", url, reader)
  2394. if err != nil {
  2395. fmt.Println(err.Error())
  2396. return err.Error()
  2397. }
  2398. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2399. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2400. request.Header.Set("x-tif-signature", signature)
  2401. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2402. request.Header.Set("x-tif-nonce", nonce)
  2403. client := http.Client{}
  2404. resp, err := client.Do(request)
  2405. if err != nil {
  2406. fmt.Println(err.Error())
  2407. return err.Error()
  2408. }
  2409. respBytes, err := ioutil.ReadAll(resp.Body)
  2410. if err != nil {
  2411. fmt.Println(err.Error())
  2412. return err.Error()
  2413. }
  2414. str := string(respBytes)
  2415. fmt.Println(str)
  2416. return str
  2417. }
  2418. 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 {
  2419. // 生成签名
  2420. nonce := GetRandomString(32)
  2421. timestamp := time.Now().Unix()
  2422. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  2423. inputMessage := make(map[string]interface{})
  2424. if baseParams.MdtrtareaAdmvs == "450721" {
  2425. inputMessage = SetInputMessage1111(nonce, timestamp, baseParams.OrgName, admin_user_id, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.Doctor)
  2426. //inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs,doctor)
  2427. } else {
  2428. inputMessage = SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  2429. //inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2430. }
  2431. // 生成输入报文
  2432. input := make(map[string]interface{})
  2433. //input2 := make([]map[string]interface{})
  2434. feedetail := make([]map[string]interface{}, 0)
  2435. inputData := make(map[string]interface{})
  2436. inputMessage["infno"] = "3301A" // 交易编码
  2437. inputData["fixmedins_hilist_id"] = codg
  2438. inputData["fixmedins_hilist_name"] = name
  2439. inputData["list_type"] = list_type
  2440. inputData["med_list_codg"] = codg
  2441. inputData["begndate"] = start_time
  2442. inputData["enddate"] = ent_time
  2443. inputData["aprvno"] = ""
  2444. inputData["dosform"] = ""
  2445. inputData["exct_cont"] = ""
  2446. inputData["item_cont"] = ""
  2447. inputData["prcunt"] = ""
  2448. inputData["spec"] = ""
  2449. inputData["pacspec"] = ""
  2450. inputData["memo"] = ""
  2451. feedetail = append(feedetail, inputData)
  2452. input["data"] = feedetail
  2453. inputMessage["input"] = input //交易输入
  2454. bytesData, err := json.Marshal(inputMessage)
  2455. fmt.Println(string(bytesData))
  2456. if err != nil {
  2457. fmt.Println(err.Error())
  2458. return err.Error()
  2459. }
  2460. reader := bytes.NewReader(bytesData)
  2461. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3301"
  2462. //
  2463. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3301"
  2464. gdyb_url := beego.AppConfig.String("gdyb_url")
  2465. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2466. url := ""
  2467. if baseParams.MdtrtareaAdmvs == "450721" {
  2468. url = gdyb_url
  2469. } else {
  2470. url = gdyb_url + "3301"
  2471. }
  2472. request, err := http.NewRequest("POST", url, reader)
  2473. if err != nil {
  2474. fmt.Println(err.Error())
  2475. return err.Error()
  2476. }
  2477. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2478. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2479. request.Header.Set("x-tif-signature", signature)
  2480. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2481. request.Header.Set("x-tif-nonce", nonce)
  2482. client := http.Client{}
  2483. resp, err := client.Do(request)
  2484. if err != nil {
  2485. fmt.Println(err.Error())
  2486. return err.Error()
  2487. }
  2488. respBytes, err := ioutil.ReadAll(resp.Body)
  2489. if err != nil {
  2490. fmt.Println(err.Error())
  2491. return err.Error()
  2492. }
  2493. str := string(respBytes)
  2494. fmt.Println(str)
  2495. return str
  2496. }
  2497. func Gdyb3302(baseParams *models.BaseParams, name string, codg string, list_type_code string) string {
  2498. // 生成签名
  2499. nonce := GetRandomString(32)
  2500. timestamp := time.Now().Unix()
  2501. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  2502. // 生成输入报文
  2503. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  2504. input := make(map[string]interface{})
  2505. inputData := make(map[string]interface{})
  2506. inputMessage["infno"] = "3302" // 交易编码
  2507. inputData["fixmedins_code"] = baseParams.FixmedinsCode
  2508. inputData["fixmedins_hilist_id"] = codg
  2509. inputData["list_type"] = list_type_code
  2510. inputData["med_list_codg"] = codg
  2511. input["data"] = inputData
  2512. inputMessage["input"] = input //交易输入
  2513. bytesData, err := json.Marshal(inputMessage)
  2514. fmt.Println(string(bytesData))
  2515. if err != nil {
  2516. fmt.Println(err.Error())
  2517. return err.Error()
  2518. }
  2519. reader := bytes.NewReader(bytesData)
  2520. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3302"
  2521. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3302"
  2522. gdyb_url := beego.AppConfig.String("gdyb_url")
  2523. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2524. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2525. url := gdyb_url + "3302"
  2526. request, err := http.NewRequest("POST", url, reader)
  2527. if err != nil {
  2528. fmt.Println(err.Error())
  2529. return err.Error()
  2530. }
  2531. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2532. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2533. request.Header.Set("x-tif-signature", signature)
  2534. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2535. request.Header.Set("x-tif-nonce", nonce)
  2536. client := http.Client{}
  2537. resp, err := client.Do(request)
  2538. if err != nil {
  2539. fmt.Println(err.Error())
  2540. return err.Error()
  2541. }
  2542. respBytes, err := ioutil.ReadAll(resp.Body)
  2543. if err != nil {
  2544. fmt.Println(err.Error())
  2545. return err.Error()
  2546. }
  2547. str := string(respBytes)
  2548. fmt.Println(str)
  2549. return str
  2550. }
  2551. 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 {
  2552. // 生成签名
  2553. nonce := GetRandomString(32)
  2554. timestamp := time.Now().Unix()
  2555. signature := setSignature(timestamp, nonce, secret_key)
  2556. inputMessage := make(map[string]interface{})
  2557. //tempTime := time.Unix(timestamp, 0)
  2558. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2559. // 生成输入报文
  2560. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  2561. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  2562. } else {
  2563. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2564. }
  2565. // 生成输入报文
  2566. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2567. input := make(map[string]interface{})
  2568. inputData := make(map[string]interface{})
  2569. inputMessage["infno"] = "2505"
  2570. inputData["psn_no"] = psnNo
  2571. inputData["biz_appy_type"] = "01"
  2572. inputData["begndate"] = start_time
  2573. inputData["enddate"] = end_time
  2574. inputData["fixmedins_code"] = fixmedins_code
  2575. inputData["fixmedins_name"] = org_name
  2576. inputData["tel"] = ""
  2577. inputData["addr"] = ""
  2578. inputData["agnter_name"] = ""
  2579. inputData["agnter_cert_type"] = ""
  2580. inputData["agnter_certno"] = ""
  2581. inputData["agnter_tel"] = ""
  2582. inputData["agnter_addr"] = ""
  2583. inputData["agnter_rlts"] = ""
  2584. inputData["fix_srt_no"] = "1"
  2585. inputData["memo"] = ""
  2586. input["data"] = inputData
  2587. inputMessage["input"] = input //交易输入
  2588. bytesData, err := json.Marshal(inputMessage)
  2589. if err != nil {
  2590. fmt.Println(err.Error())
  2591. return err.Error()
  2592. }
  2593. reader := bytes.NewReader(bytesData)
  2594. //fmt.Println(String(bytesData))
  2595. fmt.Println(string(bytesData))
  2596. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2505"
  2597. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2505"
  2598. gdyb_url := beego.AppConfig.String("gdyb_url")
  2599. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2600. url := ""
  2601. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  2602. url = gdyb_url
  2603. } else {
  2604. url = gdyb_url + "2505"
  2605. }
  2606. request, err := http.NewRequest("POST", url, reader)
  2607. if err != nil {
  2608. fmt.Println(err.Error())
  2609. return err.Error()
  2610. }
  2611. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2612. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2613. request.Header.Set("x-tif-signature", signature)
  2614. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2615. request.Header.Set("x-tif-nonce", nonce)
  2616. client := http.Client{}
  2617. resp, err := client.Do(request)
  2618. if err != nil {
  2619. fmt.Println(err.Error())
  2620. return err.Error()
  2621. }
  2622. respBytes, err := ioutil.ReadAll(resp.Body)
  2623. if err != nil {
  2624. fmt.Println(err.Error())
  2625. return err.Error()
  2626. }
  2627. str := string(respBytes)
  2628. fmt.Println(str)
  2629. return str
  2630. }
  2631. 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 {
  2632. // 生成签名
  2633. nonce := GetRandomString(32)
  2634. timestamp := time.Now().Unix()
  2635. signature := setSignature(timestamp, nonce, secret_key)
  2636. // 生成输入报文
  2637. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2638. input := make(map[string]interface{})
  2639. inputData := make(map[string]interface{})
  2640. inputMessage["infno"] = "2506"
  2641. inputData["psn_no"] = psnNo
  2642. inputData["trt_dcla_detl_sn"] = trt_dcla_detl_sn
  2643. inputData["memo"] = ""
  2644. input["data"] = inputData
  2645. inputMessage["input"] = input //交易输入
  2646. bytesData, err := json.Marshal(inputMessage)
  2647. fmt.Println(string(bytesData))
  2648. if err != nil {
  2649. fmt.Println(err.Error())
  2650. return err.Error()
  2651. }
  2652. reader := bytes.NewReader(bytesData)
  2653. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2506"
  2654. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2506"
  2655. gdyb_url := beego.AppConfig.String("gdyb_url")
  2656. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2657. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2658. url := gdyb_url + "2506"
  2659. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  2660. request, err := http.NewRequest("POST", url, reader)
  2661. if err != nil {
  2662. fmt.Println(err.Error())
  2663. return err.Error()
  2664. }
  2665. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2666. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2667. request.Header.Set("x-tif-signature", signature)
  2668. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2669. request.Header.Set("x-tif-nonce", nonce)
  2670. client := http.Client{}
  2671. resp, err := client.Do(request)
  2672. if err != nil {
  2673. fmt.Println(err.Error())
  2674. return err.Error()
  2675. }
  2676. respBytes, err := ioutil.ReadAll(resp.Body)
  2677. if err != nil {
  2678. fmt.Println(err.Error())
  2679. return err.Error()
  2680. }
  2681. str := string(respBytes)
  2682. fmt.Println(str)
  2683. return str
  2684. }
  2685. 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 {
  2686. // 生成签名
  2687. nonce := GetRandomString(32)
  2688. timestamp := time.Now().Unix()
  2689. signature := setSignature(timestamp, nonce, secret_key)
  2690. //tempTime := time.Unix(timestamp, 0)
  2691. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2692. //timeFormatTwo := tempTime.Format("2006-01-02")
  2693. //t := time.Now()
  2694. //last := time.Date(t.Year(), time.December, 31, 0, 0, 0, 0, time.UTC)
  2695. //tm := time.Unix(last.Unix(), 0)
  2696. // 生成输入报文
  2697. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2698. input := make(map[string]interface{})
  2699. inputData := make(map[string]interface{})
  2700. inputMessage["infno"] = "2503" // 交易编码
  2701. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  2702. inputData["insutype"] = insutype // 险种类型(来自1101接口返回)
  2703. inputData["opsp_dise_code"] = sick_code // 险种类型(来自1101接口返回)
  2704. inputData["opsp_dise_name"] = sick_name // 险种类型(来自1101接口返回)
  2705. inputData["insu_optins"] = insuplc_admdvs // 险种类型(来自1101接口返回)
  2706. inputData["ide_fixmedins_no"] = hospital_code // 险种类型(来自1101接口返回)
  2707. inputData["ide_fixmedins_name"] = hospital_name // 险种类型(来自1101接口返回)
  2708. inputData["hosp_ide_date"] = check_time // 险种类型(来自1101接口返回)
  2709. inputData["diag_dr_codg"] = doctor_id // 开始时间
  2710. inputData["diag_dr_name"] = doctor // 开始时间
  2711. inputData["begndate"] = start_time // 医师编码
  2712. inputData["tel"] = "" // 医师编码
  2713. inputData["addr"] = "" // 医师编码
  2714. inputData["enddate"] = end_time // 医师编码
  2715. input["data"] = inputData
  2716. inputMessage["input"] = input //交易输入
  2717. bytesData, err := json.Marshal(inputMessage)
  2718. fmt.Println(string(bytesData))
  2719. if err != nil {
  2720. fmt.Println(err.Error())
  2721. return err.Error()
  2722. }
  2723. reader := bytes.NewReader(bytesData)
  2724. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2503"
  2725. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2503"
  2726. gdyb_url := beego.AppConfig.String("gdyb_url")
  2727. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2728. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2729. //url := gdyb_url + "2503"
  2730. var url string
  2731. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  2732. url = gdyb_url
  2733. } else {
  2734. url = gdyb_url + "2503"
  2735. }
  2736. request, err := http.NewRequest("POST", url, reader)
  2737. if err != nil {
  2738. fmt.Println(err.Error())
  2739. return err.Error()
  2740. }
  2741. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2742. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2743. request.Header.Set("x-tif-signature", signature)
  2744. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2745. request.Header.Set("x-tif-nonce", nonce)
  2746. client := http.Client{}
  2747. resp, err := client.Do(request)
  2748. if err != nil {
  2749. fmt.Println(err.Error())
  2750. return err.Error()
  2751. }
  2752. respBytes, err := ioutil.ReadAll(resp.Body)
  2753. if err != nil {
  2754. fmt.Println(err.Error())
  2755. return err.Error()
  2756. }
  2757. str := string(respBytes)
  2758. fmt.Println(str)
  2759. return str
  2760. }
  2761. 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 {
  2762. // 生成签名
  2763. nonce := GetRandomString(32)
  2764. timestamp := time.Now().Unix()
  2765. signature := setSignature(timestamp, nonce, secret_key)
  2766. // 生成输入报文
  2767. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2768. input := make(map[string]interface{})
  2769. inputData := make(map[string]interface{})
  2770. inputMessage["infno"] = "2504" // 交易编码
  2771. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  2772. inputData["trt_dcla_detl_sn"] = trt_dcla_detl_sn // 人员编号 (来自1101接口返回)
  2773. inputData["memo"] = "撤销备案" // 人员编号 (来自1101接口返回)
  2774. input["data"] = inputData
  2775. inputMessage["input"] = input //交易输入
  2776. bytesData, err := json.Marshal(inputMessage)
  2777. fmt.Println(string(bytesData))
  2778. if err != nil {
  2779. fmt.Println(err.Error())
  2780. return err.Error()
  2781. }
  2782. reader := bytes.NewReader(bytesData)
  2783. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2504"
  2784. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2504"
  2785. gdyb_url := beego.AppConfig.String("gdyb_url")
  2786. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2787. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2788. url := gdyb_url + "2504"
  2789. request, err := http.NewRequest("POST", url, reader)
  2790. if err != nil {
  2791. fmt.Println(err.Error())
  2792. return err.Error()
  2793. }
  2794. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2795. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2796. request.Header.Set("x-tif-signature", signature)
  2797. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2798. request.Header.Set("x-tif-nonce", nonce)
  2799. client := http.Client{}
  2800. resp, err := client.Do(request)
  2801. if err != nil {
  2802. fmt.Println(err.Error())
  2803. return err.Error()
  2804. }
  2805. respBytes, err := ioutil.ReadAll(resp.Body)
  2806. if err != nil {
  2807. fmt.Println(err.Error())
  2808. return err.Error()
  2809. }
  2810. str := string(respBytes)
  2811. fmt.Println(str)
  2812. return str
  2813. }
  2814. //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 {
  2815. // // 生成签名
  2816. // nonce := GetRandomString(32)
  2817. // timestamp := time.Now().Unix()
  2818. // signature := setSignature(timestamp, nonce, secret_key)
  2819. // tempTime := time.Unix(timestamp, 0)
  2820. // timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2821. //
  2822. // // 生成输入报文
  2823. // inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2824. // input := make(map[string]interface{})
  2825. // inputData := make(map[string]interface{})
  2826. // diseinfo := make([]map[string]interface{}, 0)
  2827. //
  2828. // inputMessage["infno"] = "2203" // 交易编码
  2829. // inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  2830. // inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  2831. // inputData["med_type"] = med_type // 医疗类别 16门诊特殊病
  2832. // inputData["begntime"] = timeFormatOne // 开始时间
  2833. // inputData["main_cond_dscr"] = "" // 主要病情描述
  2834. // inputData["dise_codg"] = sick_code // 病种编码
  2835. // inputData["dise_name"] = sick_name // 病种名称
  2836. // inputData["birctrl_type"] = "" // 计划生育手术类别
  2837. // inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
  2838. //
  2839. // diseinfo_sun := make(map[string]interface{})
  2840. // diseinfo_sun["diag_type"] = "1" // 诊断类别
  2841. // diseinfo_sun["diag_srt_no"] = "1" // 诊断排序号
  2842. // diseinfo_sun["diag_code"] = diag_code // 诊断代码
  2843. // diseinfo_sun["diag_name"] = diag // 诊断名称
  2844. // diseinfo_sun["diag_dept"] = department // 诊断科室
  2845. // diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
  2846. // diseinfo_sun["dise_dor_name"] = doctor // 诊断医生姓名
  2847. // diseinfo_sun["diag_time"] = timeFormatOne // 诊断时间
  2848. // diseinfo_sun["vali_flag"] = "1" // 有效标志
  2849. //
  2850. // diseinfo = append(diseinfo, diseinfo_sun)
  2851. // input["diseinfo"] = diseinfo
  2852. // input["mdtrtinfo"] = inputData
  2853. // inputMessage["input"] = input //交易输入
  2854. //
  2855. // bytesData, err := json.Marshal(inputMessage)
  2856. // fmt.Println(string(bytesData))
  2857. // if err != nil {
  2858. // fmt.Println(err.Error())
  2859. // return err.Error()
  2860. // }
  2861. // reader := bytes.NewReader(bytesData)
  2862. //
  2863. // url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2203"
  2864. //
  2865. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  2866. // request, err := http.NewRequest("POST", url, reader)
  2867. // if err != nil {
  2868. // fmt.Println(err.Error())
  2869. // return err.Error()
  2870. // }
  2871. //
  2872. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2873. // request.Header.Set("x-tif-paasid", "sg03_prd")
  2874. // request.Header.Set("x-tif-signature", signature)
  2875. // request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2876. // request.Header.Set("x-tif-nonce", nonce)
  2877. //
  2878. // client := http.Client{}
  2879. // resp, err := client.Do(request)
  2880. // if err != nil {
  2881. // fmt.Println(err.Error())
  2882. // return err.Error()
  2883. // }
  2884. // respBytes, err := ioutil.ReadAll(resp.Body)
  2885. // if err != nil {
  2886. // fmt.Println(err.Error())
  2887. // return err.Error()
  2888. // }
  2889. // str := string(respBytes)
  2890. // fmt.Println(str)
  2891. // return str
  2892. //}
  2893. 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 {
  2894. // 生成签名
  2895. nonce := GetRandomString(32)
  2896. timestamp := time.Now().Unix()
  2897. //timestamp := time.Now().UnixNano() / 1e6
  2898. signature := setSignature(timestamp, nonce, secret_key)
  2899. //tempTime := time.Unix(timestamp, 0)
  2900. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2901. //timeFormatTwo := tempTime.Format("2006-01-02")
  2902. inputMessage := make(map[string]interface{})
  2903. //tempTime := time.Unix(timestamp, 0)
  2904. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2905. // 生成输入报文
  2906. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  2907. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  2908. } else {
  2909. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2910. }
  2911. // 生成输入报文
  2912. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2913. input := make(map[string]interface{})
  2914. inputData := make(map[string]interface{})
  2915. inputMessage["infno"] = "5301" // 交易编码
  2916. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  2917. input["data"] = inputData
  2918. inputMessage["input"] = input //交易输入
  2919. bytesData, err := json.Marshal(inputMessage)
  2920. fmt.Println(string(bytesData))
  2921. if err != nil {
  2922. fmt.Println(err.Error())
  2923. return err.Error()
  2924. }
  2925. reader := bytes.NewReader(bytesData)
  2926. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  2927. gdyb_url := beego.AppConfig.String("gdyb_url")
  2928. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2929. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2930. var url string
  2931. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  2932. url = gdyb_url
  2933. } else {
  2934. url = gdyb_url + "5301"
  2935. }
  2936. request, err := http.NewRequest("POST", url, reader)
  2937. if err != nil {
  2938. fmt.Println(err.Error())
  2939. return err.Error()
  2940. }
  2941. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2942. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2943. request.Header.Set("x-tif-signature", signature)
  2944. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2945. request.Header.Set("x-tif-nonce", nonce)
  2946. client := http.Client{}
  2947. resp, err := client.Do(request)
  2948. if err != nil {
  2949. fmt.Println(err.Error())
  2950. return err.Error()
  2951. }
  2952. respBytes, err := ioutil.ReadAll(resp.Body)
  2953. if err != nil {
  2954. fmt.Println(err.Error())
  2955. return err.Error()
  2956. }
  2957. str := string(respBytes)
  2958. fmt.Println(str)
  2959. return str
  2960. }
  2961. func Gdyb5301Two(psnNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  2962. // 生成签名
  2963. nonce := GetRandomString(32)
  2964. timestamp := time.Now().Unix()
  2965. signature := setSignature(timestamp, nonce, secret_key)
  2966. //tempTime := time.Unix(timestamp, 0)
  2967. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2968. //timeFormatTwo := tempTime.Format("2006-01-02")
  2969. // 生成输入报文
  2970. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2971. input := make(map[string]interface{})
  2972. inputData := make(map[string]interface{})
  2973. inputMessage["infno"] = "5301" // 交易编码
  2974. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  2975. input["data"] = inputData
  2976. inputMessage["input"] = input //交易输入
  2977. bytesData, err := json.Marshal(inputMessage)
  2978. fmt.Println(string(bytesData))
  2979. if err != nil {
  2980. fmt.Println(err.Error())
  2981. return err.Error()
  2982. }
  2983. reader := bytes.NewReader(bytesData)
  2984. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  2985. gdyb_url := beego.AppConfig.String("gdyb_url")
  2986. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2987. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2988. url := gdyb_url
  2989. request, err := http.NewRequest("POST", url, reader)
  2990. if err != nil {
  2991. fmt.Println(err.Error())
  2992. return err.Error()
  2993. }
  2994. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2995. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2996. request.Header.Set("x-tif-signature", signature)
  2997. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2998. request.Header.Set("x-tif-nonce", nonce)
  2999. client := http.Client{}
  3000. resp, err := client.Do(request)
  3001. if err != nil {
  3002. fmt.Println(err.Error())
  3003. return err.Error()
  3004. }
  3005. respBytes, err := ioutil.ReadAll(resp.Body)
  3006. if err != nil {
  3007. fmt.Println(err.Error())
  3008. return err.Error()
  3009. }
  3010. str := string(respBytes)
  3011. fmt.Println(str)
  3012. return str
  3013. }
  3014. type CustomStruct struct {
  3015. FundPayType string
  3016. FundPayamt float64
  3017. }
  3018. type OpspdiseinfoStruct struct {
  3019. DiagName string
  3020. DiagCode string
  3021. OprnOprtName string
  3022. OprnOprtCode string
  3023. }
  3024. type DiaginfoStructTwo struct {
  3025. DiagType string
  3026. DiagCode string
  3027. DiagName string
  3028. MaindiagFlag string
  3029. }
  3030. type IteminfoStruct struct {
  3031. MedChrgitm string
  3032. Amt float64
  3033. ClaaSumfee float64
  3034. ClabAmt float64
  3035. FulamtOwnpayAmt float64
  3036. OthAmt float64
  3037. }
  3038. type Struct4101 struct {
  3039. PsnNo string
  3040. MdtrtId string
  3041. SetlId string
  3042. HiSetlLv string
  3043. PsnName string
  3044. Gend string
  3045. Brdy string
  3046. Ntly string
  3047. Naty string
  3048. PatnCertType string
  3049. Certno string
  3050. Prfs string
  3051. ConerName string
  3052. PatnRlts string
  3053. ConerAddr string
  3054. ConerTel string
  3055. HiType string
  3056. Insuplc string
  3057. AdmCaty string
  3058. DscgCaty string
  3059. MaindiagFlag string
  3060. BillCode string
  3061. BillNo string
  3062. BizSn string
  3063. SetlBegnDate string
  3064. SetlEndDate string
  3065. PsnSelfPay float64
  3066. PsnOwnPay float64
  3067. AcctPay float64
  3068. PsnCashpay float64
  3069. HiPaymtd string
  3070. Hsorg string
  3071. HsorgOpter string
  3072. MedinsFillDept string
  3073. MedinsFillPsn string
  3074. IptMedType string
  3075. Age int64
  3076. CustomStruct []CustomStruct
  3077. OpspdiseinfoStruct []OpspdiseinfoStruct
  3078. Diseinfo []DiaginfoStructTwo
  3079. IteminfoStruct []IteminfoStruct
  3080. AdmTime string
  3081. AdmEndTime string
  3082. HisNo string
  3083. DoctorName string
  3084. DoctorCode string
  3085. CurAddr string
  3086. }
  3087. 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) {
  3088. // 生成签名
  3089. nonce := GetRandomString(32)
  3090. timestamp := time.Now().Unix()
  3091. signature := setSignature(timestamp, nonce, secret_key)
  3092. inputMessage := make(map[string]interface{})
  3093. //tempTime := time.Unix(timestamp, 0)
  3094. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  3095. // 生成输入报文
  3096. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  3097. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  3098. } else {
  3099. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3100. }
  3101. // 生成输入报文
  3102. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3103. input := make(map[string]interface{})
  3104. inputData := make(map[string]interface{})
  3105. if org_id == 10106 || org_id == 10215 || org_id == 10138 || org_id == 9504 {
  3106. inputMessage["infno"] = "4101A" // 交易编码
  3107. } else {
  3108. inputMessage["infno"] = "4101A" // 交易编码
  3109. }
  3110. year := time.Now().Format("2006")
  3111. month := time.Now().Format("01")
  3112. day := time.Now().Format("02")
  3113. inputData["mdtrt_id"] = struct4101.MdtrtId // 就诊 ID 必填(来自2201接口返回)
  3114. inputData["setl_id"] = struct4101.SetlId // 结算 ID 必填
  3115. inputData["psn_no"] = struct4101.PsnNo // 结算 ID 必填
  3116. inputData["fixmedins_name"] = org_name // 定点医药机构名称 必填
  3117. inputData["fixmedins_code"] = fixmedins_code // 定点医药机构编码 必填
  3118. inputData["hi_setl_lv"] = "" // 医保结算等级
  3119. inputData["hi_no"] = struct4101.PsnNo // 医保编号
  3120. inputData["medcasno"] = struct4101.PsnNo // 病案号 必填
  3121. inputData["dcla_time"] = year + "-" + month + "-" + day // 申报时间 必填
  3122. inputData["psn_name"] = struct4101.PsnName // 人员姓名 必填
  3123. inputData["gend"] = struct4101.Gend // 性别 必填
  3124. inputData["brdy"] = struct4101.Brdy // 出生日期 必填
  3125. inputData["age"] = struct4101.Age // 年龄 必填
  3126. inputData["ntly"] = "CHN" // 国籍 必填
  3127. inputData["nwb_age"] = "" // 年龄 必填
  3128. inputData["naty"] = struct4101.Naty // 民族 必填
  3129. inputData["dscg_way"] = "9" // 民族 必填
  3130. //inputData["resp_nurs_code"] = "N441623001432" // 民族 必填
  3131. inputData["patn_cert_type"] = struct4101.PatnCertType // 患者证件类别 必填
  3132. inputData["certno"] = struct4101.Certno // 证件号码 必填
  3133. inputData["prfs"] = struct4101.Prfs // 职业 必填
  3134. inputData["curr_addr"] = "" // 现住址 必填
  3135. inputData["emp_name"] = "" // 单位名称 必填
  3136. inputData["emp_addr"] = "" // 单位地址 必填
  3137. inputData["emp_tel"] = "" // 单位电话 必填
  3138. inputData["poscode"] = "" // 邮编 必填
  3139. inputData["coner_name"] = struct4101.ConerName // 联系人姓名 必填
  3140. inputData["patn_rlts"] = struct4101.PatnRlts // 与患者关系 必填
  3141. inputData["coner_addr"] = struct4101.ConerAddr // 联系人地址 必填
  3142. inputData["coner_tel"] = struct4101.ConerTel // 联系人电话 必填
  3143. inputData["hi_type"] = struct4101.HiType // 医保类型 必填
  3144. inputData["insuplc"] = struct4101.Insuplc // 参保地 必填
  3145. inputData["sp_psn_type"] = "" // 特殊人员类型 必填
  3146. inputData["nwb_adm_type"] = "" // 新生儿入院类型 必填
  3147. inputData["nwb_bir_wt"] = "" // 新生儿出生体重 必填
  3148. inputData["nwb_adm_wt"] = "" // 新生儿入院体重 必填
  3149. inputData["opsp_diag_caty"] = "" // 门诊慢特病诊断 必填
  3150. inputData["opsp_mdtrt_date"] = "" // 门诊慢特病就诊日期 必填
  3151. inputData["ipt_med_type"] = "" // 住院医疗类型 必填
  3152. inputData["adm_way"] = "2" // 入院途径 必填
  3153. inputData["trt_type"] = "1" // 治疗类别 必填
  3154. inputData["adm_time"] = struct4101.SetlEndDate // 入院时间 必填
  3155. inputData["adm_caty"] = "A03.06" // 入院科别 必填
  3156. inputData["refldept_dept"] = "" // 转科科别 必填
  3157. inputData["dscg_time"] = struct4101.SetlBegnDate // 出院时间 必填
  3158. inputData["dscg_caty"] = "A03.06" // 出院科别 必填
  3159. inputData["caty"] = "A03.06" // 出院科别 必填
  3160. inputData["act_ipt_days"] = "" // 实际住院天数 必填
  3161. inputData["otp_wm_dise"] = "" // 门(急) 诊西医诊断 必填
  3162. inputData["wm_dise_code"] = "" // 门(急) 诊中医诊断 必填
  3163. inputData["otp_tcm_dise"] = "" // 西医诊断疾病代码 必填
  3164. inputData["tcm_dise_code"] = "" // 中医诊断代码 必填
  3165. inputData["oprn_oprt_code_cnt"] = "" // 手术操作代码计数 必填
  3166. inputData["vent_used_dura"] = "" // 呼吸机使用时长 必填
  3167. inputData["pwcry_bfadm_coma_dura"] = "" // 颅脑损伤患者入院前昏迷时长 必填
  3168. inputData["pwcry_afadm_coma_dura"] = "" // 颅脑损伤患者入院后昏迷时长 必填
  3169. inputData["bld_cat"] = "" // 输血品种 必填
  3170. inputData["bld_amt"] = "" // 输血量 必填
  3171. inputData["bld_unt"] = "" // 输血计量单位 必填
  3172. inputData["spga_nurscare_days"] = "" // 特级护理天数 必填
  3173. inputData["lv1_nurscare_days"] = "" // 一级护理天数 必填
  3174. inputData["scd_nurscare_days"] = "" // 二级护理天数 必填
  3175. inputData["lv3_nurscare_days"] = "" // 三级护理天数 必填
  3176. inputData["acp_medins_name"] = "" // 拟接收机构名称 必填
  3177. inputData["acp_optins_code"] = "" // 拟接收机构代码 必填
  3178. inputData["bill_code"] = struct4101.BillCode // 票据代码 必填
  3179. inputData["bill_no"] = struct4101.BillNo // 票据号码 必填
  3180. inputData["biz_sn"] = struct4101.BizSn // 业务流水号 必填
  3181. inputData["days_rinp_flag_31"] = "1" // 出院 31 天内再住院计划标志 必填
  3182. inputData["days_rinp_pup_31"] = "1" // 出院 31 天内再住院目的 必填
  3183. inputData["chfpdr_name"] = struct4101.DoctorName // 主诊医师姓名 必填
  3184. inputData["chfpdr_code"] = struct4101.DoctorCode // 主诊医师代码 必填
  3185. inputData["setl_begn_date"] = struct4101.SetlBegnDate // 结算开始日期 必填
  3186. inputData["setl_end_date"] = struct4101.SetlEndDate // 结算结束日期 必填
  3187. inputData["psn_selfpay"] = struct4101.PsnSelfPay // 个人自付 必填
  3188. inputData["psn_ownpay"] = struct4101.PsnOwnPay // 个人自费 必填
  3189. inputData["acct_pay"] = struct4101.AcctPay // 个人账户支出 必填
  3190. inputData["hi_paymtd"] = struct4101.HiPaymtd // 医保支付方式 必填
  3191. inputData["hsorg"] = struct4101.Hsorg // 医保机构 必填
  3192. inputData["hsorg_opter"] = struct4101.HsorgOpter // 医保机构经办人 必填
  3193. inputData["medins_fill_dept"] = struct4101.MedinsFillDept // 医疗机构填报部门 必填
  3194. inputData["medins_fill_psn"] = struct4101.MedinsFillPsn // 医疗机构填报人 必填
  3195. inputData["psn_cashpay"] = struct4101.PsnCashpay // 医疗机构填报人 必填
  3196. inputData["resp_nurs_code"] = "N440307016120" // 民族 必填
  3197. payinfo := make([]map[string]interface{}, 0) // 基金支付信息
  3198. for _, item := range struct4101.CustomStruct {
  3199. payinfotemp := make(map[string]interface{})
  3200. 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" {
  3201. payinfotemp["fund_pay_type"] = item.FundPayType // 基金支付类型 必填
  3202. payinfotemp["fund_payamt"] = item.FundPayamt // 基金支付金额
  3203. payinfo = append(payinfo, payinfotemp)
  3204. }
  3205. }
  3206. opspdiseinfo := make([]map[string]interface{}, 0) // 门诊慢特病诊断信息
  3207. opspdiseinfotemp := make(map[string]interface{})
  3208. opspdiseinfotemp["diag_name"] = "慢性肾功能不全(血透治疗)" // 诊断名称 必填
  3209. opspdiseinfotemp["diag_code"] = "N18.904" // 诊断代码 必填
  3210. opspdiseinfotemp["oprn_oprt_name"] = "血液透析" // 手术操作名称 必填
  3211. opspdiseinfotemp["oprn_oprt_code"] = "39.9500" // 手术操作代码 必填
  3212. opspdiseinfo = append(opspdiseinfo, opspdiseinfotemp)
  3213. diseinfo := make([]map[string]interface{}, 0) // 住院诊断信息
  3214. for _, item := range struct4101.Diseinfo {
  3215. diseinfotemp := make(map[string]interface{})
  3216. diseinfotemp["maindiag_flag"] = item.MaindiagFlag // 手术操作代码 必填
  3217. diseinfotemp["diag_type"] = item.DiagType // 诊断类别 必填
  3218. diseinfotemp["diag_code"] = item.DiagCode // 诊断代码 必填
  3219. diseinfotemp["diag_name"] = item.DiagName // 诊断名称 必填
  3220. diseinfotemp["adm_cond_type"] = "3" // 入院病情类型 必填
  3221. diseinfo = append(diseinfo, diseinfotemp)
  3222. }
  3223. oprninfo := make([]map[string]interface{}, 0) // 手术操作信息
  3224. oprninfotemp := make(map[string]interface{})
  3225. oprninfotemp["oprn_oprt_type"] = "" // 手术操作类别 必填
  3226. oprninfotemp["oprn_oprt_name"] = "" // 手术操作名称 必填
  3227. oprninfotemp["oprn_oprt_code"] = "" // 手术操作代码 必填
  3228. oprninfotemp["oprn_oprt_date"] = "" // 手术操作日期 必填
  3229. oprninfotemp["anst_way"] = "" // 麻醉方式 必填
  3230. oprninfotemp["oper_dr_name"] = "" // 术者医师姓名 必填
  3231. oprninfotemp["oper_dr_code"] = "" // 术者医师代码 必填
  3232. oprninfotemp["anst_dr_name"] = "" // 麻醉医师姓名 必填
  3233. oprninfotemp["anst_dr_code"] = "" // 麻醉医师代码 必填
  3234. oprninfo = append(oprninfo, oprninfotemp)
  3235. icuinfo := make([]map[string]interface{}, 0) // 重症监护信息
  3236. icuinfotemp := make(map[string]interface{})
  3237. icuinfotemp["scs_cutd_ward_type"] = "" // 重症监护病房类型 必填
  3238. icuinfotemp["scs_cutd_inpool_time"] = "" // 重症监护进入时间 必填
  3239. icuinfotemp["scs_cutd_exit_time"] = "" // 重症监护退出时间 必填
  3240. icuinfotemp["scs_cutd_sum_dura"] = "" // 重症监护合计时长 必填
  3241. icuinfo = append(icuinfo, icuinfotemp)
  3242. input["setlinfo"] = inputData
  3243. input["payinfo"] = payinfo
  3244. //input["opspdiseinfo"] = opspdiseinfo
  3245. input["diseinfo"] = diseinfo
  3246. inputMessage["input"] = input //交易输入
  3247. bytesData, err := json.Marshal(inputMessage)
  3248. fmt.Println(string(bytesData))
  3249. if err != nil {
  3250. fmt.Println(err.Error())
  3251. return err.Error(), ""
  3252. }
  3253. reader := bytes.NewReader(bytesData)
  3254. gdyb_url := beego.AppConfig.String("gdyb_url")
  3255. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3256. //url := gdyb_url + "4101"
  3257. var url string
  3258. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  3259. url = gdyb_url
  3260. //inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs,doctor)
  3261. } else {
  3262. //inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3263. url = gdyb_url + "4101A"
  3264. }
  3265. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/4101"
  3266. request, err := http.NewRequest("POST", url, reader)
  3267. if err != nil {
  3268. fmt.Println(err.Error())
  3269. return err.Error(), ""
  3270. }
  3271. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3272. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3273. request.Header.Set("x-tif-signature", signature)
  3274. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3275. request.Header.Set("x-tif-nonce", nonce)
  3276. client := http.Client{}
  3277. resp, err := client.Do(request)
  3278. if err != nil {
  3279. fmt.Println(err.Error())
  3280. return err.Error(), ""
  3281. }
  3282. respBytes, err := ioutil.ReadAll(resp.Body)
  3283. if err != nil {
  3284. fmt.Println(err.Error())
  3285. return err.Error(), ""
  3286. }
  3287. str := string(respBytes)
  3288. fmt.Println(str)
  3289. return str, string(bytesData)
  3290. }
  3291. 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) {
  3292. // 生成签名
  3293. nonce := GetRandomString(32)
  3294. timestamp := time.Now().Unix()
  3295. signature := setSignature(timestamp, nonce, secret_key)
  3296. inputMessage := make(map[string]interface{})
  3297. //tempTime := time.Unix(timestamp, 0)
  3298. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  3299. // 生成输入报文
  3300. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  3301. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  3302. } else {
  3303. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3304. }
  3305. // 生成输入报文
  3306. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3307. input := make(map[string]interface{})
  3308. inputData := make(map[string]interface{})
  3309. if org_id == 10106 || org_id == 10215 || org_id == 10138 || org_id == 9504 {
  3310. inputMessage["infno"] = "4101A" // 交易编码
  3311. } else {
  3312. inputMessage["infno"] = "4101A" // 交易编码
  3313. }
  3314. year := time.Now().Format("2006")
  3315. month := time.Now().Format("01")
  3316. day := time.Now().Format("02")
  3317. inputData["mdtrt_id"] = struct4101.MdtrtId // 就诊 ID 必填(来自2201接口返回)
  3318. inputData["setl_id"] = struct4101.SetlId // 结算 ID 必填
  3319. inputData["psn_no"] = struct4101.PsnNo // 结算 ID 必填
  3320. inputData["fixmedins_name"] = org_name // 定点医药机构名称 必填
  3321. inputData["fixmedins_code"] = fixmedins_code // 定点医药机构编码 必填
  3322. inputData["hi_setl_lv"] = "" // 医保结算等级
  3323. inputData["hi_no"] = struct4101.PsnNo // 医保编号
  3324. inputData["medcasno"] = struct4101.PsnNo // 病案号 必填
  3325. inputData["dcla_time"] = year + "-" + month + "-" + day // 申报时间 必填
  3326. inputData["psn_name"] = struct4101.PsnName // 人员姓名 必填
  3327. inputData["gend"] = struct4101.Gend // 性别 必填
  3328. inputData["brdy"] = struct4101.Brdy // 出生日期 必填
  3329. inputData["age"] = struct4101.Age // 年龄 必填
  3330. inputData["ntly"] = struct4101.Ntly // 国籍 必填
  3331. inputData["nwb_age"] = "" // 年龄 必填
  3332. inputData["naty"] = struct4101.Naty // 民族 必填
  3333. //inputData["dscg_way"] = "9" // 民族 必填
  3334. //inputData["resp_nurs_code"] = "N441623001432" // 民族 必填
  3335. inputData["patn_cert_type"] = struct4101.PatnCertType // 患者证件类别 必填
  3336. inputData["certno"] = struct4101.Certno // 证件号码 必填
  3337. inputData["prfs"] = struct4101.Prfs // 职业 必填
  3338. inputData["curr_addr"] = "" // 现住址 必填
  3339. inputData["emp_name"] = "" // 单位名称 必填
  3340. inputData["emp_addr"] = "" // 单位地址 必填
  3341. inputData["emp_tel"] = "" // 单位电话 必填
  3342. inputData["poscode"] = "" // 邮编 必填
  3343. inputData["coner_name"] = struct4101.ConerName // 联系人姓名 必填
  3344. inputData["patn_rlts"] = struct4101.PatnRlts // 与患者关系 必填
  3345. inputData["coner_addr"] = struct4101.ConerAddr // 联系人地址 必填
  3346. inputData["coner_tel"] = struct4101.ConerTel // 联系人电话 必填
  3347. inputData["hi_type"] = struct4101.HiType // 医保类型 必填
  3348. inputData["insuplc"] = struct4101.Insuplc // 参保地 必填
  3349. inputData["sp_psn_type"] = "" // 特殊人员类型 必填
  3350. inputData["nwb_adm_type"] = "" // 新生儿入院类型 必填
  3351. inputData["nwb_bir_wt"] = "" // 新生儿出生体重 必填
  3352. inputData["nwb_adm_wt"] = "" // 新生儿入院体重 必填
  3353. inputData["opsp_diag_caty"] = "" // 门诊慢特病诊断 必填
  3354. inputData["opsp_mdtrt_date"] = "" // 门诊慢特病就诊日期 必填
  3355. inputData["ipt_med_type"] = "" // 住院医疗类型 必填
  3356. inputData["adm_way"] = "" // 入院途径 必填
  3357. inputData["trt_type"] = "10" // 治疗类别 必填
  3358. inputData["adm_time"] = "" // 入院时间 必填
  3359. inputData["adm_caty"] = "A03.06" // 入院科别 必填
  3360. inputData["refldept_dept"] = "" // 转科科别 必填
  3361. inputData["dscg_time"] = "" // 出院时间 必填
  3362. inputData["dscg_caty"] = "A03.06" // 出院科别 必填
  3363. inputData["caty"] = "A03.06" // 出院科别 必填
  3364. inputData["act_ipt_days"] = "" // 实际住院天数 必填
  3365. inputData["otp_wm_dise"] = "" // 门(急) 诊西医诊断 必填
  3366. inputData["wm_dise_code"] = "" // 门(急) 诊中医诊断 必填
  3367. inputData["otp_tcm_dise"] = "" // 西医诊断疾病代码 必填
  3368. inputData["tcm_dise_code"] = "" // 中医诊断代码 必填
  3369. inputData["oprn_oprt_code_cnt"] = "" // 手术操作代码计数 必填
  3370. inputData["vent_used_dura"] = "" // 呼吸机使用时长 必填
  3371. inputData["pwcry_bfadm_coma_dura"] = "" // 颅脑损伤患者入院前昏迷时长 必填
  3372. inputData["pwcry_afadm_coma_dura"] = "" // 颅脑损伤患者入院后昏迷时长 必填
  3373. inputData["bld_cat"] = "" // 输血品种 必填
  3374. inputData["bld_amt"] = "" // 输血量 必填
  3375. inputData["bld_unt"] = "" // 输血计量单位 必填
  3376. inputData["spga_nurscare_days"] = "" // 特级护理天数 必填
  3377. inputData["lv1_nurscare_days"] = "" // 一级护理天数 必填
  3378. inputData["scd_nurscare_days"] = "" // 二级护理天数 必填
  3379. inputData["lv3_nurscare_days"] = "" // 三级护理天数 必填
  3380. inputData["acp_medins_name"] = "" // 拟接收机构名称 必填
  3381. inputData["acp_optins_code"] = "" // 拟接收机构代码 必填
  3382. inputData["bill_code"] = struct4101.BillCode // 票据代码 必填
  3383. inputData["bill_no"] = struct4101.BillNo // 票据号码 必填
  3384. inputData["biz_sn"] = struct4101.BizSn // 业务流水号 必填
  3385. inputData["days_rinp_flag_31"] = "" // 出院 31 天内再住院计划标志 必填
  3386. inputData["days_rinp_pup_31"] = "" // 出院 31 天内再住院目的 必填
  3387. inputData["chfpdr_name"] = struct4101.DoctorName // 主诊医师姓名 必填
  3388. inputData["chfpdr_code"] = struct4101.DoctorCode // 主诊医师代码 必填
  3389. inputData["setl_begn_date"] = struct4101.SetlBegnDate // 结算开始日期 必填
  3390. inputData["setl_end_date"] = struct4101.SetlEndDate // 结算结束日期 必填
  3391. inputData["psn_selfpay"] = struct4101.PsnSelfPay // 个人自付 必填
  3392. inputData["psn_ownpay"] = struct4101.PsnOwnPay // 个人自费 必填
  3393. inputData["acct_pay"] = struct4101.AcctPay // 个人账户支出 必填
  3394. inputData["hi_paymtd"] = struct4101.HiPaymtd // 医保支付方式 必填
  3395. inputData["hsorg"] = struct4101.Hsorg // 医保机构 必填
  3396. inputData["hsorg_opter"] = struct4101.HsorgOpter // 医保机构经办人 必填
  3397. inputData["medins_fill_dept"] = struct4101.MedinsFillDept // 医疗机构填报部门 必填
  3398. inputData["medins_fill_psn"] = struct4101.MedinsFillPsn // 医疗机构填报人 必填
  3399. inputData["psn_cashpay"] = struct4101.PsnCashpay // 医疗机构填报人 必填
  3400. inputData["dscg_way"] = "1" // 医疗机构填报人 必填
  3401. payinfo := make([]map[string]interface{}, 0) // 基金支付信息
  3402. for _, item := range struct4101.CustomStruct {
  3403. payinfotemp := make(map[string]interface{})
  3404. 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" {
  3405. payinfotemp["fund_pay_type"] = item.FundPayType // 基金支付类型 必填
  3406. payinfotemp["fund_payamt"] = item.FundPayamt // 基金支付金额
  3407. payinfo = append(payinfo, payinfotemp)
  3408. }
  3409. }
  3410. opspdiseinfo := make([]map[string]interface{}, 0) // 门诊慢特病诊断信息
  3411. opspdiseinfotemp := make(map[string]interface{})
  3412. opspdiseinfotemp["diag_name"] = "慢性肾功能不全(血透治疗)" // 诊断名称 必填
  3413. opspdiseinfotemp["diag_code"] = "N18.904" // 诊断代码 必填
  3414. opspdiseinfotemp["oprn_oprt_name"] = "血液透析" // 手术操作名称 必填
  3415. opspdiseinfotemp["oprn_oprt_code"] = "39.9500" // 手术操作代码 必填
  3416. opspdiseinfo = append(opspdiseinfo, opspdiseinfotemp)
  3417. diseinfo := make([]map[string]interface{}, 0) // 住院诊断信息
  3418. for _, item := range struct4101.Diseinfo {
  3419. diseinfotemp := make(map[string]interface{})
  3420. diseinfotemp["maindiag_flag"] = item.MaindiagFlag // 手术操作代码 必填
  3421. diseinfotemp["diag_type"] = item.DiagType // 诊断类别 必填
  3422. diseinfotemp["diag_code"] = item.DiagCode // 诊断代码 必填
  3423. diseinfotemp["diag_name"] = item.DiagName // 诊断名称 必填
  3424. diseinfotemp["adm_cond_type"] = "3" // 入院病情类型 必填
  3425. diseinfo = append(diseinfo, diseinfotemp)
  3426. }
  3427. oprninfo := make([]map[string]interface{}, 0) // 手术操作信息
  3428. oprninfotemp := make(map[string]interface{})
  3429. oprninfotemp["oprn_oprt_type"] = "" // 手术操作类别 必填
  3430. oprninfotemp["oprn_oprt_name"] = "" // 手术操作名称 必填
  3431. oprninfotemp["oprn_oprt_code"] = "" // 手术操作代码 必填
  3432. oprninfotemp["oprn_oprt_date"] = "" // 手术操作日期 必填
  3433. oprninfotemp["anst_way"] = "" // 麻醉方式 必填
  3434. oprninfotemp["oper_dr_name"] = "" // 术者医师姓名 必填
  3435. oprninfotemp["oper_dr_code"] = "" // 术者医师代码 必填
  3436. oprninfotemp["anst_dr_name"] = "" // 麻醉医师姓名 必填
  3437. oprninfotemp["anst_dr_code"] = "" // 麻醉医师代码 必填
  3438. oprninfo = append(oprninfo, oprninfotemp)
  3439. icuinfo := make([]map[string]interface{}, 0) // 重症监护信息
  3440. icuinfotemp := make(map[string]interface{})
  3441. icuinfotemp["scs_cutd_ward_type"] = "" // 重症监护病房类型 必填
  3442. icuinfotemp["scs_cutd_inpool_time"] = "" // 重症监护进入时间 必填
  3443. icuinfotemp["scs_cutd_exit_time"] = "" // 重症监护退出时间 必填
  3444. icuinfotemp["scs_cutd_sum_dura"] = "" // 重症监护合计时长 必填
  3445. icuinfo = append(icuinfo, icuinfotemp)
  3446. input["setlinfo"] = inputData
  3447. input["payinfo"] = payinfo
  3448. input["opspdiseinfo"] = opspdiseinfo
  3449. input["diseinfo"] = diseinfo
  3450. inputMessage["input"] = input //交易输入
  3451. bytesData, err := json.Marshal(inputMessage)
  3452. fmt.Println(string(bytesData))
  3453. if err != nil {
  3454. fmt.Println(err.Error())
  3455. return err.Error(), ""
  3456. }
  3457. reader := bytes.NewReader(bytesData)
  3458. gdyb_url := beego.AppConfig.String("gdyb_url")
  3459. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3460. //url := gdyb_url + "4101"
  3461. var url string
  3462. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  3463. url = gdyb_url
  3464. //inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs,doctor)
  3465. } else {
  3466. //inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3467. url = gdyb_url
  3468. }
  3469. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/4101"
  3470. request, err := http.NewRequest("POST", url, reader)
  3471. if err != nil {
  3472. fmt.Println(err.Error())
  3473. return err.Error(), ""
  3474. }
  3475. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3476. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3477. request.Header.Set("x-tif-signature", signature)
  3478. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3479. request.Header.Set("x-tif-nonce", nonce)
  3480. client := http.Client{}
  3481. resp, err := client.Do(request)
  3482. if err != nil {
  3483. fmt.Println(err.Error())
  3484. return err.Error(), ""
  3485. }
  3486. respBytes, err := ioutil.ReadAll(resp.Body)
  3487. if err != nil {
  3488. fmt.Println(err.Error())
  3489. return err.Error(), ""
  3490. }
  3491. str := string(respBytes)
  3492. fmt.Println(str)
  3493. return str, string(bytesData)
  3494. }
  3495. 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) {
  3496. // 生成签名
  3497. nonce := GetRandomString(32)
  3498. timestamp := time.Now().Unix()
  3499. signature := setSignature(timestamp, nonce, secret_key)
  3500. // 生成输入报文
  3501. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3502. input := make(map[string]interface{})
  3503. inputData := make(map[string]interface{})
  3504. inputMessage["infno"] = "4101A" // 交易编码
  3505. year := time.Now().Format("2006")
  3506. month := time.Now().Format("01")
  3507. day := time.Now().Format("02")
  3508. inputData["mdtrt_id"] = struct4101.MdtrtId // 就诊 ID 必填(来自2201接口返回)
  3509. inputData["setl_id"] = struct4101.SetlId // 结算 ID 必填
  3510. inputData["psn_no"] = struct4101.PsnNo // 结算 ID 必填
  3511. inputData["fixmedins_name"] = org_name // 定点医药机构名称 必填
  3512. inputData["fixmedins_code"] = fixmedins_code // 定点医药机构编码 必填
  3513. inputData["hi_setl_lv"] = "" // 医保结算等级
  3514. inputData["hi_no"] = struct4101.PsnNo // 医保编号
  3515. inputData["medcasno"] = struct4101.PsnNo // 病案号 必填
  3516. inputData["dcla_time"] = year + "-" + month + "-" + day // 申报时间 必填
  3517. inputData["psn_name"] = struct4101.PsnName // 人员姓名 必填
  3518. inputData["gend"] = struct4101.Gend // 性别 必填
  3519. inputData["brdy"] = struct4101.Brdy // 出生日期 必填
  3520. inputData["age"] = struct4101.Age // 年龄 必填
  3521. inputData["ntly"] = struct4101.Ntly // 国籍 必填
  3522. inputData["nwb_age"] = "" // 年龄 必填
  3523. inputData["naty"] = struct4101.Naty // 民族 必填
  3524. inputData["patn_cert_type"] = struct4101.PatnCertType // 患者证件类别 必填
  3525. inputData["certno"] = struct4101.Certno // 证件号码 必填
  3526. inputData["prfs"] = struct4101.Prfs // 职业 必填
  3527. inputData["curr_addr"] = "" // 现住址 必填
  3528. inputData["emp_name"] = "" // 单位名称 必填
  3529. inputData["emp_addr"] = "" // 单位地址 必填
  3530. inputData["emp_tel"] = "" // 单位电话 必填
  3531. inputData["poscode"] = "" // 邮编 必填
  3532. inputData["coner_name"] = struct4101.ConerName // 联系人姓名 必填
  3533. inputData["patn_rlts"] = struct4101.PatnRlts // 与患者关系 必填
  3534. inputData["coner_addr"] = struct4101.ConerAddr // 联系人地址 必填
  3535. inputData["coner_tel"] = struct4101.ConerTel // 联系人电话 必填
  3536. inputData["hi_type"] = struct4101.HiType // 医保类型 必填
  3537. inputData["insuplc"] = struct4101.Insuplc // 参保地 必填
  3538. inputData["sp_psn_type"] = "" // 特殊人员类型 必填
  3539. inputData["nwb_adm_type"] = "" // 新生儿入院类型 必填
  3540. inputData["nwb_bir_wt"] = "" // 新生儿出生体重 必填
  3541. inputData["nwb_adm_wt"] = "" // 新生儿入院体重 必填
  3542. inputData["opsp_diag_caty"] = "" // 门诊慢特病诊断 必填
  3543. inputData["opsp_mdtrt_date"] = "" // 门诊慢特病就诊日期 必填
  3544. inputData["ipt_med_type"] = "" // 住院医疗类型 必填
  3545. inputData["adm_way"] = "" // 入院途径 必填
  3546. inputData["trt_type"] = "10" // 治疗类别 必填
  3547. inputData["adm_time"] = struct4101.AdmTime // 入院时间 必填
  3548. inputData["adm_caty"] = struct4101.AdmCaty // 入院科别 必填
  3549. inputData["refldept_dept"] = "" // 转科科别 必填
  3550. inputData["dscg_time"] = struct4101.AdmEndTime // 出院时间 必填
  3551. inputData["dscg_caty"] = struct4101.DscgCaty // 出院科别 必填
  3552. inputData["act_ipt_days"] = "" // 实际住院天数 必填
  3553. inputData["otp_wm_dise"] = "" // 门(急) 诊西医诊断 必填
  3554. inputData["wm_dise_code"] = "" // 门(急) 诊中医诊断 必填
  3555. inputData["otp_tcm_dise"] = "" // 西医诊断疾病代码 必填
  3556. inputData["tcm_dise_code"] = "" // 中医诊断代码 必填
  3557. inputData["oprn_oprt_code_cnt"] = "" // 手术操作代码计数 必填
  3558. inputData["vent_used_dura"] = "" // 呼吸机使用时长 必填
  3559. inputData["pwcry_bfadm_coma_dura"] = "" // 颅脑损伤患者入院前昏迷时长 必填
  3560. inputData["pwcry_afadm_coma_dura"] = "" // 颅脑损伤患者入院后昏迷时长 必填
  3561. inputData["bld_cat"] = "" // 输血品种 必填
  3562. inputData["bld_amt"] = "" // 输血量 必填
  3563. inputData["bld_unt"] = "" // 输血计量单位 必填
  3564. inputData["spga_nurscare_days"] = "" // 特级护理天数 必填
  3565. inputData["lv1_nurscare_days"] = "" // 一级护理天数 必填
  3566. inputData["scd_nurscare_days"] = "" // 二级护理天数 必填
  3567. inputData["lv3_nurscare_days"] = "" // 三级护理天数 必填
  3568. inputData["acp_medins_name"] = "" // 拟接收机构名称 必填
  3569. inputData["acp_optins_code"] = "" // 拟接收机构代码 必填
  3570. inputData["bill_code"] = struct4101.BillCode // 票据代码 必填
  3571. inputData["bill_no"] = struct4101.BillNo // 票据号码 必填
  3572. inputData["biz_sn"] = struct4101.BizSn // 业务流水号 必填
  3573. inputData["days_rinp_flag_31"] = "" // 出院 31 天内再住院计划标志 必填
  3574. inputData["days_rinp_pup_31"] = "" // 出院 31 天内再住院目的 必填
  3575. inputData["chfpdr_name"] = struct4101.DoctorName // 主诊医师姓名 必填
  3576. inputData["chfpdr_code"] = struct4101.DoctorCode // 主诊医师代码 必填
  3577. inputData["setl_begn_date"] = struct4101.SetlBegnDate // 结算开始日期 必填
  3578. inputData["setl_end_date"] = struct4101.SetlEndDate // 结算结束日期 必填
  3579. inputData["psn_selfpay"] = struct4101.PsnSelfPay // 个人自付 必填
  3580. inputData["psn_ownpay"] = struct4101.PsnOwnPay // 个人自费 必填
  3581. inputData["acct_pay"] = struct4101.AcctPay // 个人账户支出 必填
  3582. inputData["hi_paymtd"] = struct4101.HiPaymtd // 医保支付方式 必填
  3583. inputData["hsorg"] = struct4101.Hsorg // 医保机构 必填
  3584. inputData["hsorg_opter"] = struct4101.HsorgOpter // 医保机构经办人 必填
  3585. inputData["medins_fill_dept"] = struct4101.MedinsFillDept // 医疗机构填报部门 必填
  3586. inputData["medins_fill_psn"] = struct4101.MedinsFillPsn // 医疗机构填报人 必填
  3587. inputData["psn_cashpay"] = struct4101.PsnCashpay // 医疗机构填报人 必填
  3588. payinfo := make([]map[string]interface{}, 0) // 基金支付信息
  3589. for _, item := range struct4101.CustomStruct {
  3590. payinfotemp := make(map[string]interface{})
  3591. 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" {
  3592. payinfotemp["fund_pay_type"] = item.FundPayType // 基金支付类型 必填
  3593. payinfotemp["fund_payamt"] = item.FundPayamt // 基金支付金额
  3594. payinfo = append(payinfo, payinfotemp)
  3595. }
  3596. }
  3597. opspdiseinfo := make([]map[string]interface{}, 0) // 门诊慢特病诊断信息
  3598. opspdiseinfotemp := make(map[string]interface{})
  3599. opspdiseinfotemp["diag_name"] = struct4101.Diseinfo[len(struct4101.Diseinfo)-1].DiagName // 诊断名称 必填
  3600. opspdiseinfotemp["diag_code"] = struct4101.Diseinfo[len(struct4101.Diseinfo)-1].DiagCode // 诊断代码 必填
  3601. opspdiseinfotemp["oprn_oprt_name"] = "血液透析" // 手术操作名称 必填
  3602. opspdiseinfotemp["oprn_oprt_code"] = "39.9500" // 手术操作代码 必填
  3603. opspdiseinfo = append(opspdiseinfo, opspdiseinfotemp)
  3604. diseinfo := make([]map[string]interface{}, 0) // 住院诊断信息
  3605. for _, item := range struct4101.Diseinfo {
  3606. diseinfotemp := make(map[string]interface{})
  3607. diseinfotemp["maindiag_flag"] = item.MaindiagFlag // 手术操作代码 必填
  3608. diseinfotemp["diag_type"] = item.DiagType // 诊断类别 必填
  3609. diseinfotemp["diag_code"] = item.DiagCode // 诊断代码 必填
  3610. diseinfotemp["diag_name"] = item.DiagName // 诊断名称 必填
  3611. diseinfotemp["adm_cond_type"] = "3" // 入院病情类型 必填
  3612. diseinfo = append(diseinfo, diseinfotemp)
  3613. }
  3614. iteminfo := make([]map[string]interface{}, 0)
  3615. for _, item := range struct4101.IteminfoStruct {
  3616. iteminfotemp := make(map[string]interface{})
  3617. iteminfotemp["med_chrgitm"] = item.MedChrgitm // 医疗收费项目 必填
  3618. iteminfotemp["amt"] = item.Amt // 金额 必填
  3619. iteminfotemp["claa_sumfee"] = item.ClaaSumfee // 甲类费用合计 必填
  3620. iteminfotemp["clab_amt"] = item.ClabAmt // 乙类金额 必填
  3621. iteminfotemp["fulamt_ownpay_amt"] = item.FulamtOwnpayAmt // 全自费金额 必填
  3622. iteminfotemp["oth_amt"] = item.OthAmt // 其他金额 必填
  3623. iteminfo = append(iteminfo, iteminfotemp)
  3624. }
  3625. oprninfo := make([]map[string]interface{}, 0) // 手术操作信息
  3626. oprninfotemp := make(map[string]interface{})
  3627. oprninfotemp["oprn_oprt_type"] = "" // 手术操作类别 必填
  3628. oprninfotemp["oprn_oprt_name"] = "" // 手术操作名称 必填
  3629. oprninfotemp["oprn_oprt_code"] = "" // 手术操作代码 必填
  3630. oprninfotemp["oprn_oprt_date"] = "" // 手术操作日期 必填
  3631. oprninfotemp["anst_way"] = "" // 麻醉方式 必填
  3632. oprninfotemp["oper_dr_name"] = "" // 术者医师姓名 必填
  3633. oprninfotemp["oper_dr_code"] = "" // 术者医师代码 必填
  3634. oprninfotemp["anst_dr_name"] = "" // 麻醉医师姓名 必填
  3635. oprninfotemp["anst_dr_code"] = "" // 麻醉医师代码 必填
  3636. oprninfo = append(oprninfo, oprninfotemp)
  3637. icuinfo := make([]map[string]interface{}, 0) // 重症监护信息
  3638. icuinfotemp := make(map[string]interface{})
  3639. icuinfotemp["scs_cutd_ward_type"] = "" // 重症监护病房类型 必填
  3640. icuinfotemp["scs_cutd_inpool_time"] = "" // 重症监护进入时间 必填
  3641. icuinfotemp["scs_cutd_exit_time"] = "" // 重症监护退出时间 必填
  3642. icuinfotemp["scs_cutd_sum_dura"] = "" // 重症监护合计时长 必填
  3643. icuinfo = append(icuinfo, icuinfotemp)
  3644. input["setlinfo"] = inputData
  3645. input["payinfo"] = payinfo
  3646. input["opspdiseinfo"] = opspdiseinfo
  3647. input["diseinfo"] = diseinfo
  3648. input["iteminfo"] = iteminfo
  3649. inputMessage["input"] = input //交易输入
  3650. bytesData, err := json.Marshal(inputMessage)
  3651. fmt.Println(string(bytesData))
  3652. if err != nil {
  3653. fmt.Println(err.Error())
  3654. return err.Error(), ""
  3655. }
  3656. reader := bytes.NewReader(bytesData)
  3657. gdyb_url := beego.AppConfig.String("gdyb_url")
  3658. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3659. //url := gdyb_url + "4101"
  3660. var url string
  3661. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  3662. url = gdyb_url
  3663. } else {
  3664. url = gdyb_url + "4101A"
  3665. }
  3666. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/4101"
  3667. request, err := http.NewRequest("POST", url, reader)
  3668. if err != nil {
  3669. fmt.Println(err.Error())
  3670. return err.Error(), ""
  3671. }
  3672. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3673. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3674. request.Header.Set("x-tif-signature", signature)
  3675. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3676. request.Header.Set("x-tif-nonce", nonce)
  3677. client := http.Client{}
  3678. resp, err := client.Do(request)
  3679. if err != nil {
  3680. fmt.Println(err.Error())
  3681. return err.Error(), ""
  3682. }
  3683. respBytes, err := ioutil.ReadAll(resp.Body)
  3684. if err != nil {
  3685. fmt.Println(err.Error())
  3686. return err.Error(), ""
  3687. }
  3688. str := string(respBytes)
  3689. fmt.Println(str)
  3690. return str, string(bytesData)
  3691. }
  3692. 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) {
  3693. // 生成签名
  3694. nonce := GetRandomString(32)
  3695. timestamp := time.Now().Unix()
  3696. signature := setSignature(timestamp, nonce, secret_key)
  3697. // 生成输入报文
  3698. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3699. input := make(map[string]interface{})
  3700. inputData := make(map[string]interface{})
  3701. inputMessage["infno"] = "4101A" // 交易编码
  3702. year := time.Now().Format("2006")
  3703. month := time.Now().Format("01")
  3704. day := time.Now().Format("02")
  3705. inputData["psn_no"] = struct4101.PsnNo // 结算 ID 必填
  3706. inputData["mdtrt_id"] = struct4101.MdtrtId // 就诊 ID 必填(来自2201接口返回)
  3707. inputData["setl_id"] = struct4101.SetlId // 结算 ID 必填
  3708. inputData["hi_no"] = struct4101.PsnNo // 医保编号
  3709. inputData["medcasno"] = struct4101.PsnNo // 病案号 必填
  3710. inputData["dcla_time"] = year + "-" + month + "-" + day // 申报时间 必填
  3711. inputData["ntly"] = struct4101.Ntly // 国籍 必填
  3712. inputData["prfs"] = struct4101.Prfs // 职业 必填
  3713. inputData["curr_addr"] = struct4101.CurAddr // 现住址 必填
  3714. inputData["emp_name"] = "" // 单位名称 必填
  3715. inputData["emp_addr"] = "" // 单位地址 必填
  3716. inputData["emp_tel"] = ""
  3717. inputData["poscode"] = "" // 邮编 必填
  3718. inputData["coner_name"] = "" // 联系人姓名 必填
  3719. inputData["patn_rlts"] = "" // 与患者关系 必填
  3720. inputData["coner_addr"] = "" // 联系人地址 必填
  3721. inputData["coner_tel"] = ""
  3722. inputData["nwb_adm_type"] = "" // 新生儿入院类型 必填
  3723. inputData["nwb_bir_wt"] = "" // 新生儿出生体重 必填
  3724. inputData["nwb_adm_wt"] = "" // 新生儿入院体重 必填
  3725. inputData["mul_nwb_bir_wt"] = "" // 新生儿入院体重 必填
  3726. inputData["mul_nwb_adm_wt"] = "" // 新生儿入院体重 必填
  3727. inputData["opsp_diag_caty"] = "" // 门诊慢特病诊断 必填
  3728. inputData["opsp_mdtrt_date"] = "" // 门诊慢特病就诊日期 必填
  3729. inputData["adm_way"] = "" // 入院途径 必填
  3730. inputData["trt_type"] = "" // 治疗类别 必填
  3731. inputData["adm_time"] = "" // 入院时间 必填
  3732. inputData["refldept_dept"] = "" // 转科科别 必填
  3733. inputData["dscg_time"] = "" // 出院时间 必填
  3734. inputData["dscg_caty"] = "" // 出院科别 必填
  3735. inputData["otp_wm_dise"] = "" // 门(急) 诊西医诊断 必填
  3736. inputData["wm_dise_code"] = "" // 门(急) 诊中医诊断 必填
  3737. inputData["otp_tcm_dise"] = "" // 西医诊断疾病代码 必填
  3738. inputData["tcm_dise_code"] = "" // 中医诊断代码 必填
  3739. inputData["vent_used_dura"] = "" // 呼吸机使用时长 必填
  3740. inputData["pwcry_bfadm_coma_dura"] = "" // 颅脑损伤患者入院前昏迷时长 必填
  3741. inputData["pwcry_afadm_coma_dura"] = "" // 颅脑损伤患者入院后昏迷时长 必填
  3742. inputData["spga_nurscare_days"] = "" // 特级护理天数 必填
  3743. inputData["lv1_nurscare_days"] = "" // 一级护理天数 必填
  3744. inputData["scd_nurscare_days"] = "" // 二级护理天数 必填
  3745. inputData["lv3_nurscare_days"] = "" // 三级护理天数 必填
  3746. inputData["acp_medins_name"] = "" // 拟接收机构名称 必填
  3747. inputData["acp_optins_code"] = "" // 拟接收机构代码 必填
  3748. inputData["bill_code"] = struct4101.BillCode // 票据代码 必填
  3749. inputData["bill_no"] = struct4101.BillNo // 票据号码 必填
  3750. inputData["biz_sn"] = struct4101.BizSn // 业务流水号 必填
  3751. inputData["hi_paymtd"] = "1" // 业务流水号 必填
  3752. inputData["days_rinp_flag_31"] = "" // 出院 31 天内再住院计划标志 必填
  3753. inputData["days_rinp_pup_31"] = "" // 出院 31 天内再住院目的 必填
  3754. //inputData["chfpdr_name"] = struct4101.DoctorName // 主诊医师姓名 必填
  3755. //inputData["chfpdr_code"] = struct4101.DoctorCode // 主诊医师代码 必填
  3756. inputData["setl_begn_date"] = struct4101.SetlBegnDate // 结算开始日期 必填
  3757. inputData["setl_end_date"] = struct4101.SetlEndDate // 结算结束日期 必填
  3758. inputData["medins_fill_dept"] = struct4101.MedinsFillDept // 医疗机构填报部门 必填
  3759. inputData["medins_fill_psn"] = struct4101.MedinsFillPsn // 医疗机构填报人 必填
  3760. //payinfo := make([]map[string]interface{}, 0) // 基金支付信息
  3761. //for _, item := range struct4101.CustomStruct {
  3762. // payinfotemp := make(map[string]interface{})
  3763. // 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" {
  3764. // payinfotemp["fund_pay_type"] = item.FundPayType // 基金支付类型 必填
  3765. // payinfotemp["fund_payamt"] = item.FundPayamt // 基金支付金额
  3766. // payinfo = append(payinfo, payinfotemp)
  3767. // }
  3768. //}
  3769. opspdiseinfo := make([]map[string]interface{}, 0) // 门诊慢特病诊断信息
  3770. opspdiseinfotemp := make(map[string]interface{})
  3771. opspdiseinfotemp["diag_name"] = "慢性肾脏病5期" // 诊断名称 必填
  3772. opspdiseinfotemp["diag_code"] = "N18.500" // 诊断代码 必填
  3773. opspdiseinfotemp["oprn_oprt_name"] = "血液透析" // 手术操作名称 必填
  3774. opspdiseinfotemp["oprn_oprt_code"] = "39.9500" // 手术操作代码 必填
  3775. opspdiseinfo = append(opspdiseinfo, opspdiseinfotemp)
  3776. diseinfo := make([]map[string]interface{}, 0) // 住院诊断信息
  3777. for _, item := range struct4101.Diseinfo {
  3778. diseinfotemp := make(map[string]interface{})
  3779. diseinfotemp["maindiag_flag"] = item.MaindiagFlag // 手术操作代码 必填
  3780. diseinfotemp["diag_type"] = item.DiagType // 诊断类别 必填
  3781. diseinfotemp["diag_code"] = item.DiagCode // 诊断代码 必填
  3782. diseinfotemp["diag_name"] = item.DiagName // 诊断名称 必填
  3783. diseinfotemp["adm_cond_type"] = "3" // 入院病情类型 必填
  3784. diseinfo = append(diseinfo, diseinfotemp)
  3785. }
  3786. //iteminfo := make([]map[string]interface{}, 0)
  3787. //for _, item := range struct4101.IteminfoStruct {
  3788. // iteminfotemp := make(map[string]interface{})
  3789. // iteminfotemp["med_chrgitm"] = item.MedChrgitm // 医疗收费项目 必填
  3790. // iteminfotemp["amt"] = item.Amt // 金额 必填
  3791. // iteminfotemp["claa_sumfee"] = item.ClaaSumfee // 甲类费用合计 必填
  3792. // iteminfotemp["clab_amt"] = item.ClabAmt // 乙类金额 必填
  3793. // iteminfotemp["fulamt_ownpay_amt"] = item.FulamtOwnpayAmt // 全自费金额 必填
  3794. // iteminfotemp["oth_amt"] = item.OthAmt // 其他金额 必填
  3795. // iteminfo = append(iteminfo, iteminfotemp)
  3796. //}
  3797. oprninfo := make([]map[string]interface{}, 0) // 手术操作信息
  3798. oprninfotemp := make(map[string]interface{})
  3799. oprninfotemp["oprn_oprt_type"] = "" // 手术操作类别 必填
  3800. oprninfotemp["oprn_oprt_name"] = "" // 手术操作名称 必填
  3801. oprninfotemp["oprn_oprt_code"] = "" // 手术操作代码 必填
  3802. oprninfotemp["oprn_oprt_date"] = "" // 手术操作日期 必填
  3803. oprninfotemp["anst_way"] = "" // 麻醉方式 必填
  3804. oprninfotemp["oper_dr_name"] = "" // 术者医师姓名 必填
  3805. oprninfotemp["oper_dr_code"] = "" // 术者医师代码 必填
  3806. oprninfotemp["anst_dr_name"] = "" // 麻醉医师姓名 必填
  3807. oprninfotemp["anst_dr_code"] = "" // 麻醉医师代码 必填
  3808. oprninfo = append(oprninfo, oprninfotemp)
  3809. icuinfo := make([]map[string]interface{}, 0) // 重症监护信息
  3810. icuinfotemp := make(map[string]interface{})
  3811. icuinfotemp["scs_cutd_ward_type"] = "" // 重症监护病房类型 必填
  3812. icuinfotemp["scs_cutd_inpool_time"] = "" // 重症监护进入时间 必填
  3813. icuinfotemp["scs_cutd_exit_time"] = "" // 重症监护退出时间 必填
  3814. icuinfotemp["scs_cutd_sum_dura"] = "" // 重症监护合计时长 必填
  3815. icuinfo = append(icuinfo, icuinfotemp)
  3816. input["setlinfo"] = inputData
  3817. input["opspdiseinfo"] = opspdiseinfo
  3818. //input["diseinfo"] = diseinfo
  3819. //input["oprninfo"] = payinfo
  3820. //input["icuinfo"] = payinfo
  3821. //input["bldinfo"] = payinfo
  3822. inputMessage["input"] = input //交易输入
  3823. bytesData, err := json.Marshal(inputMessage)
  3824. fmt.Println(string(bytesData))
  3825. if err != nil {
  3826. fmt.Println(err.Error())
  3827. return err.Error(), ""
  3828. }
  3829. reader := bytes.NewReader(bytesData)
  3830. gdyb_url := beego.AppConfig.String("gdyb_url")
  3831. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3832. //url := gdyb_url + "4101"
  3833. var url string
  3834. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  3835. url = gdyb_url
  3836. } else {
  3837. url = gdyb_url + "4101A"
  3838. }
  3839. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/4101"
  3840. request, err := http.NewRequest("POST", url, reader)
  3841. if err != nil {
  3842. fmt.Println(err.Error())
  3843. return err.Error(), ""
  3844. }
  3845. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3846. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3847. request.Header.Set("x-tif-signature", signature)
  3848. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3849. request.Header.Set("x-tif-nonce", nonce)
  3850. client := http.Client{}
  3851. resp, err := client.Do(request)
  3852. if err != nil {
  3853. fmt.Println(err.Error())
  3854. return err.Error(), ""
  3855. }
  3856. respBytes, err := ioutil.ReadAll(resp.Body)
  3857. if err != nil {
  3858. fmt.Println(err.Error())
  3859. return err.Error(), ""
  3860. }
  3861. str := string(respBytes)
  3862. fmt.Println(str)
  3863. return str, string(bytesData)
  3864. }
  3865. //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 {
  3866. // // 生成签名
  3867. // nonce := GetRandomString(32)
  3868. // timestamp := time.Now().Unix()
  3869. // signature := setSignature(timestamp, nonce, secret_key)
  3870. // tempTime := time.Unix(timestamp, 0)
  3871. // //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  3872. //
  3873. // timeFormatTwo := tempTime.Format("2006-01-02")
  3874. //
  3875. // t := time.Now()
  3876. // last := time.Date(t.Year(), time.December, 31, 0, 0, 0, 0, time.UTC)
  3877. // tm := time.Unix(last.Unix(), 0)
  3878. //
  3879. // // 生成输入报文
  3880. // inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3881. // input := make(map[string]interface{})
  3882. // inputData := make(map[string]interface{})
  3883. //
  3884. // inputData2 := make(map[string]interface{})
  3885. //
  3886. // inputMessage["infno"] = "7101" // 交易编码
  3887. // inputData["hosp_rxno"] = psnNo // 人员编号 (来自1101接口返回)
  3888. // inputData["init_rxno"] = insutype // 险种类型(来自1101接口返回)
  3889. // inputData["rx_type_code"] = sick_code // 险种类型(来自1101接口返回)
  3890. // inputData["prsc_time"] = sick_name // 险种类型(来自1101接口返回)
  3891. // inputData["rx_drug_nums"] = insuplc_admdvs // 险种类型(来自1101接口返回)
  3892. // inputData["rx_way_codg"] = fixmedins_code // 险种类型(来自1101接口返回)
  3893. // inputData["rx_way_name"] = org_name // 险种类型(来自1101接口返回)
  3894. // inputData["rx_freq_codg"] = timeFormatTwo // 险种类型(来自1101接口返回)
  3895. // inputData["rx_freq_name"] = doctor_id // 开始时间
  3896. // inputData["rx_dosunt"] = doctor // 开始时间
  3897. // inputData["rx_doscnt"] = timeFormatTwo // 医师编码
  3898. // inputData["rx_drord_dscr"] = "" // 医师编码
  3899. // inputData["valid_days"] = "" // 医师编码
  3900. // inputData["valid_end_time"] = tm.Format("2006-01-02") // 医师编码
  3901. // inputData["rept_flag"] = tm.Format("2006-01-02") // 医师编码
  3902. // inputData["max_rept_cnt"] = tm.Format("2006-01-02") // 医师编码
  3903. // inputData["reptd_cnt"] = tm.Format("2006-01-02") // 医师编码
  3904. // inputData["min_inrv_days"] = tm.Format("2006-01-02") // 医师编码
  3905. // inputData["dr_sign_info"] = tm.Format("2006-01-02") // 医师编码
  3906. // inputData["phar_sign_info"] = tm.Format("2006-01-02") // 医师编码
  3907. // inputData["fixmedins_sign_info"] = tm.Format("2006-01-02") // 医师编码
  3908. // inputData["rx_cotn_flag"] = tm.Format("2006-01-02") // 医师编码
  3909. // inputData["rx_file"] = tm.Format("2006-01-02") // 医师编码
  3910. // input["data"] = inputData
  3911. //
  3912. //
  3913. // inputData2["med_list_codg"] = psnNo // 人员编号 (来自1101接口返回)
  3914. // inputData2["fixmedins_hilist_id"] = insutype // 险种类型(来自1101接口返回)
  3915. // inputData["hosp_prep_flag"] = sick_code // 险种类型(来自1101接口返回)
  3916. // inputData["rx_item_type_code"] = sick_name // 险种类型(来自1101接口返回)
  3917. // inputData["rx_item_type_name"] = insuplc_admdvs // 险种类型(来自1101接口返回)
  3918. // inputData["tcmdrug_type_name"] = fixmedins_code // 险种类型(来自1101接口返回)
  3919. // inputData["tcmdrug_type_code"] = org_name // 险种类型(来自1101接口返回)
  3920. // inputData["tcmherb_foote"] = timeFormatTwo // 险种类型(来自1101接口返回)
  3921. // inputData["medn_type_code"] = doctor_id // 开始时间
  3922. // inputData["medn_type_name"] = doctor // 开始时间
  3923. // inputData["main_medc_flag"] = timeFormatTwo // 医师编码
  3924. // inputData["urgt_flag"] = "" // 医师编码
  3925. // inputData["bas_medn_flag"] = "" // 医师编码
  3926. // inputData["imp_drug_flag"] = tm.Format("2006-01-02") // 医师编码
  3927. // inputData["prod_barc"] = tm.Format("2006-01-02") // 医师编码
  3928. // inputData["drug_prodname"] = tm.Format("2006-01-02") // 医师编码
  3929. //
  3930. // inputData["genname_codg"] = tm.Format("2006-01-02") // 医师编码
  3931. // inputData["drug_genname"] = tm.Format("2006-01-02") // 医师编码
  3932. // inputData["chemname"] = tm.Format("2006-01-02") // 医师编码
  3933. //
  3934. // inputData["drugstdcode"] = tm.Format("2006-01-02") // 医师编码
  3935. // inputData["drug_dosform"] = tm.Format("2006-01-02") // 医师编码
  3936. //
  3937. //
  3938. // inputData["drug_spec"] = tm.Format("2006-01-02") // 医师编码
  3939. // inputData["prdr_name"] = tm.Format("2006-01-02") // 医师编码
  3940. //
  3941. //
  3942. // inputData["drug_pric"] = tm.Format("2006-01-02") // 医师编码
  3943. // inputData["drug_cnt"] = tm.Format("2006-01-02") // 医师编码
  3944. // inputData["drug_cnt_unit"] = tm.Format("2006-01-02") // 医师编码
  3945. // inputData["drug_sumamt"] = tm.Format("2006-01-02") // 医师编码
  3946. // inputData["medc_way_codg"] = tm.Format("2006-01-02") // 医师编码
  3947. // inputData["medc_way_dscr"] = tm.Format("2006-01-02") // 医师编码
  3948. // inputData["medc_starttime"] = tm.Format("2006-01-02") // 医师编码
  3949. //
  3950. // inputData["medc_endtime"] = tm.Format("2006-01-02") // 医师编码
  3951. //
  3952. //
  3953. // inputData["medc_days"] = tm.Format("2006-01-02") // 医师编码
  3954. // inputData["drug_dosunt"] = tm.Format("2006-01-02") // 医师编码
  3955. // inputData["sin_doscnt"] = tm.Format("2006-01-02") // 医师编码
  3956. // inputData["sin_dosunt"] = tm.Format("2006-01-02") // 医师编码
  3957. // inputData["used_frqu_codg"] = tm.Format("2006-01-02") // 医师编码
  3958. //
  3959. //
  3960. // inputData["used_frqu_name"] = tm.Format("2006-01-02") // 医师编码
  3961. // inputData["drug_totlnt"] = tm.Format("2006-01-02") // 医师编码
  3962. //
  3963. // inputData["drug_totlnt_emp"] = tm.Format("2006-01-02") // 医师编码
  3964. // inputData["dise_codg"] = tm.Format("2006-01-02") // 医师编码
  3965. // inputData["drug_res"] = tm.Format("2006-01-02") // 医师编码
  3966. // inputData["drug_limit"] = tm.Format("2006-01-02") // 医师编码
  3967. //
  3968. //
  3969. //
  3970. //
  3971. //
  3972. //
  3973. //
  3974. //
  3975. //
  3976. // input["rxdrugdetail"] = inputData2
  3977. //
  3978. //
  3979. //
  3980. //
  3981. // inputMessage["input"] = input //交易输入
  3982. // bytesData, err := json.Marshal(inputMessage)
  3983. // fmt.Println(string(bytesData))
  3984. // if err != nil {
  3985. // fmt.Println(err.Error())
  3986. // return err.Error()
  3987. // }
  3988. // reader := bytes.NewReader(bytesData)
  3989. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2503"
  3990. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2503"
  3991. // gdyb_url := beego.AppConfig.String("gdyb_url")
  3992. // gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3993. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  3994. // url := gdyb_url + "2503"
  3995. //
  3996. // request, err := http.NewRequest("POST", url, reader)
  3997. // if err != nil {
  3998. // fmt.Println(err.Error())
  3999. // return err.Error()
  4000. // }
  4001. //
  4002. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4003. // request.Header.Set("x-tif-paasid", gdyb_paasid)
  4004. // request.Header.Set("x-tif-signature", signature)
  4005. // request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4006. // request.Header.Set("x-tif-nonce", nonce)
  4007. //
  4008. // client := http.Client{}
  4009. // resp, err := client.Do(request)
  4010. // if err != nil {
  4011. // fmt.Println(err.Error())
  4012. // return err.Error()
  4013. // }
  4014. // respBytes, err := ioutil.ReadAll(resp.Body)
  4015. // if err != nil {
  4016. // fmt.Println(err.Error())
  4017. // return err.Error()
  4018. // }
  4019. // str := string(respBytes)
  4020. // fmt.Println(str)
  4021. // return str
  4022. //}
  4023. // 生成签名
  4024. func setSignature(timestamp int64, nonce string, secret_key string) string {
  4025. fmt.Println(timestamp)
  4026. fmt.Println(nonce)
  4027. fmt.Println(secret_key)
  4028. fmt.Println(strconv.FormatInt(timestamp, 10))
  4029. fmt.Println(time.Now().UnixNano() / 1e6)
  4030. str := strconv.FormatInt(timestamp, 10) + secret_key + nonce + strconv.FormatInt(timestamp, 10)
  4031. hash := sha256.New()
  4032. //输入数据
  4033. hash.Write([]byte(str))
  4034. //计算哈希值
  4035. bytes := hash.Sum(nil)
  4036. //将字符串编码为16进制格式,返回字符串
  4037. hashCode := hex.EncodeToString(bytes)
  4038. //返回哈希值
  4039. return hashCode
  4040. }
  4041. const charset = "abcdefghijklmnopqrstuvwxyz" +
  4042. "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
  4043. var seededRand *rand.Rand = rand.New(
  4044. rand.NewSource(time.Now().UnixNano()))
  4045. // 生成随机字符串
  4046. func GetRandomString(l int) string {
  4047. //str := "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
  4048. //bytes := []byte(str)
  4049. //result := []byte{}
  4050. //r := rand.New(rand.NewSource(time.Now().UnixNano()))
  4051. //for i := 0; i < l; i++ {
  4052. // result = append(result, bytes[r.Intn(len(bytes))])
  4053. //}
  4054. return String(32)
  4055. }
  4056. func StringWithCharset(length int, charset string) string {
  4057. b := make([]byte, length)
  4058. for i := range b {
  4059. b[i] = charset[seededRand.Intn(len(charset))]
  4060. }
  4061. return string(b)
  4062. }
  4063. func String(length int) string {
  4064. return StringWithCharset(length, charset)
  4065. }
  4066. // 生成基础报文
  4067. 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{} {
  4068. // 生成签名
  4069. tempTime := time.Unix(timestamp, 0)
  4070. //timeFormat := tempTime.Format("20060102150405")
  4071. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  4072. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  4073. month := time.Unix(1557042972, 0).Format("1")
  4074. year := time.Now().Format("2006")
  4075. month = time.Now().Format("01")
  4076. day := time.Now().Format("02")
  4077. hour := time.Now().Format("15")
  4078. min := time.Now().Format("04")
  4079. sec := time.Now().Format("05")
  4080. msec := time.Now().Format("000")
  4081. // 生成输入报文
  4082. inputMessage := make(map[string]interface{})
  4083. inputMessage["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  4084. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  4085. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  4086. inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  4087. inputMessage["dev_no"] = "" // 设备编号
  4088. inputMessage["dev_safe_info"] = "" // 设备安全信息
  4089. inputMessage["cainfo"] = "" // 数字签名信息
  4090. inputMessage["signtype"] = "MOCK" // 签名类型
  4091. inputMessage["infver"] = "V1.0" // 接收方系统代码
  4092. inputMessage["opter_type"] = "1" // 经办人类别
  4093. inputMessage["opter"] = doctor // 经办人
  4094. inputMessage["opter_name"] = op_name // 经办人姓名
  4095. inputMessage["inf_time"] = timeFormatOne // 交易时间
  4096. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  4097. inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  4098. if mdtrtarea_admvs == "440100" {
  4099. inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号
  4100. } else {
  4101. inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号 //交易签到流水号
  4102. }
  4103. return inputMessage
  4104. }
  4105. func SetInputMessage(nonce string, timestamp int64, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) map[string]interface{} {
  4106. // 生成签名
  4107. tempTime := time.Unix(timestamp, 0)
  4108. //timeFormat := tempTime.Format("20060102150405")
  4109. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  4110. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  4111. month := time.Unix(1557042972, 0).Format("1")
  4112. year := time.Now().Format("2006")
  4113. month = time.Now().Format("01")
  4114. day := time.Now().Format("02")
  4115. hour := time.Now().Format("15")
  4116. min := time.Now().Format("04")
  4117. sec := time.Now().Format("05")
  4118. msec := time.Now().Format("000")
  4119. // 生成输入报文
  4120. inputMessage := make(map[string]interface{})
  4121. inputMessage["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  4122. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  4123. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  4124. inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  4125. inputMessage["dev_no"] = "" // 设备编号
  4126. inputMessage["dev_safe_info"] = "" // 设备安全信息
  4127. inputMessage["cainfo"] = "" // 数字签名信息
  4128. inputMessage["signtype"] = "MOCK" // 签名类型
  4129. inputMessage["infver"] = "V1.0" // 接收方系统代码
  4130. inputMessage["opter_type"] = "1" // 经办人类别
  4131. inputMessage["opter"] = doctor // 经办人
  4132. inputMessage["opter_name"] = doctor // 经办人姓名
  4133. inputMessage["inf_time"] = timeFormatOne // 交易时间
  4134. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  4135. inputMessage["fixmedins_name"] = org_name
  4136. inputMessage["sign_no"] = "489925883" //交易签到流水号
  4137. //定点医药机构名称
  4138. //if mdtrtarea_admvs == "440100" {
  4139. // inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号
  4140. //} else {
  4141. // inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号 //交易签到流水号
  4142. //}
  4143. return inputMessage
  4144. }
  4145. func SetInputMessagenosign(nonce string, timestamp int64, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) map[string]interface{} {
  4146. // 生成签名
  4147. tempTime := time.Unix(timestamp, 0)
  4148. //timeFormat := tempTime.Format("20060102150405")
  4149. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  4150. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  4151. month := time.Unix(1557042972, 0).Format("1")
  4152. year := time.Now().Format("2006")
  4153. month = time.Now().Format("01")
  4154. day := time.Now().Format("02")
  4155. hour := time.Now().Format("15")
  4156. min := time.Now().Format("04")
  4157. sec := time.Now().Format("05")
  4158. msec := time.Now().Format("000")
  4159. // 生成输入报文
  4160. inputMessage := make(map[string]interface{})
  4161. inputMessage["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  4162. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  4163. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  4164. inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  4165. inputMessage["dev_no"] = "" // 设备编号
  4166. inputMessage["dev_safe_info"] = "" // 设备安全信息
  4167. inputMessage["cainfo"] = "" // 数字签名信息
  4168. inputMessage["signtype"] = "MOCK" // 签名类型
  4169. inputMessage["infver"] = "V1.0" // 接收方系统代码
  4170. inputMessage["opter_type"] = "1" // 经办人类别
  4171. inputMessage["opter"] = doctor // 经办人
  4172. inputMessage["opter_name"] = doctor // 经办人姓名
  4173. inputMessage["inf_time"] = timeFormatOne // 交易时间
  4174. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  4175. inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  4176. if mdtrtarea_admvs == "440100" {
  4177. inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号
  4178. } else {
  4179. inputMessage["sign_no"] = ""
  4180. }
  4181. return inputMessage
  4182. }
  4183. //func GetSignInInfo(code string) string {
  4184. // var sign models.HisSignIn
  4185. // err = readDb.Model(&models.HisSignIn{}).Where("fixmedins_code = ? AND status = 1", code).Last(&sign).Error
  4186. // return sign.SignNo
  4187. //}
  4188. 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{} {
  4189. // 生成签名
  4190. tempTime := time.Unix(timestamp, 0)
  4191. //timeFormat := tempTime.Format("20060102150405")
  4192. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  4193. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  4194. // 生成输入报文
  4195. inputMessage := make(map[string]interface{})
  4196. inputMessage["msgid"] = msg_id // 发送方报文 ID
  4197. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  4198. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  4199. inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  4200. inputMessage["dev_no"] = "" // 设备编号
  4201. inputMessage["dev_safe_info"] = "" // 设备安全信息
  4202. inputMessage["cainfo"] = "" // 数字签名信息
  4203. inputMessage["signtype"] = "SM3" // 签名类型
  4204. inputMessage["infver"] = "V1.0" // 接收方系统代码
  4205. inputMessage["opter_type"] = "1" // 经办人类别
  4206. inputMessage["opter"] = doctor // 经办人
  4207. inputMessage["opter_name"] = doctor // 经办人姓名
  4208. inputMessage["inf_time"] = timeFormatOne // 交易时间
  4209. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  4210. inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  4211. if mdtrtarea_admvs == "440100" {
  4212. inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号
  4213. } else {
  4214. inputMessage["sign_no"] = "" //交易签到流水号
  4215. }
  4216. return inputMessage
  4217. }
  4218. 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{} {
  4219. // 生成签名
  4220. tempTime := time.Unix(timestamp, 0)
  4221. //timeFormat := tempTime.Format("20060102150405")
  4222. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  4223. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  4224. month := time.Unix(1557042972, 0).Format("1")
  4225. year := time.Now().Format("2006")
  4226. month = time.Now().Format("01")
  4227. day := time.Now().Format("02")
  4228. hour := time.Now().Format("15")
  4229. min := time.Now().Format("04")
  4230. sec := time.Now().Format("05")
  4231. msec := time.Now().Format("000")
  4232. // 生成输入报文
  4233. inputMessage := make(map[string]interface{})
  4234. inputMessage["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  4235. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  4236. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  4237. inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  4238. inputMessage["dev_no"] = "" // 设备编号
  4239. inputMessage["dev_safe_info"] = "" // 设备安全信息
  4240. inputMessage["cainfo"] = "" // 数字签名信息
  4241. inputMessage["signtype"] = "SM3" // 签名类型
  4242. inputMessage["infver"] = "V1.0" // 接收方系统代码
  4243. inputMessage["opter_type"] = "1" // 经办人类别
  4244. inputMessage["opter"] = doctor // 经办人
  4245. inputMessage["opter_name"] = doctor // 经办人姓名
  4246. inputMessage["inf_time"] = timeFormatOne // 交易时间
  4247. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  4248. inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  4249. if mdtrtarea_admvs == "440100" {
  4250. inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号
  4251. } else {
  4252. inputMessage["sign_no"] = sign_no //交易签到流水号
  4253. }
  4254. return inputMessage
  4255. }
  4256. func postFile(filename string, target_url string) (*http.Response, error) {
  4257. body_buf := bytes.NewBufferString("")
  4258. body_writer := multipart.NewWriter(body_buf)
  4259. // use the body_writer to write the Part headers to the buffer
  4260. _, err := body_writer.CreateFormFile("userfile", filename)
  4261. if err != nil {
  4262. fmt.Println("error writing to buffer")
  4263. return nil, err
  4264. }
  4265. // the file data will be the second part of the body
  4266. fh, err := os.Open(filename)
  4267. if err != nil {
  4268. fmt.Println("error opening file")
  4269. return nil, err
  4270. }
  4271. // need to know the boundary to properly close the part myself.
  4272. boundary := body_writer.Boundary()
  4273. //close_string := fmt.Sprintf("\r\n--%s--\r\n", boundary)
  4274. close_buf := bytes.NewBufferString(fmt.Sprintf("\r\n--%s--\r\n", boundary))
  4275. // use multi-reader to defer the reading of the file data until
  4276. // writing to the socket buffer.
  4277. request_reader := io.MultiReader(body_buf, fh, close_buf)
  4278. fi, err := fh.Stat()
  4279. if err != nil {
  4280. fmt.Printf("Error Stating file: %s", filename)
  4281. return nil, err
  4282. }
  4283. req, err := http.NewRequest("POST", target_url, request_reader)
  4284. if err != nil {
  4285. return nil, err
  4286. }
  4287. // Set headers for multipart, and Content Length
  4288. req.Header.Add("Content-Type", "multipart/form-data; boundary="+boundary)
  4289. req.ContentLength = fi.Size() + int64(body_buf.Len()) + int64(close_buf.Len())
  4290. return http.DefaultClient.Do(req)
  4291. }
  4292. //func Gdyb1201(psnNo string, org_name string, doctor string) string {
  4293. // // 生成签名
  4294. // nonce := GetRandomString(32)
  4295. // timestamp := time.Now().Unix()
  4296. // signature := setSignature(timestamp, nonce)
  4297. //
  4298. // // 生成输入报文
  4299. // inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, "")
  4300. // input := make(map[string]interface{})
  4301. // inputData := make(map[string]interface{})
  4302. // inputMessage["infno"] = "1201" // 交易编码
  4303. // inputData["fixmedins_type"] = psnNo // 人员编号 (来自1101接口返回)
  4304. // inputData["fixmedins_name"] = org_name // 人员编号 (来自1101接口返回)
  4305. // inputData["fixmedins_code"] = "" // 人员编号 (来自1101接口返回)
  4306. //
  4307. // input["medinsinfo"] = inputData
  4308. // inputMessage["input"] = input //交易输入
  4309. //
  4310. // bytesData, err := json.Marshal(inputMessage)
  4311. // fmt.Println(string(bytesData))
  4312. // if err != nil {
  4313. // fmt.Println(err.Error())
  4314. // return err.Error()
  4315. // }
  4316. // reader := bytes.NewReader(bytesData)
  4317. //
  4318. // url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1201"
  4319. // request, err := http.NewRequest("POST", url, reader)
  4320. // if err != nil {
  4321. // fmt.Println(err.Error())
  4322. // return err.Error()
  4323. // }
  4324. //
  4325. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4326. // request.Header.Set("x-tif-paasid", "test_hosp")
  4327. // request.Header.Set("x-tif-signature", signature)
  4328. // request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4329. // request.Header.Set("x-tif-nonce", nonce)
  4330. //
  4331. // client := http.Client{}
  4332. // resp, err := client.Do(request)
  4333. // if err != nil {
  4334. // fmt.Println(err.Error())
  4335. // return err.Error()
  4336. // }
  4337. // respBytes, err := ioutil.ReadAll(resp.Body)
  4338. // if err != nil {
  4339. // fmt.Println(err.Error())
  4340. // return err.Error()
  4341. // }
  4342. // str := string(respBytes)
  4343. // fmt.Println(str)
  4344. // return str
  4345. //}
  4346. func newfileUploadRequest(uri string, params map[string]string, paramName, path string) (*http.Request, error) {
  4347. file, err := os.Open(path)
  4348. if err != nil {
  4349. return nil, err
  4350. }
  4351. defer file.Close()
  4352. body := &bytes.Buffer{}
  4353. writer := multipart.NewWriter(body)
  4354. part, err := writer.CreateFormFile(paramName, filepath.Base(path))
  4355. if err != nil {
  4356. return nil, err
  4357. }
  4358. _, err = io.Copy(part, file)
  4359. for key, val := range params {
  4360. _ = writer.WriteField(key, val)
  4361. }
  4362. err = writer.Close()
  4363. if err != nil {
  4364. return nil, err
  4365. }
  4366. req, err := http.NewRequest("POST", uri, body)
  4367. req.Header.Set("Content-Type", writer.FormDataContentType())
  4368. return req, err
  4369. }
  4370. func CreateMedicalInsuranceCostCompareRecord(record *models.MedicalInsuranceCostCompare) error {
  4371. err := writeDb.Save(&record).Error
  4372. return err
  4373. }
  4374. //func Gdyb5203(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  4375. // // 生成签名
  4376. // nonce := GetRandomString(32)
  4377. // timestamp := time.Now().Unix()
  4378. // signature := setSignature(timestamp, nonce, secret_key)
  4379. //
  4380. // // 生成输入报文
  4381. // inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4382. // input := make(map[string]interface{})
  4383. // inputData := make(map[string]interface{})
  4384. // inputMessage["infno"] = "5203" // 交易编码
  4385. //
  4386. // inputData["fixmedins_type"] = "1"
  4387. // inputData["fixmedins_name"] = org_name
  4388. // inputData["fixmedins_code"] = fixmedins_code
  4389. // input["medinsinfo"] = inputData
  4390. // inputMessage["input"] = input //交易输入
  4391. //
  4392. // bytesData, err := json.Marshal(inputMessage)
  4393. // fmt.Println(string(bytesData))
  4394. // if err != nil {
  4395. // fmt.Println(err.Error())
  4396. // return err.Error()
  4397. // }
  4398. // reader := bytes.NewReader(bytesData)
  4399. // url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1201"
  4400. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1201"
  4401. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4402. // request, err := http.NewRequest("POST", url, reader)
  4403. // if err != nil {
  4404. // fmt.Println(err.Error())
  4405. // return err.Error()
  4406. // }
  4407. //
  4408. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4409. // request.Header.Set("x-tif-paasid", "sg03_prd")
  4410. // request.Header.Set("x-tif-signature", signature)
  4411. // request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4412. // request.Header.Set("x-tif-nonce", nonce)
  4413. //
  4414. // client := http.Client{}
  4415. // resp, err := client.Do(request)
  4416. // if err != nil {
  4417. // fmt.Println(err.Error())
  4418. // return err.Error()
  4419. // }
  4420. // respBytes, err := ioutil.ReadAll(resp.Body)
  4421. // if err != nil {
  4422. // fmt.Println(err.Error())
  4423. // return err.Error()
  4424. // }
  4425. // fmt.Println(string(respBytes))
  4426. // str := string(respBytes)
  4427. // return str
  4428. //}
  4429. func CreatePsnRecord(record *models.GdybPsnRecord) {
  4430. writeDb.Save(&record)
  4431. return
  4432. }
  4433. func GetPsnRecordById(id int64) (record models.GdybPsnRecord, err error) {
  4434. err = readDb.Model(&models.GdybPsnRecord{}).Where("id = ?").First(&record).Error
  4435. return
  4436. }
  4437. func CreatePsnNCDSRecord(record *models.GdybPsnNcdsRecord) {
  4438. writeDb.Save(&record)
  4439. return
  4440. }
  4441. func GetPsnNCDSRecordById(id int64) (record models.GdybPsnNcdsRecord, err error) {
  4442. err = readDb.Model(&models.GdybPsnNcdsRecord{}).Where("id = ?", id).First(&record).Error
  4443. return
  4444. }
  4445. func GetPatientsByIds(ids []string, current_org_id int64) (patients []*models.Patients, err error) {
  4446. err = readDb.Model(&models.Patients{}).Where("id IN (?) AND user_org_id = ?", ids, current_org_id).Find(&patients).Error
  4447. return
  4448. }
  4449. 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 {
  4450. // 生成签名
  4451. nonce := GetRandomString(32)
  4452. timestamp := time.Now().Unix()
  4453. signature := setSignature(timestamp, nonce, secret_key)
  4454. // 生成输入报文
  4455. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4456. input := make(map[string]interface{})
  4457. inputData := make(map[string]interface{})
  4458. inputMessage["infno"] = "2601" // 交易编码
  4459. inputData["psn_no"] = psnNo
  4460. inputData["omsgid"] = omsgid
  4461. inputData["oinfno"] = oinfno
  4462. input["data"] = inputData
  4463. inputMessage["input"] = input //交易输入
  4464. bytesData, err := json.Marshal(inputMessage)
  4465. fmt.Println(string(bytesData))
  4466. if err != nil {
  4467. fmt.Println(err.Error())
  4468. return err.Error()
  4469. }
  4470. reader := bytes.NewReader(bytesData)
  4471. gdyb_url := beego.AppConfig.String("gdyb_url")
  4472. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4473. url := gdyb_url + "2601"
  4474. request, err := http.NewRequest("POST", url, reader)
  4475. if err != nil {
  4476. fmt.Println(err.Error())
  4477. return err.Error()
  4478. }
  4479. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4480. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4481. request.Header.Set("x-tif-signature", signature)
  4482. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4483. request.Header.Set("x-tif-nonce", nonce)
  4484. client := http.Client{}
  4485. resp, err := client.Do(request)
  4486. if err != nil {
  4487. fmt.Println(err.Error())
  4488. return err.Error()
  4489. }
  4490. respBytes, err := ioutil.ReadAll(resp.Body)
  4491. if err != nil {
  4492. fmt.Println(err.Error())
  4493. return err.Error()
  4494. }
  4495. str := string(respBytes)
  4496. fmt.Println(str)
  4497. return str
  4498. }
  4499. // 人员信息版本3
  4500. 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 {
  4501. //生成签名
  4502. nonce := GetRandomString(32)
  4503. timestamp := time.Now().Unix()
  4504. signature := setSignature(timestamp, nonce, secret_key)
  4505. //生成输入报文
  4506. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4507. inputMessage := make(map[string]interface{})
  4508. //生成输入报文
  4509. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  4510. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  4511. } else {
  4512. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4513. }
  4514. input := make(map[string]interface{})
  4515. inputData := make(map[string]interface{})
  4516. inputMessage["infno"] = "1101" // 交易编码
  4517. if certificates == 3 {
  4518. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  4519. inputData["certno"] = "01836483" // 证件号码
  4520. inputData["psn_cert_type"] = "01" // 人员证件类型
  4521. inputData["mdtrt_cert_no"] = "01836483" // 就诊凭证编号
  4522. } else {
  4523. if certificates == 1 {
  4524. if id_card_type == 1 {
  4525. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  4526. inputData["card_sn"] = card_sn // 卡识别码
  4527. inputData["certno"] = certNo // 证件号码
  4528. inputData["psn_cert_type"] = "01" // 人员证件类型
  4529. inputData["mdtrt_cert_no"] = cardNumber // 就诊凭证编号
  4530. } else {
  4531. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  4532. inputData["card_sn"] = "" // 卡识别码
  4533. inputData["certno"] = certNo // 证件号码
  4534. inputData["psn_cert_type"] = "01" // 人员证件类型
  4535. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  4536. }
  4537. } else if certificates == 6 {
  4538. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  4539. inputData["card_sn"] = "" // 卡识别码
  4540. inputData["certno"] = certNo // 证件号码
  4541. inputData["psn_cert_type"] = "17" // 人员证件类型
  4542. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  4543. }
  4544. }
  4545. inputData["begntime"] = "" // 开始时间
  4546. inputData["psn_name"] = name // 人员姓名
  4547. input["data"] = inputData
  4548. inputMessage["input"] = input //交易输入
  4549. bytesData, err := json.Marshal(inputMessage)
  4550. fmt.Println(string(bytesData))
  4551. if err != nil {
  4552. fmt.Println(err.Error())
  4553. return err.Error()
  4554. }
  4555. reader := bytes.NewReader(bytesData)
  4556. gdyb_url := beego.AppConfig.String("gdyb_url")
  4557. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4558. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4559. //url := gdyb_url + "1101"
  4560. var url string
  4561. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  4562. url = gdyb_url
  4563. } else {
  4564. url = gdyb_url + "1101"
  4565. }
  4566. fmt.Println(url)
  4567. fmt.Println(gdyb_paasid)
  4568. fmt.Println(secret_key)
  4569. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4570. request, err := http.NewRequest("POST", url, reader)
  4571. if err != nil {
  4572. fmt.Println(err.Error())
  4573. return err.Error()
  4574. }
  4575. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4576. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4577. request.Header.Set("x-tif-signature", signature)
  4578. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4579. request.Header.Set("x-tif-nonce", nonce)
  4580. client := http.Client{}
  4581. resp, err := client.Do(request)
  4582. if err != nil {
  4583. fmt.Println(err.Error())
  4584. return err.Error()
  4585. }
  4586. respBytes, err := ioutil.ReadAll(resp.Body)
  4587. if err != nil {
  4588. fmt.Println(err.Error())
  4589. return err.Error()
  4590. }
  4591. fmt.Println(string(respBytes))
  4592. str := string(respBytes)
  4593. return str
  4594. }
  4595. 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 {
  4596. //生成签名
  4597. nonce := GetRandomString(32)
  4598. timestamp := time.Now().Unix()
  4599. signature := setSignature(timestamp, nonce, secret_key)
  4600. inputMessage := make(map[string]interface{})
  4601. //生成输入报文
  4602. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  4603. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  4604. } else {
  4605. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4606. }
  4607. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4608. input := make(map[string]interface{})
  4609. inputData := make(map[string]interface{})
  4610. inputMessage["infno"] = "1101" // 交易编码
  4611. if certificates == 3 {
  4612. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  4613. inputData["certno"] = "01836483" // 证件号码
  4614. inputData["psn_cert_type"] = "01" // 人员证件类型
  4615. inputData["mdtrt_cert_no"] = "01836483" // 就诊凭证编号
  4616. } else {
  4617. if certificates == 1 {
  4618. if id_card_type == 4 {
  4619. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  4620. inputData["card_sn"] = card_sn // 卡识别码
  4621. inputData["certno"] = certNo // 证件号码
  4622. inputData["psn_cert_type"] = "01" // 人员证件类型
  4623. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  4624. }
  4625. } else if certificates == 6 {
  4626. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  4627. inputData["card_sn"] = "" // 卡识别码
  4628. inputData["certno"] = certNo // 证件号码
  4629. inputData["psn_cert_type"] = "17" // 人员证件类型
  4630. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  4631. }
  4632. }
  4633. inputData["begntime"] = "" // 开始时间
  4634. inputData["psn_name"] = name // 人员姓名
  4635. input["data"] = inputData
  4636. inputMessage["input"] = input //交易输入
  4637. bytesData, err := json.Marshal(inputMessage)
  4638. fmt.Println(string(bytesData))
  4639. if err != nil {
  4640. fmt.Println(err.Error())
  4641. return err.Error()
  4642. }
  4643. reader := bytes.NewReader(bytesData)
  4644. gdyb_url := beego.AppConfig.String("gdyb_url")
  4645. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4646. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4647. //url := gdyb_url + "1101"
  4648. var url string
  4649. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  4650. url = gdyb_url
  4651. } else {
  4652. url = gdyb_url + "1101"
  4653. }
  4654. fmt.Println(url)
  4655. fmt.Println(gdyb_paasid)
  4656. fmt.Println(secret_key)
  4657. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4658. request, err := http.NewRequest("POST", url, reader)
  4659. if err != nil {
  4660. fmt.Println(err.Error())
  4661. return err.Error()
  4662. }
  4663. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4664. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4665. request.Header.Set("x-tif-signature", signature)
  4666. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4667. request.Header.Set("x-tif-nonce", nonce)
  4668. client := http.Client{}
  4669. resp, err := client.Do(request)
  4670. if err != nil {
  4671. fmt.Println(err.Error())
  4672. return err.Error()
  4673. }
  4674. respBytes, err := ioutil.ReadAll(resp.Body)
  4675. if err != nil {
  4676. fmt.Println(err.Error())
  4677. return err.Error()
  4678. }
  4679. fmt.Println(string(respBytes))
  4680. str := string(respBytes)
  4681. return str
  4682. }
  4683. 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 {
  4684. //生成签名
  4685. nonce := GetRandomString(32)
  4686. timestamp := time.Now().Unix()
  4687. signature := setSignature(timestamp, nonce, secret_key)
  4688. //生成输入报文
  4689. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4690. input := make(map[string]interface{})
  4691. inputData := make(map[string]interface{})
  4692. inputMessage["infno"] = "1101" // 交易编码
  4693. if certificates == 3 {
  4694. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  4695. inputData["certno"] = "01836483" // 证件号码
  4696. inputData["psn_cert_type"] = "01" // 人员证件类型
  4697. inputData["mdtrt_cert_no"] = "01836483" // 就诊凭证编号
  4698. } else {
  4699. if certificates == 1 {
  4700. if id_card_type == 1 {
  4701. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  4702. inputData["card_sn"] = "" // 卡识别码
  4703. inputData["certno"] = certNo // 证件号码
  4704. inputData["psn_cert_type"] = "01" // 人员证件类型
  4705. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  4706. } else {
  4707. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  4708. inputData["card_sn"] = "" // 卡识别码
  4709. inputData["certno"] = certNo // 证件号码
  4710. inputData["psn_cert_type"] = "" // 人员证件类型
  4711. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  4712. }
  4713. } else if certificates == 6 {
  4714. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  4715. inputData["card_sn"] = "" // 卡识别码
  4716. inputData["certno"] = certNo // 证件号码
  4717. inputData["psn_cert_type"] = "" // 人员证件类型
  4718. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  4719. }
  4720. }
  4721. inputData["begntime"] = "" // 开始时间
  4722. inputData["psn_name"] = "" // 人员姓名
  4723. input["data"] = inputData
  4724. inputMessage["input"] = input //交易输入
  4725. bytesData, err := json.Marshal(inputMessage)
  4726. fmt.Println(string(bytesData))
  4727. if err != nil {
  4728. fmt.Println(err.Error())
  4729. return err.Error()
  4730. }
  4731. reader := bytes.NewReader(bytesData)
  4732. gdyb_url := beego.AppConfig.String("gdyb_url")
  4733. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4734. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4735. //url := gdyb_url + "1101"
  4736. var url string
  4737. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  4738. url = gdyb_url
  4739. } else {
  4740. url = gdyb_url + "1101"
  4741. }
  4742. fmt.Println(url)
  4743. fmt.Println(gdyb_paasid)
  4744. fmt.Println(secret_key)
  4745. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4746. request, err := http.NewRequest("POST", url, reader)
  4747. if err != nil {
  4748. fmt.Println(err.Error())
  4749. return err.Error()
  4750. }
  4751. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4752. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4753. request.Header.Set("x-tif-signature", signature)
  4754. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4755. request.Header.Set("x-tif-nonce", nonce)
  4756. client := http.Client{}
  4757. resp, err := client.Do(request)
  4758. if err != nil {
  4759. fmt.Println(err.Error())
  4760. return err.Error()
  4761. }
  4762. respBytes, err := ioutil.ReadAll(resp.Body)
  4763. if err != nil {
  4764. fmt.Println(err.Error())
  4765. return err.Error()
  4766. }
  4767. fmt.Println(string(respBytes))
  4768. str := string(respBytes)
  4769. return str
  4770. }
  4771. 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 {
  4772. //生成签名
  4773. nonce := GetRandomString(32)
  4774. timestamp := time.Now().Unix()
  4775. signature := setSignature(timestamp, nonce, secret_key)
  4776. //生成输入报文
  4777. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4778. input := make(map[string]interface{})
  4779. inputData := make(map[string]interface{})
  4780. inputMessage["infno"] = "1101" // 交易编码
  4781. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  4782. inputData["card_sn"] = card_sn // 卡识别码
  4783. inputData["certno"] = certNo // 证件号码
  4784. inputData["psn_cert_type"] = "01" // 人员证件类型
  4785. inputData["mdtrt_cert_no"] = cardNumber // 就诊凭证编号
  4786. inputData["begntime"] = "" // 开始时间
  4787. inputData["psn_name"] = name // 人员姓名
  4788. input["data"] = inputData
  4789. inputMessage["input"] = input //交易输入
  4790. bytesData, err := json.Marshal(inputMessage)
  4791. fmt.Println(string(bytesData))
  4792. if err != nil {
  4793. fmt.Println(err.Error())
  4794. return err.Error()
  4795. }
  4796. reader := bytes.NewReader(bytesData)
  4797. gdyb_url := beego.AppConfig.String("gdyb_url")
  4798. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4799. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4800. //url := gdyb_url + "1101"
  4801. var url string
  4802. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  4803. url = gdyb_url
  4804. } else {
  4805. url = gdyb_url + "1101"
  4806. }
  4807. fmt.Println(url)
  4808. fmt.Println(gdyb_paasid)
  4809. fmt.Println(secret_key)
  4810. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4811. request, err := http.NewRequest("POST", url, reader)
  4812. if err != nil {
  4813. fmt.Println(err.Error())
  4814. return err.Error()
  4815. }
  4816. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4817. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4818. request.Header.Set("x-tif-signature", signature)
  4819. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4820. request.Header.Set("x-tif-nonce", nonce)
  4821. client := http.Client{}
  4822. resp, err := client.Do(request)
  4823. if err != nil {
  4824. fmt.Println(err.Error())
  4825. return err.Error()
  4826. }
  4827. respBytes, err := ioutil.ReadAll(resp.Body)
  4828. if err != nil {
  4829. fmt.Println(err.Error())
  4830. return err.Error()
  4831. }
  4832. fmt.Println(string(respBytes))
  4833. str := string(respBytes)
  4834. return str
  4835. }
  4836. 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) {
  4837. //生成签名
  4838. nonce := GetRandomString(32)
  4839. timestamp := time.Now().Unix()
  4840. signature := setSignature(timestamp, nonce, secret_key)
  4841. //生成输入报文
  4842. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4843. input := make(map[string]interface{})
  4844. inputData := make(map[string]interface{})
  4845. inputMessage["infno"] = "1101" // 交易编码
  4846. if certificates == 6 {
  4847. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  4848. inputData["psn_cert_type"] = "" // 人员证件类型
  4849. } else {
  4850. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  4851. inputData["psn_cert_type"] = "01" // 人员证件类型
  4852. }
  4853. inputData["card_sn"] = "" // 卡识别码
  4854. inputData["certno"] = idNo // 证件号码
  4855. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  4856. inputData["begntime"] = "" // 开始时间
  4857. inputData["psn_name"] = user_name // 人员姓名
  4858. input["data"] = inputData
  4859. inputMessage["input"] = input //交易输入
  4860. bytesData, err := json.Marshal(inputMessage)
  4861. fmt.Println(string(bytesData))
  4862. if err != nil {
  4863. fmt.Println(err.Error())
  4864. return err.Error(), ""
  4865. }
  4866. reader := bytes.NewReader(bytesData)
  4867. gdyb_url := beego.AppConfig.String("gdyb_url")
  4868. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4869. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4870. //url := gdyb_url + "1101"
  4871. var url string
  4872. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  4873. url = gdyb_url
  4874. } else {
  4875. url = gdyb_url + "1101"
  4876. }
  4877. fmt.Println(url)
  4878. fmt.Println(gdyb_paasid)
  4879. fmt.Println(secret_key)
  4880. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4881. request, err := http.NewRequest("POST", url, reader)
  4882. if err != nil {
  4883. fmt.Println(err.Error())
  4884. return err.Error(), ""
  4885. }
  4886. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4887. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4888. request.Header.Set("x-tif-signature", signature)
  4889. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4890. request.Header.Set("x-tif-nonce", nonce)
  4891. client := http.Client{}
  4892. resp, err := client.Do(request)
  4893. if err != nil {
  4894. fmt.Println(err.Error())
  4895. return err.Error(), ""
  4896. }
  4897. respBytes, err := ioutil.ReadAll(resp.Body)
  4898. if err != nil {
  4899. fmt.Println(err.Error())
  4900. return err.Error(), ""
  4901. }
  4902. fmt.Println(string(respBytes))
  4903. str := string(respBytes)
  4904. return str, string(bytesData)
  4905. }
  4906. 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) {
  4907. //生成签名
  4908. nonce := GetRandomString(32)
  4909. timestamp := time.Now().Unix()
  4910. signature := setSignature(timestamp, nonce, secret_key)
  4911. //生成输入报文
  4912. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4913. input := make(map[string]interface{})
  4914. inputData := make(map[string]interface{})
  4915. inputMessage["infno"] = "1101" // 交易编码
  4916. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  4917. inputData["psn_cert_type"] = "01" // 人员证件类型
  4918. inputData["card_sn"] = "" // 卡识别码
  4919. inputData["certno"] = idNo // 证件号码
  4920. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  4921. inputData["begntime"] = "" // 开始时间
  4922. inputData["psn_name"] = user_name // 人员姓名
  4923. input["data"] = inputData
  4924. inputMessage["input"] = input //交易输入
  4925. bytesData, err := json.Marshal(inputMessage)
  4926. fmt.Println(string(bytesData))
  4927. if err != nil {
  4928. fmt.Println(err.Error())
  4929. return err.Error(), ""
  4930. }
  4931. reader := bytes.NewReader(bytesData)
  4932. gdyb_url := beego.AppConfig.String("gdyb_url")
  4933. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4934. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4935. //url := gdyb_url + "1101"
  4936. var url string
  4937. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  4938. url = gdyb_url
  4939. } else {
  4940. url = gdyb_url + "1101"
  4941. }
  4942. fmt.Println(url)
  4943. fmt.Println(gdyb_paasid)
  4944. fmt.Println(secret_key)
  4945. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4946. request, err := http.NewRequest("POST", url, reader)
  4947. if err != nil {
  4948. fmt.Println(err.Error())
  4949. return err.Error(), ""
  4950. }
  4951. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4952. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4953. request.Header.Set("x-tif-signature", signature)
  4954. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4955. request.Header.Set("x-tif-nonce", nonce)
  4956. client := http.Client{}
  4957. resp, err := client.Do(request)
  4958. if err != nil {
  4959. fmt.Println(err.Error())
  4960. return err.Error(), ""
  4961. }
  4962. respBytes, err := ioutil.ReadAll(resp.Body)
  4963. if err != nil {
  4964. fmt.Println(err.Error())
  4965. return err.Error(), ""
  4966. }
  4967. fmt.Println(string(respBytes))
  4968. str := string(respBytes)
  4969. return str, string(bytesData)
  4970. }
  4971. 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) {
  4972. //生成签名
  4973. nonce := GetRandomString(32)
  4974. timestamp := time.Now().Unix()
  4975. signature := setSignature(timestamp, nonce, secret_key)
  4976. //生成输入报文
  4977. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4978. input := make(map[string]interface{})
  4979. inputData := make(map[string]interface{})
  4980. inputMessage["infno"] = "1101" // 交易编码
  4981. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  4982. inputData["card_sn"] = "" // 卡识别码
  4983. inputData["certno"] = idNo // 证件号码
  4984. inputData["psn_cert_type"] = "01" // 人员证件类型
  4985. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  4986. inputData["begntime"] = "" // 开始时间
  4987. inputData["psn_name"] = user_name // 人员姓名
  4988. input["data"] = inputData
  4989. inputMessage["input"] = input //交易输入
  4990. bytesData, err := json.Marshal(inputMessage)
  4991. fmt.Println(string(bytesData))
  4992. if err != nil {
  4993. fmt.Println(err.Error())
  4994. return err.Error(), ""
  4995. }
  4996. reader := bytes.NewReader(bytesData)
  4997. gdyb_url := beego.AppConfig.String("gdyb_url")
  4998. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4999. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  5000. //url := gdyb_url + "1101"
  5001. var url string
  5002. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5003. url = gdyb_url
  5004. } else {
  5005. url = gdyb_url + "1101"
  5006. }
  5007. fmt.Println(url)
  5008. fmt.Println(gdyb_paasid)
  5009. fmt.Println(secret_key)
  5010. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  5011. request, err := http.NewRequest("POST", url, reader)
  5012. if err != nil {
  5013. fmt.Println(err.Error())
  5014. return err.Error(), ""
  5015. }
  5016. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5017. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5018. request.Header.Set("x-tif-signature", signature)
  5019. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5020. request.Header.Set("x-tif-nonce", nonce)
  5021. client := http.Client{}
  5022. resp, err := client.Do(request)
  5023. if err != nil {
  5024. fmt.Println(err.Error())
  5025. return err.Error(), ""
  5026. }
  5027. respBytes, err := ioutil.ReadAll(resp.Body)
  5028. if err != nil {
  5029. fmt.Println(err.Error())
  5030. return err.Error(), ""
  5031. }
  5032. fmt.Println(string(respBytes))
  5033. str := string(respBytes)
  5034. return str, string(bytesData)
  5035. }
  5036. func Gdyb6101(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) (string, string) {
  5037. //生成签名
  5038. nonce := GetRandomString(32)
  5039. timestamp := time.Now().Unix()
  5040. signature := setSignature(timestamp, nonce, secret_key)
  5041. //生成输入报文
  5042. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  5043. input := make(map[string]interface{})
  5044. inputData := make(map[string]interface{})
  5045. inputMessage["infno"] = "6101" // 交易编码
  5046. inputData["orgId"] = fixmedins_code // 就诊凭证类型
  5047. inputData["businessType"] = "01101" // 卡识别码
  5048. inputData["businessInfo"] = "" // 证件号码
  5049. inputData["operateorId"] = "01" // 人员证件类型
  5050. inputData["operateornName"] = doctor // 就诊凭证编号
  5051. inputData["officeId"] = "01" // 开始时间
  5052. inputData["officeName"] = "血透" // 人员姓名
  5053. inputData["deviceType"] = "" // 人员姓名
  5054. input["InData"] = inputData
  5055. inputMessage["input"] = input //交易输入
  5056. bytesData, err := json.Marshal(inputMessage)
  5057. fmt.Println(string(bytesData))
  5058. if err != nil {
  5059. fmt.Println(err.Error())
  5060. return err.Error(), ""
  5061. }
  5062. reader := bytes.NewReader(bytesData)
  5063. gdyb_url := beego.AppConfig.String("gdyb_url")
  5064. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5065. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  5066. //url := gdyb_url + "1101"
  5067. var url string
  5068. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450127" {
  5069. url = gdyb_url
  5070. } else {
  5071. url = gdyb_url + "1101"
  5072. }
  5073. fmt.Println(url)
  5074. fmt.Println(gdyb_paasid)
  5075. fmt.Println(secret_key)
  5076. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  5077. request, err := http.NewRequest("POST", url, reader)
  5078. if err != nil {
  5079. fmt.Println(err.Error())
  5080. return err.Error(), ""
  5081. }
  5082. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5083. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5084. request.Header.Set("x-tif-signature", signature)
  5085. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5086. request.Header.Set("x-tif-nonce", nonce)
  5087. client := http.Client{}
  5088. resp, err := client.Do(request)
  5089. if err != nil {
  5090. fmt.Println(err.Error())
  5091. return err.Error(), ""
  5092. }
  5093. respBytes, err := ioutil.ReadAll(resp.Body)
  5094. if err != nil {
  5095. fmt.Println(err.Error())
  5096. return err.Error(), ""
  5097. }
  5098. fmt.Println(string(respBytes))
  5099. str := string(respBytes)
  5100. return str, string(bytesData)
  5101. }
  5102. // 人员信息版本4
  5103. 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) {
  5104. //生成签名
  5105. nonce := GetRandomString(32)
  5106. timestamp := time.Now().Unix()
  5107. //signature := setSignature(timestamp, nonce, secret_key)
  5108. //生成输入报文
  5109. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  5110. input := make(map[string]interface{})
  5111. inputData := make(map[string]interface{})
  5112. inputMessage["infno"] = "1101" // 交易编码
  5113. if certificates == 3 {
  5114. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  5115. inputData["certno"] = certNo // 证件号码
  5116. inputData["psn_cert_type"] = "99" // 人员证件类型
  5117. } else {
  5118. if id_card_type == 1 {
  5119. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  5120. inputData["card_sn"] = "" // 卡识别码
  5121. inputData["certno"] = "" // 证件号码
  5122. inputData["psn_cert_type"] = "" // 人员证件类型
  5123. } else {
  5124. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  5125. inputData["card_sn"] = "" // 卡识别码
  5126. inputData["certno"] = certNo // 证件号码
  5127. inputData["psn_cert_type"] = "1" // 人员证件类型
  5128. }
  5129. }
  5130. inputData["mdtrt_cert_no"] = "" // 就诊凭证编号
  5131. inputData["begntime"] = "" // 开始时间
  5132. inputData["psn_name"] = "" // 人员姓名
  5133. input["data"] = inputData
  5134. inputMessage["input"] = input //交易输入
  5135. bytesData, err := json.Marshal(inputMessage)
  5136. fmt.Println(string(bytesData))
  5137. if err != nil {
  5138. fmt.Println(err.Error())
  5139. return err.Error(), ""
  5140. }
  5141. var json2 string
  5142. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  5143. out, err := cmd.Output()
  5144. if err != nil {
  5145. fmt.Println("error:", err.Error())
  5146. }
  5147. fmt.Println(string(out))
  5148. return string(out), string(bytesData)
  5149. }
  5150. func StrPtr(s string) uintptr {
  5151. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  5152. }
  5153. 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 {
  5154. //生成签名
  5155. nonce := GetRandomString(32)
  5156. timestamp := time.Now().Unix()
  5157. signature := setSignature(timestamp, nonce, secret_key)
  5158. //生成输入报文
  5159. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  5160. input := make(map[string]interface{})
  5161. inputData := make(map[string]interface{})
  5162. inputMessage["infno"] = "90991" // 交易编码
  5163. inputData["fixmedins_code"] = fixmedins_code // 就诊凭证编号
  5164. inputData["psn_no"] = psn_no // 开始时间
  5165. inputData["card_pwd"] = pwd // 人员姓名
  5166. inputData["sscno"] = card_number // 人员姓名
  5167. input["data"] = inputData
  5168. inputMessage["input"] = input //交易输入
  5169. bytesData, err := json.Marshal(inputMessage)
  5170. fmt.Println(string(bytesData))
  5171. if err != nil {
  5172. fmt.Println(err.Error())
  5173. return err.Error()
  5174. }
  5175. reader := bytes.NewReader(bytesData)
  5176. gdyb_url := beego.AppConfig.String("gdyb_url")
  5177. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5178. url := gdyb_url + "90991"
  5179. request, err := http.NewRequest("POST", url, reader)
  5180. if err != nil {
  5181. fmt.Println(err.Error())
  5182. return err.Error()
  5183. }
  5184. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5185. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5186. request.Header.Set("x-tif-signature", signature)
  5187. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5188. request.Header.Set("x-tif-nonce", nonce)
  5189. client := http.Client{}
  5190. resp, err := client.Do(request)
  5191. if err != nil {
  5192. fmt.Println(err.Error())
  5193. return err.Error()
  5194. }
  5195. respBytes, err := ioutil.ReadAll(resp.Body)
  5196. if err != nil {
  5197. fmt.Println(err.Error())
  5198. return err.Error()
  5199. }
  5200. fmt.Println(string(respBytes))
  5201. str := string(respBytes)
  5202. return str
  5203. }
  5204. func Gdyb90100(psn_no string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  5205. //生成签名
  5206. nonce := GetRandomString(32)
  5207. timestamp := time.Now().Unix()
  5208. signature := setSignature(timestamp, nonce, secret_key)
  5209. //生成输入报文
  5210. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  5211. input := make(map[string]interface{})
  5212. inputData := make(map[string]interface{})
  5213. inputMessage["infno"] = "90100" // 交易编码
  5214. inputData["psn_no"] = psn_no // 开始时间
  5215. input["data"] = inputData
  5216. inputMessage["input"] = input //交易输入
  5217. bytesData, err := json.Marshal(inputMessage)
  5218. fmt.Println(string(bytesData))
  5219. if err != nil {
  5220. fmt.Println(err.Error())
  5221. return err.Error()
  5222. }
  5223. reader := bytes.NewReader(bytesData)
  5224. gdyb_url := beego.AppConfig.String("gdyb_url")
  5225. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5226. url := gdyb_url + "90100"
  5227. request, err := http.NewRequest("POST", url, reader)
  5228. if err != nil {
  5229. fmt.Println(err.Error())
  5230. return err.Error()
  5231. }
  5232. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5233. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5234. request.Header.Set("x-tif-signature", signature)
  5235. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5236. request.Header.Set("x-tif-nonce", nonce)
  5237. client := http.Client{}
  5238. resp, err := client.Do(request)
  5239. if err != nil {
  5240. fmt.Println(err.Error())
  5241. return err.Error()
  5242. }
  5243. respBytes, err := ioutil.ReadAll(resp.Body)
  5244. if err != nil {
  5245. fmt.Println(err.Error())
  5246. return err.Error()
  5247. }
  5248. fmt.Println(string(respBytes))
  5249. str := string(respBytes)
  5250. return str
  5251. }
  5252. 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) {
  5253. //生成签名
  5254. nonce := GetRandomString(32)
  5255. timestamp := time.Now().Unix()
  5256. signature := setSignature(timestamp, nonce, secret_key)
  5257. //生成输入报文
  5258. inputMessage := SetInputMessageTwo(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, sign)
  5259. input := make(map[string]interface{})
  5260. inputData := make(map[string]interface{})
  5261. inputMessage["infno"] = "3260" // 交易编码
  5262. inputData["sign"] = sign // 就诊凭证编号
  5263. inputData["trt_year"] = year // 就诊凭证编号
  5264. inputData["trt_month"] = month // 开始时间
  5265. inputData["startrow"] = count // 人员姓名
  5266. input["data"] = inputData
  5267. inputMessage["input"] = input //交易输入
  5268. var inputLog string
  5269. bytesData, err := json.Marshal(inputMessage)
  5270. inputLog = string(bytesData)
  5271. fmt.Println(string(bytesData))
  5272. if err != nil {
  5273. fmt.Println(err.Error())
  5274. return err.Error(), ""
  5275. }
  5276. reader := bytes.NewReader(bytesData)
  5277. gdyb_url := beego.AppConfig.String("gdyb_url")
  5278. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5279. var url string
  5280. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5281. url = gdyb_url
  5282. } else {
  5283. url = gdyb_url + "3260"
  5284. }
  5285. if insuplc_admdvs == "421300" {
  5286. var json2 string
  5287. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  5288. out, err := cmd.Output()
  5289. if err != nil {
  5290. fmt.Println("error:", err.Error())
  5291. }
  5292. fmt.Println(string(out))
  5293. return hex.EncodeToString(out), inputLog
  5294. } else {
  5295. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  5296. request, err := http.NewRequest("POST", url, reader)
  5297. if err != nil {
  5298. fmt.Println(err.Error())
  5299. return err.Error(), ""
  5300. }
  5301. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5302. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5303. request.Header.Set("x-tif-signature", signature)
  5304. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5305. request.Header.Set("x-tif-nonce", nonce)
  5306. client := http.Client{}
  5307. resp, err := client.Do(request)
  5308. if err != nil {
  5309. fmt.Println(err.Error())
  5310. return err.Error(), ""
  5311. }
  5312. respBytes, err := ioutil.ReadAll(resp.Body)
  5313. if err != nil {
  5314. fmt.Println(err.Error())
  5315. return err.Error(), ""
  5316. }
  5317. fmt.Println(string(respBytes))
  5318. str := string(respBytes)
  5319. return str, inputLog
  5320. }
  5321. }
  5322. 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) {
  5323. //msg_month := time.Unix(1557042972, 0).Format("1")
  5324. //msg_year := time.Now().Format("2006")
  5325. //msg_month = time.Now().Format("01")
  5326. //day := time.Now().Format("02")
  5327. //
  5328. //hour := time.Now().Format("15")
  5329. //min := time.Now().Format("04")
  5330. //sec := time.Now().Format("05")
  5331. //
  5332. //msec := time.Now().Format("000")
  5333. //msg_id := fixmedins_code + msg_year + msg_month + day + hour + min + sec + msec + "0"
  5334. feedetail := make([]map[string]interface{}, 0)
  5335. for _, subitem := range result3260 {
  5336. for _, item := range subitem.Output.Data {
  5337. if item.MdtrtId != "out20230406681871" && item.MdtrtId != "out20230406681868" {
  5338. feedetailInfo := make(map[string]interface{})
  5339. feedetailInfo["certno"] = item.Certno
  5340. feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5341. feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5342. feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5343. feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5344. feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5345. feedetailInfo["cnfm_flag"] = "1" // 处方号
  5346. feedetail = append(feedetail, feedetailInfo)
  5347. }
  5348. }
  5349. }
  5350. for _, subitem := range result3260 {
  5351. for _, item := range subitem.Output.Data {
  5352. if item.MdtrtId == "out20230406681871" {
  5353. feedetailInfo := make(map[string]interface{})
  5354. feedetailInfo["certno"] = item.Certno
  5355. feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5356. feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5357. feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5358. feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5359. feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5360. feedetailInfo["cnfm_flag"] = "0" // 处方号
  5361. feedetail = append(feedetail, feedetailInfo)
  5362. }
  5363. }
  5364. }
  5365. for _, subitem := range result3260 {
  5366. for _, item := range subitem.Output.Data {
  5367. if item.MdtrtId == "out20230406681868" {
  5368. feedetailInfo := make(map[string]interface{})
  5369. feedetailInfo["certno"] = item.Certno
  5370. feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5371. feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5372. feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5373. feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5374. feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5375. feedetailInfo["cnfm_flag"] = "0" // 处方号
  5376. feedetail = append(feedetail, feedetailInfo)
  5377. }
  5378. }
  5379. }
  5380. // 分页操作
  5381. pageSize := 100
  5382. pages := paginate(feedetail, pageSize)
  5383. //aa := 0
  5384. // 输出每一页的数据
  5385. for _, page := range pages {
  5386. nonce := GetRandomString(32)
  5387. timestamp := time.Now().Unix()
  5388. signature := setSignature(timestamp, nonce, secret_key)
  5389. //生成输入报文
  5390. //aa = aa + len(page)
  5391. //nonce := GetRandomString(32)
  5392. //timestamp := time.Now().Unix()
  5393. inputMessage := SetInputMessageTwo(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, sign_no)
  5394. input := make(map[string]interface{})
  5395. inputData := make(map[string]interface{})
  5396. inputMessage["infno"] = "3261" // 交易编码
  5397. inputData["trt_year"] = year // 就诊凭证编号
  5398. inputData["trt_month"] = month // 开始时间
  5399. inputData["totalrow"] = len(feedetail) // 人员姓名
  5400. input["data"] = inputData
  5401. input["detail"] = page
  5402. inputMessage["input"] = input //交易输入
  5403. //var inputLog string
  5404. bytesData, err := json.Marshal(inputMessage)
  5405. //inputLog = string(bytesData)
  5406. fmt.Println(string(bytesData))
  5407. if err != nil {
  5408. fmt.Println(err.Error())
  5409. return
  5410. }
  5411. reader := bytes.NewReader(bytesData)
  5412. gdyb_url := beego.AppConfig.String("gdyb_url")
  5413. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5414. var url string
  5415. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5416. url = gdyb_url
  5417. } else {
  5418. url = gdyb_url + "3261"
  5419. }
  5420. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  5421. request, err := http.NewRequest("POST", url, reader)
  5422. if err != nil {
  5423. fmt.Println(err.Error())
  5424. return
  5425. }
  5426. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5427. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5428. request.Header.Set("x-tif-signature", signature)
  5429. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5430. request.Header.Set("x-tif-nonce", nonce)
  5431. client := http.Client{}
  5432. resp, err := client.Do(request)
  5433. if err != nil {
  5434. fmt.Println(err.Error())
  5435. return
  5436. }
  5437. respBytes, err := ioutil.ReadAll(resp.Body)
  5438. if err != nil {
  5439. fmt.Println(err.Error())
  5440. return
  5441. }
  5442. fmt.Println(string(respBytes))
  5443. str := string(respBytes)
  5444. fmt.Println(str)
  5445. }
  5446. //for _, item := range result3260.Output.Data[start-1 : stop] {
  5447. // if item.MdtrtId != "out20230406681871" && item.MdtrtId != "out20230406681868" {
  5448. // feedetailInfo := make(map[string]interface{})
  5449. // feedetailInfo["certno"] = item.Certno
  5450. // feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5451. // feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5452. // feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5453. // feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5454. // feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5455. // feedetailInfo["cnfm_flag"] = "1" // 处方号
  5456. // feedetail = append(feedetail, feedetailInfo)
  5457. // }
  5458. //}
  5459. //for _, item := range result3260.Output.Data[start-1 : stop] {
  5460. // if item.MdtrtId == "out20230406681871" {
  5461. // feedetailInfo := make(map[string]interface{})
  5462. // feedetailInfo["certno"] = item.Certno
  5463. // feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5464. // feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5465. // feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5466. // feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5467. // feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5468. // feedetailInfo["cnfm_flag"] = "0" // 处方号
  5469. // feedetail = append(feedetail, feedetailInfo)
  5470. // }
  5471. //
  5472. //}
  5473. //for _, item := range result3260.Output.Data[start-1 : stop] {
  5474. // if item.MdtrtId == "out20230406681868" {
  5475. // feedetailInfo := make(map[string]interface{})
  5476. // feedetailInfo["certno"] = item.Certno
  5477. // feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5478. // feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5479. // feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5480. // feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5481. // feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5482. // feedetailInfo["cnfm_flag"] = "0" // 处方号
  5483. // feedetail = append(feedetail, feedetailInfo)
  5484. // }
  5485. //
  5486. //}
  5487. return
  5488. }
  5489. 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) {
  5490. //msg_month := time.Unix(1557042972, 0).Format("1")
  5491. //msg_year := time.Now().Format("2006")
  5492. //msg_month = time.Now().Format("01")
  5493. //day := time.Now().Format("02")
  5494. //
  5495. //hour := time.Now().Format("15")
  5496. //min := time.Now().Format("04")
  5497. //sec := time.Now().Format("05")
  5498. //
  5499. //msec := time.Now().Format("000")
  5500. //msg_id := fixmedins_code + msg_year + msg_month + day + hour + min + sec + msec + "0"
  5501. feedetail := make([]map[string]interface{}, 0)
  5502. for _, subitem := range result3260 {
  5503. for _, item := range subitem.Output.Data {
  5504. if item.MdtrtId != "out20230406681871" && item.MdtrtId != "out20230406681868" {
  5505. feedetailInfo := make(map[string]interface{})
  5506. feedetailInfo["certno"] = item.Certno
  5507. feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5508. feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5509. feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5510. feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5511. feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5512. feedetailInfo["cnfm_flag"] = "1" // 处方号
  5513. feedetail = append(feedetail, feedetailInfo)
  5514. }
  5515. }
  5516. }
  5517. for _, subitem := range result3260 {
  5518. for _, item := range subitem.Output.Data {
  5519. if item.MdtrtId == "out20230406681871" {
  5520. feedetailInfo := make(map[string]interface{})
  5521. feedetailInfo["certno"] = item.Certno
  5522. feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5523. feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5524. feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5525. feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5526. feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5527. feedetailInfo["cnfm_flag"] = "0" // 处方号
  5528. feedetail = append(feedetail, feedetailInfo)
  5529. }
  5530. }
  5531. }
  5532. for _, subitem := range result3260 {
  5533. for _, item := range subitem.Output.Data {
  5534. if item.MdtrtId == "out20230406681868" {
  5535. feedetailInfo := make(map[string]interface{})
  5536. feedetailInfo["certno"] = item.Certno
  5537. feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5538. feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5539. feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5540. feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5541. feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5542. feedetailInfo["cnfm_flag"] = "0" // 处方号
  5543. feedetail = append(feedetail, feedetailInfo)
  5544. }
  5545. }
  5546. }
  5547. var firstSlice, secondSlice []map[string]interface{}
  5548. if len(feedetail) > 500 {
  5549. firstSlice = feedetail[:500]
  5550. secondSlice = feedetail[500:]
  5551. } else {
  5552. firstSlice = feedetail
  5553. secondSlice = []map[string]interface{}{}
  5554. }
  5555. fmt.Println(firstSlice)
  5556. nonce := GetRandomString(32)
  5557. timestamp := time.Now().Unix()
  5558. signature := setSignature(timestamp, nonce, secret_key)
  5559. //生成输入报文
  5560. total := 0
  5561. for _, item := range result3260 {
  5562. total = total + len(item.Output.Data)
  5563. }
  5564. //nonce := GetRandomString(32)
  5565. //timestamp := time.Now().Unix()
  5566. inputMessage := SetInputMessageTwo(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, sign_no)
  5567. input := make(map[string]interface{})
  5568. inputData := make(map[string]interface{})
  5569. inputMessage["infno"] = "3261" // 交易编码
  5570. inputData["trt_year"] = year // 就诊凭证编号
  5571. inputData["trt_month"] = month // 开始时间
  5572. inputData["totalrow"] = len(secondSlice) // 人员姓名
  5573. input["data"] = inputData
  5574. input["detail"] = secondSlice
  5575. inputMessage["input"] = input //交易输入
  5576. //var inputLog string
  5577. bytesData, err := json.Marshal(inputMessage)
  5578. //inputLog = string(bytesData)
  5579. fmt.Println(string(bytesData))
  5580. if err != nil {
  5581. fmt.Println(err.Error())
  5582. return
  5583. }
  5584. reader := bytes.NewReader(bytesData)
  5585. gdyb_url := beego.AppConfig.String("gdyb_url")
  5586. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5587. var url string
  5588. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5589. url = gdyb_url
  5590. } else {
  5591. url = gdyb_url + "3261"
  5592. }
  5593. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  5594. request, err := http.NewRequest("POST", url, reader)
  5595. if err != nil {
  5596. fmt.Println(err.Error())
  5597. return
  5598. }
  5599. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5600. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5601. request.Header.Set("x-tif-signature", signature)
  5602. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5603. request.Header.Set("x-tif-nonce", nonce)
  5604. client := http.Client{}
  5605. resp, err := client.Do(request)
  5606. if err != nil {
  5607. fmt.Println(err.Error())
  5608. return
  5609. }
  5610. respBytes, err := ioutil.ReadAll(resp.Body)
  5611. if err != nil {
  5612. fmt.Println(err.Error())
  5613. return
  5614. }
  5615. fmt.Println(string(respBytes))
  5616. str := string(respBytes)
  5617. fmt.Println(str)
  5618. //for _, item := range result3260.Output.Data[start-1 : stop] {
  5619. // if item.MdtrtId != "out20230406681871" && item.MdtrtId != "out20230406681868" {
  5620. // feedetailInfo := make(map[string]interface{})
  5621. // feedetailInfo["certno"] = item.Certno
  5622. // feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5623. // feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5624. // feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5625. // feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5626. // feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5627. // feedetailInfo["cnfm_flag"] = "1" // 处方号
  5628. // feedetail = append(feedetail, feedetailInfo)
  5629. // }
  5630. //}
  5631. //for _, item := range result3260.Output.Data[start-1 : stop] {
  5632. // if item.MdtrtId == "out20230406681871" {
  5633. // feedetailInfo := make(map[string]interface{})
  5634. // feedetailInfo["certno"] = item.Certno
  5635. // feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5636. // feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5637. // feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5638. // feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5639. // feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5640. // feedetailInfo["cnfm_flag"] = "0" // 处方号
  5641. // feedetail = append(feedetail, feedetailInfo)
  5642. // }
  5643. //
  5644. //}
  5645. //for _, item := range result3260.Output.Data[start-1 : stop] {
  5646. // if item.MdtrtId == "out20230406681868" {
  5647. // feedetailInfo := make(map[string]interface{})
  5648. // feedetailInfo["certno"] = item.Certno
  5649. // feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5650. // feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5651. // feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5652. // feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5653. // feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5654. // feedetailInfo["cnfm_flag"] = "0" // 处方号
  5655. // feedetail = append(feedetail, feedetailInfo)
  5656. // }
  5657. //
  5658. //}
  5659. return
  5660. }
  5661. 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) {
  5662. //生成签名
  5663. nonce := GetRandomString(32)
  5664. timestamp := time.Now().Unix()
  5665. signature := setSignature(timestamp, nonce, secret_key)
  5666. //生成输入报文
  5667. inputMessage := SetInputMessageTwo(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, sign_no)
  5668. input := make(map[string]interface{})
  5669. inputData := make(map[string]interface{})
  5670. inputMessage["infno"] = "3262" // 交易编码
  5671. inputData["trt_year"] = year // 就诊凭证编号
  5672. inputData["trt_month"] = month // 开始时间
  5673. inputData["otransid"] = "0" // 开始时间
  5674. input["data"] = inputData
  5675. inputMessage["input"] = input //交易输入
  5676. var inputLog string
  5677. bytesData, err := json.Marshal(inputMessage)
  5678. inputLog = string(bytesData)
  5679. fmt.Println(string(bytesData))
  5680. if err != nil {
  5681. fmt.Println(err.Error())
  5682. return err.Error(), ""
  5683. }
  5684. reader := bytes.NewReader(bytesData)
  5685. gdyb_url := beego.AppConfig.String("gdyb_url")
  5686. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5687. var url string
  5688. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5689. url = gdyb_url
  5690. } else {
  5691. url = gdyb_url + "3262"
  5692. }
  5693. if insuplc_admdvs == "421300" {
  5694. var json2 string
  5695. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  5696. out, err := cmd.Output()
  5697. if err != nil {
  5698. fmt.Println("error:", err.Error())
  5699. }
  5700. fmt.Println(string(out))
  5701. return hex.EncodeToString(out), inputLog
  5702. } else {
  5703. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  5704. request, err := http.NewRequest("POST", url, reader)
  5705. if err != nil {
  5706. fmt.Println(err.Error())
  5707. return err.Error(), ""
  5708. }
  5709. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5710. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5711. request.Header.Set("x-tif-signature", signature)
  5712. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5713. request.Header.Set("x-tif-nonce", nonce)
  5714. client := http.Client{}
  5715. resp, err := client.Do(request)
  5716. if err != nil {
  5717. fmt.Println(err.Error())
  5718. return err.Error(), ""
  5719. }
  5720. respBytes, err := ioutil.ReadAll(resp.Body)
  5721. if err != nil {
  5722. fmt.Println(err.Error())
  5723. return err.Error(), ""
  5724. }
  5725. fmt.Println(string(respBytes))
  5726. str := string(respBytes)
  5727. return str, inputLog
  5728. }
  5729. }
  5730. 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) {
  5731. //生成签名
  5732. nonce := GetRandomString(32)
  5733. timestamp := time.Now().Unix()
  5734. signature := setSignature(timestamp, nonce, "d6Ad0P1B3z6Dsdst0gYAFPlz8YlIvFDx")
  5735. inputMessage := make(map[string]interface{})
  5736. //生成输入报文
  5737. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5738. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  5739. } else {
  5740. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  5741. }
  5742. input := make(map[string]interface{})
  5743. inputData := make(map[string]interface{})
  5744. inputMessage["infno"] = "9001" // 交易编码
  5745. inputData["opter_no"] = admin_user_id // 就诊凭证编号
  5746. inputData["mac"] = "11-11-11-11-11" // 开始时间
  5747. inputData["ip"] = "11.11.11.11"
  5748. //inputData["userid"] = "H44010400081"
  5749. //month := time.Unix(1557042972, 0).Format("1")
  5750. //year := time.Now().Format("2006")
  5751. //month = time.Now().Format("01")
  5752. //day := time.Now().Format("02")
  5753. //hour := time.Now().Format("15")
  5754. //min := time.Now().Format("04")
  5755. //sec := time.Now().Format("05")
  5756. //custom_time := year + month + day + hour + min + sec
  5757. //inputData["currenttime"] = custom_time
  5758. //var psd string
  5759. //psd = custom_time + "Gzyb$867"
  5760. //h := md5.New()
  5761. //h.Write([]byte(psd))
  5762. //inputData["password"] = strings.ToUpper(hex.EncodeToString(h.Sum(nil)))
  5763. input["data"] = inputData
  5764. inputMessage["input"] = input //交易输入
  5765. var inputLog string
  5766. bytesData, err := json.Marshal(inputMessage)
  5767. inputLog = string(bytesData)
  5768. fmt.Println(string(bytesData))
  5769. if err != nil {
  5770. fmt.Println(err.Error())
  5771. return err.Error(), ""
  5772. }
  5773. reader := bytes.NewReader(bytesData)
  5774. gdyb_url := beego.AppConfig.String("gdyb_url")
  5775. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5776. var url string
  5777. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5778. url = gdyb_url
  5779. } else {
  5780. url = gdyb_url + "9001"
  5781. }
  5782. if insuplc_admdvs == "421300" {
  5783. var json2 string
  5784. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  5785. out, err := cmd.Output()
  5786. if err != nil {
  5787. fmt.Println("error:", err.Error())
  5788. }
  5789. fmt.Println(string(out))
  5790. return hex.EncodeToString(out), inputLog
  5791. } else {
  5792. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  5793. request, err := http.NewRequest("POST", url, reader)
  5794. if err != nil {
  5795. fmt.Println(err.Error())
  5796. return err.Error(), ""
  5797. }
  5798. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5799. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5800. request.Header.Set("x-tif-signature", signature)
  5801. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5802. request.Header.Set("x-tif-nonce", nonce)
  5803. fmt.Println(string(bytesData))
  5804. fmt.Println(gdyb_url)
  5805. fmt.Println(gdyb_paasid)
  5806. fmt.Println(request.Header)
  5807. client := http.Client{}
  5808. resp, err := client.Do(request)
  5809. if err != nil {
  5810. fmt.Println(err.Error())
  5811. return err.Error(), ""
  5812. }
  5813. respBytes, err := ioutil.ReadAll(resp.Body)
  5814. if err != nil {
  5815. fmt.Println(err.Error())
  5816. return err.Error(), ""
  5817. }
  5818. fmt.Println(string(respBytes))
  5819. str := string(respBytes)
  5820. return str, inputLog
  5821. }
  5822. }
  5823. 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) {
  5824. //生成签名
  5825. nonce := GetRandomString(32)
  5826. timestamp := time.Now().Unix()
  5827. signature := setSignature(timestamp, nonce, secret_key)
  5828. inputMessage := make(map[string]interface{})
  5829. //生成输入报文
  5830. //生成输入报文
  5831. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5832. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  5833. } else {
  5834. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  5835. }
  5836. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  5837. input := make(map[string]interface{})
  5838. inputData := make(map[string]interface{})
  5839. inputMessage["infno"] = "9001" // 交易编码
  5840. inputData["opter_no"] = admin_user_id // 就诊凭证编号
  5841. inputData["mac"] = GetMac() // 开始时间
  5842. inputData["ip"] = GetLocalIp()
  5843. input["signIn"] = inputData
  5844. inputMessage["input"] = input //交易输入
  5845. var inputLog string
  5846. bytesData, err := json.Marshal(inputMessage)
  5847. inputLog = string(bytesData)
  5848. fmt.Println(string(bytesData))
  5849. if err != nil {
  5850. fmt.Println(err.Error())
  5851. return err.Error(), ""
  5852. }
  5853. reader := bytes.NewReader(bytesData)
  5854. gdyb_url := beego.AppConfig.String("gdyb_url")
  5855. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5856. var url string
  5857. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5858. url = gdyb_url
  5859. } else {
  5860. url = gdyb_url + "9001"
  5861. }
  5862. if insuplc_admdvs == "421300" {
  5863. var json2 string
  5864. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  5865. out, err := cmd.Output()
  5866. if err != nil {
  5867. fmt.Println("error:", err.Error())
  5868. }
  5869. fmt.Println(string(out))
  5870. return hex.EncodeToString(out), inputLog
  5871. } else {
  5872. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  5873. request, err := http.NewRequest("POST", url, reader)
  5874. if err != nil {
  5875. fmt.Println(err.Error())
  5876. return err.Error(), ""
  5877. }
  5878. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5879. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5880. request.Header.Set("x-tif-signature", signature)
  5881. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5882. request.Header.Set("x-tif-nonce", nonce)
  5883. fmt.Println(string(bytesData))
  5884. fmt.Println(gdyb_url)
  5885. fmt.Println(gdyb_paasid)
  5886. fmt.Println(request.Header)
  5887. client := http.Client{}
  5888. resp, err := client.Do(request)
  5889. if err != nil {
  5890. fmt.Println(err.Error())
  5891. return err.Error(), ""
  5892. }
  5893. respBytes, err := ioutil.ReadAll(resp.Body)
  5894. if err != nil {
  5895. fmt.Println(err.Error())
  5896. return err.Error(), ""
  5897. }
  5898. fmt.Println(string(respBytes))
  5899. str := string(respBytes)
  5900. return str, inputLog
  5901. }
  5902. }
  5903. // 获取本机ip
  5904. func GetLocalIp() string {
  5905. addrs, err := net.InterfaceAddrs()
  5906. if err != nil {
  5907. fmt.Println("get local ip failed")
  5908. }
  5909. for _, address := range addrs {
  5910. if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
  5911. if ipnet.IP.To4() != nil {
  5912. return ipnet.IP.String()
  5913. }
  5914. }
  5915. }
  5916. return ""
  5917. }
  5918. // 获取本机Mac
  5919. func GetMac() string {
  5920. interfaces, err := net.Interfaces()
  5921. if err != nil {
  5922. fmt.Println("Get loacl Mac failed")
  5923. }
  5924. for _, inter := range interfaces {
  5925. mac := inter.HardwareAddr
  5926. fmt.Println("+======" + mac.String())
  5927. if mac.String() != "" {
  5928. return mac.String()
  5929. }
  5930. }
  5931. return ""
  5932. }
  5933. // 人员基本信息
  5934. 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) {
  5935. //生成签名
  5936. fmt.Println("DDDDD")
  5937. nonce := GetRandomString(32)
  5938. timestamp := time.Now().Unix()
  5939. signature := setSignature(timestamp, nonce, secret_key)
  5940. //生成输入报文
  5941. inputMessage := make(map[string]interface{})
  5942. //tempTime := time.Unix(timestamp, 0)
  5943. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  5944. // 生成输入报文
  5945. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5946. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  5947. } else {
  5948. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  5949. }
  5950. //inputMessage := SetInputMessagenosign(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  5951. input := make(map[string]interface{})
  5952. inputData := make(map[string]interface{})
  5953. inputMessage["infno"] = "1101" // 交易编码
  5954. if certificates == "3" {
  5955. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  5956. inputData["certno"] = certNo // 证件号码
  5957. inputData["psn_cert_type"] = "99" // 人员证件类型
  5958. } else {
  5959. if certificates == "1" {
  5960. if id_card_type == 1 {
  5961. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  5962. inputData["card_sn"] = "" // 卡识别码
  5963. inputData["certno"] = certNo // 证件号码
  5964. inputData["psn_cert_type"] = "01" // 人员证件类型
  5965. } else if id_card_type == 4 {
  5966. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  5967. inputData["certno"] = certNo // 证件号码
  5968. inputData["psn_cert_type"] = "01" // 人员证件类型
  5969. } else {
  5970. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  5971. inputData["card_sn"] = "" // 卡识别码
  5972. inputData["certno"] = certNo // 证件号码
  5973. inputData["psn_cert_type"] = "01" // 人员证件类型
  5974. }
  5975. } else if certificates == "6" {
  5976. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  5977. inputData["card_sn"] = "" // 卡识别码
  5978. inputData["certno"] = certNo // 证件号码
  5979. inputData["psn_cert_type"] = "17" // 人员证件类型
  5980. }
  5981. }
  5982. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  5983. inputData["begntime"] = "" // 开始时间
  5984. inputData["psn_name"] = "" // 人员姓名
  5985. input["data"] = inputData
  5986. inputMessage["input"] = input //交易输入
  5987. var inputLog string
  5988. bytesData, err := json.Marshal(inputMessage)
  5989. inputLog = string(bytesData)
  5990. fmt.Println(string(bytesData))
  5991. if err != nil {
  5992. fmt.Println(err.Error())
  5993. return err.Error(), ""
  5994. }
  5995. reader := bytes.NewReader(bytesData)
  5996. gdyb_url := beego.AppConfig.String("gdyb_url")
  5997. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5998. //DllDef := syscall.MustLoadDLL("yh_hb_sctrl.dll")
  5999. //Iinit := DllDef.MustFindProc("yh_hb_call")
  6000. //var str3 string
  6001. //ret, _, _ := Iinit.Call(StrPtr("1101"), StrPtr(string(bytesData)), StrPtr(str3))
  6002. //fmt.Println(ret)
  6003. //fmt.Println(str3)
  6004. //
  6005. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6006. var url string
  6007. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  6008. url = gdyb_url
  6009. } else {
  6010. url = gdyb_url + "1101"
  6011. }
  6012. if insuplc_admdvs == "421300" {
  6013. var json2 string
  6014. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  6015. out, err := cmd.Output()
  6016. if err != nil {
  6017. fmt.Println("error:", err.Error())
  6018. }
  6019. fmt.Println(string(out))
  6020. return hex.EncodeToString(out), inputLog
  6021. } else {
  6022. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  6023. request, err := http.NewRequest("POST", url, reader)
  6024. if err != nil {
  6025. fmt.Println(err.Error())
  6026. return err.Error(), ""
  6027. }
  6028. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6029. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6030. request.Header.Set("x-tif-signature", signature)
  6031. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6032. request.Header.Set("x-tif-nonce", nonce)
  6033. client := http.Client{}
  6034. resp, err := client.Do(request)
  6035. if err != nil {
  6036. fmt.Println(err.Error())
  6037. return err.Error(), ""
  6038. }
  6039. respBytes, err := ioutil.ReadAll(resp.Body)
  6040. if err != nil {
  6041. fmt.Println(err.Error())
  6042. return err.Error(), ""
  6043. }
  6044. fmt.Println(string(respBytes))
  6045. str := string(respBytes)
  6046. return str, inputLog
  6047. }
  6048. }
  6049. //func SetInputMessageFour(nonce string, timestamp int64, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) map[string]interface{} {
  6050. // // 生成签名
  6051. // //tempTime := time.Unix(timestamp, 0)
  6052. // //timeFormat := tempTime.Format("20060102150405")
  6053. // //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  6054. // //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  6055. //
  6056. // msec := time.Now().Format("000")
  6057. // fmt.Println(utils.GetNetTime())
  6058. // // 生成输入报文
  6059. // inputMessage := make(map[string]interface{})
  6060. // inputMessage["msgid"] = fixmedins_code + utils.GetNetTime() + msec + "0" // 发送方报文 ID
  6061. // inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  6062. // inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  6063. // inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  6064. // inputMessage["dev_no"] = "" // 设备编号
  6065. // inputMessage["dev_safe_info"] = "" // 设备安全信息
  6066. // inputMessage["cainfo"] = "" // 数字签名信息
  6067. // inputMessage["signtype"] = "SM3" // 签名类型
  6068. // inputMessage["infver"] = "V1.0" // 接收方系统代码
  6069. // inputMessage["opter_type"] = "1" // 经办人类别
  6070. // inputMessage["opter"] = doctor // 经办人
  6071. // inputMessage["opter_name"] = doctor // 经办人姓名
  6072. // inputMessage["inf_time"] = utils.GetNetTime() // 交易时间
  6073. // inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  6074. // inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  6075. // inputMessage["sign_no"] = "" //交易签到流水号
  6076. // return inputMessage
  6077. //}
  6078. func Gdyb5302(psnNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  6079. // 生成签名
  6080. nonce := GetRandomString(32)
  6081. //timestamp := time.Now().Unix()
  6082. timestamp := time.Now().UnixNano() / 1e6
  6083. signature := setSignature(timestamp, nonce, secret_key)
  6084. // 生成输入报文
  6085. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  6086. input := make(map[string]interface{})
  6087. inputData := make(map[string]interface{})
  6088. inputMessage["infno"] = "5302" // 交易编码
  6089. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  6090. inputData["biz_appy_type"] = "03" // 人员编号 (来自1101接口返回)
  6091. input["data"] = inputData
  6092. inputMessage["input"] = input //交易输入
  6093. bytesData, err := json.Marshal(inputMessage)
  6094. fmt.Println(string(bytesData))
  6095. if err != nil {
  6096. fmt.Println(err.Error())
  6097. return err.Error()
  6098. }
  6099. reader := bytes.NewReader(bytesData)
  6100. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6101. gdyb_url := beego.AppConfig.String("gdyb_url")
  6102. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6103. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6104. url := gdyb_url + "5302"
  6105. request, err := http.NewRequest("POST", url, reader)
  6106. if err != nil {
  6107. fmt.Println(err.Error())
  6108. return err.Error()
  6109. }
  6110. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6111. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6112. request.Header.Set("x-tif-signature", signature)
  6113. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6114. request.Header.Set("x-tif-nonce", nonce)
  6115. client := http.Client{}
  6116. resp, err := client.Do(request)
  6117. if err != nil {
  6118. fmt.Println(err.Error())
  6119. return err.Error()
  6120. }
  6121. respBytes, err := ioutil.ReadAll(resp.Body)
  6122. if err != nil {
  6123. fmt.Println(err.Error())
  6124. return err.Error()
  6125. }
  6126. str := string(respBytes)
  6127. fmt.Println(str)
  6128. return str
  6129. }
  6130. func CreateSignIn(record *models.HisSignIn) (err error) {
  6131. err = writeDb.Save(&record).Error
  6132. return
  6133. }
  6134. func GetSignInInfo(code string) string {
  6135. var sign models.HisSignIn
  6136. err = readDb.Model(&models.HisSignIn{}).Where("fixmedins_code = ? AND status = 1", code).Last(&sign).Error
  6137. return sign.SignNo
  6138. }
  6139. func Gdyb3501(struct3501 models.Struct3501, secret_key string) (string, string) {
  6140. // 生成签名
  6141. nonce := GetRandomString(32)
  6142. timestamp := time.Now().Unix()
  6143. signature := setSignature(timestamp, nonce, secret_key)
  6144. // 生成输入报文
  6145. inputMessage := SetGdInputMessage(timestamp, struct3501.OrgName, struct3501.Opter, struct3501.FixmedinsHilistId, struct3501.InsuplcAdmdvs, struct3501.MdtrtareaAdmvs, struct3501.Cainfo)
  6146. input := make(map[string]interface{})
  6147. inputData := make(map[string]interface{})
  6148. inputMessage["infno"] = "3501" // 交易编码
  6149. inputData["med_list_codg"] = struct3501.MedListCodg // 定点医药机构目录编号
  6150. inputData["fixmedins_hilist_id"] = struct3501.FixmedinsHilistId // 定点医药机构目录编号
  6151. inputData["fixmedins_hilist_name"] = struct3501.FixmedinsHilistName // 定点医药机构目录名称
  6152. inputData["rx_flag"] = struct3501.RxFlag //
  6153. inputData["invdate"] = struct3501.Invdate // 人员编号 (来自1101接口返回)
  6154. inputData["inv_cnt"] = struct3501.InvCnt // 人员编号 (来自1101接口返回)
  6155. inputData["manu_lotnum"] = struct3501.ManuLotnum // 人员编号 (来自1101接口返回)
  6156. inputData["fixmedins_bchno"] = struct3501.FixmedinsBchno // 人员编号 (来自1101接口返回)
  6157. inputData["manu_date"] = struct3501.ManuDate // 人员编号 (来自1101接口返回)
  6158. inputData["expy_end"] = struct3501.ExpyEnd // 人员编号 (来自1101接口返回)
  6159. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  6160. feedetail := make([]map[string]interface{}, 0)
  6161. druginputData := make(map[string]interface{})
  6162. druginputData["drug_trac_codg"] = struct3501.DrugTracCodg
  6163. feedetail = append(feedetail,druginputData)
  6164. inputData["drugtracinfo"] = feedetail
  6165. input["invinfo"] = inputData
  6166. inputMessage["input"] = input //交易输入
  6167. bytesData, err := json.Marshal(inputMessage)
  6168. fmt.Println(string(bytesData))
  6169. if err != nil {
  6170. fmt.Println(err.Error())
  6171. return err.Error(), ""
  6172. }
  6173. reader := bytes.NewReader(bytesData)
  6174. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6175. gdyb_url := beego.AppConfig.String("gdyb_url")
  6176. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6177. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6178. url := gdyb_url + "3501"
  6179. request, err := http.NewRequest("POST", url, reader)
  6180. if err != nil {
  6181. fmt.Println(err.Error())
  6182. return err.Error(), ""
  6183. }
  6184. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6185. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6186. request.Header.Set("x-tif-signature", signature)
  6187. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6188. request.Header.Set("x-tif-nonce", nonce)
  6189. client := http.Client{}
  6190. resp, err := client.Do(request)
  6191. if err != nil {
  6192. fmt.Println(err.Error())
  6193. return err.Error(), ""
  6194. }
  6195. respBytes, err := ioutil.ReadAll(resp.Body)
  6196. if err != nil {
  6197. fmt.Println(err.Error())
  6198. return err.Error(), ""
  6199. }
  6200. str := string(respBytes)
  6201. fmt.Println(str)
  6202. return str, string(bytesData)
  6203. }
  6204. func Gdyb3502(struct3502 models.Struct3502, secret_key string) (string, string) {
  6205. // 生成签名
  6206. nonce := GetRandomString(32)
  6207. timestamp := time.Now().Unix()
  6208. signature := setSignature(timestamp, nonce, secret_key)
  6209. // 生成输入报文
  6210. inputMessage := SetGdInputMessage(timestamp, struct3502.OrgName, struct3502.Opter, struct3502.FixmedinsCode, struct3502.InsuplcAdmdvs, struct3502.MdtrtareaAdmvs, struct3502.Cainfo)
  6211. input := make(map[string]interface{})
  6212. inputData := make(map[string]interface{})
  6213. inputMessage["infno"] = "3502" // 交易编码
  6214. inputData["med_list_codg"] = struct3502.MedListCodg // 定点医药机构目录编号
  6215. inputData["inv_chg_type"] = struct3502.InvChgType // 定点医药机构目录编号
  6216. inputData["fixmedins_hilist_id"] = struct3502.FixmedinsCode // 定点医药机构目录编号
  6217. inputData["fixmedins_hilist_name"] = struct3502.FixmedinsHilistName // 定点医药机构目录名称
  6218. inputData["fixmedins_bchno"] = struct3502.FixmedinsBchno // 人员编号 (来自1101接口返回)
  6219. inputData["pric"] = struct3502.Pric // 人员编号 (来自1101接口返回)
  6220. inputData["cnt"] = struct3502.Cnt // 人员编号 (来自1101接口返回)
  6221. inputData["rx_flag"] = struct3502.RxFlag //
  6222. inputData["inv_chg_time"] = struct3502.InvChgTime // 人员编号 (来自1101接口返回)
  6223. inputData["inv_chg_opter_name"] = "" // 人员编号 (来自1101接口返回)
  6224. inputData["memo"] = struct3502.Memo // 人员编号 (来自1101接口返回)
  6225. inputData["trdn_flag"] = "" // 人员编号 (来自1101接口返回)
  6226. input["invinfo"] = inputData
  6227. feedetail := make([]map[string]interface{}, 0)
  6228. druginputData := make(map[string]interface{})
  6229. druginputData["drug_trac_codg"] = struct3502.DrugTracCodg
  6230. feedetail = append(feedetail,druginputData)
  6231. inputData["drugtracinfo"] = feedetail
  6232. input["invinfo"] = inputData
  6233. inputMessage["input"] = input //交易输入
  6234. bytesData, err := json.Marshal(inputMessage)
  6235. fmt.Println(string(bytesData))
  6236. if err != nil {
  6237. fmt.Println(err.Error())
  6238. return err.Error(), ""
  6239. }
  6240. reader := bytes.NewReader(bytesData)
  6241. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6242. gdyb_url := beego.AppConfig.String("gdyb_url")
  6243. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6244. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6245. url := gdyb_url + "3502"
  6246. request, err := http.NewRequest("POST", url, reader)
  6247. if err != nil {
  6248. fmt.Println(err.Error())
  6249. return err.Error(), ""
  6250. }
  6251. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6252. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6253. request.Header.Set("x-tif-signature", signature)
  6254. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6255. request.Header.Set("x-tif-nonce", nonce)
  6256. client := http.Client{}
  6257. resp, err := client.Do(request)
  6258. if err != nil {
  6259. fmt.Println(err.Error())
  6260. return err.Error(), ""
  6261. }
  6262. respBytes, err := ioutil.ReadAll(resp.Body)
  6263. if err != nil {
  6264. fmt.Println(err.Error())
  6265. return err.Error(), ""
  6266. }
  6267. str := string(respBytes)
  6268. fmt.Println(str)
  6269. return str, string(bytesData)
  6270. }
  6271. func Gdyb3503(struct3503 models.Struct3503, secret_key string) (string, string) {
  6272. // 生成签名
  6273. nonce := GetRandomString(32)
  6274. timestamp := time.Now().Unix()
  6275. signature := setSignature(timestamp, nonce, secret_key)
  6276. // 生成输入报文
  6277. inputMessage := SetGdInputMessage(timestamp, struct3503.OrgName, struct3503.Opter, struct3503.FixmedinsHilistId, struct3503.InsuplcAdmdvs, struct3503.MdtrtareaAdmvs, struct3503.Cainfo)
  6278. input := make(map[string]interface{})
  6279. inputMessage["infno"] = "3503"
  6280. item := struct3503
  6281. feedetailInfo := make(map[string]interface{})
  6282. feedetailInfo["med_list_codg"] = item.MedListCodg
  6283. feedetailInfo["fixmedins_hilist_id"] = item.FixmedinsHilistId
  6284. feedetailInfo["fixmedins_hilist_name"] = item.FixmedinsHilistName
  6285. feedetailInfo["dynt_no"] = ""
  6286. feedetailInfo["fixmedins_bchno"] = item.FixmedinsBchno // 人员编号 (来自1101接口返回)
  6287. feedetailInfo["spler_name"] = item.SplerName // 人员编号 (来自1101接口返回)
  6288. feedetailInfo["spler_pmtno"] = "" // 人员编号 (来自1101接口返回)
  6289. feedetailInfo["manu_lotnum"] = item.ManuLotnum // 人员编号 (来自1101接口返回)
  6290. feedetailInfo["prodentp_name"] = item.ProdentpName // 人员编号 (来自1101接口返回)
  6291. feedetailInfo["aprvno"] = item.Aprvno // 人员编号 (来自1101接口返回)
  6292. feedetailInfo["manu_date"] = item.ManuDate // 人员编号 (来自1101接口返回)
  6293. feedetailInfo["expy_end"] = item.ExpyEnd // 人员编号 (来自1101接口返回)
  6294. feedetailInfo["finl_trns_pric"] = item.FinlTrnsPric // 人员编号 (来自1101接口返回)
  6295. feedetailInfo["purc_retn_cnt"] = item.PurcRetnCnt // 人员编号 (来自1101接口返回)
  6296. feedetailInfo["purc_invo_codg"] = item.PurcInvoCodg // 人员编号 (来自1101接口返回)
  6297. feedetailInfo["purc_invo_no"] = item.PurcInvoNo // 人员编号 (来自1101接口返回)
  6298. feedetailInfo["rx_flag"] = item.RxFlag // 人员编号 (来自1101接口返回)
  6299. feedetailInfo["purc_retn_stoin_time"] = item.PurcRetnStoinTime // 人员编号 (来自1101接口返回)
  6300. feedetailInfo["purc_retn_opter_name"] = item.PurcRetnOpterName // 人员编号 (来自1101接口返回)
  6301. feedetailInfo["prod_geay_flag"] = "" // 人员编号 (来自1101接口返回)
  6302. feedetailInfo["memo"] = "" // 人员编号 (来自1101接口返回)
  6303. input["purcinfo"] = feedetailInfo
  6304. inputMessage["input"] = input //交易输入
  6305. bytesData, err := json.Marshal(inputMessage)
  6306. fmt.Println(string(bytesData))
  6307. if err != nil {
  6308. fmt.Println(err.Error())
  6309. return err.Error(), ""
  6310. }
  6311. reader := bytes.NewReader(bytesData)
  6312. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6313. gdyb_url := beego.AppConfig.String("gdyb_url")
  6314. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6315. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6316. url := gdyb_url + "3503"
  6317. request, err := http.NewRequest("POST", url, reader)
  6318. if err != nil {
  6319. fmt.Println(err.Error())
  6320. return err.Error(), ""
  6321. }
  6322. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6323. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6324. request.Header.Set("x-tif-signature", signature)
  6325. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6326. request.Header.Set("x-tif-nonce", nonce)
  6327. client := http.Client{}
  6328. resp, err := client.Do(request)
  6329. if err != nil {
  6330. fmt.Println(err.Error())
  6331. return err.Error(), ""
  6332. }
  6333. respBytes, err := ioutil.ReadAll(resp.Body)
  6334. if err != nil {
  6335. fmt.Println(err.Error())
  6336. return err.Error(), ""
  6337. }
  6338. str := string(respBytes)
  6339. fmt.Println(str)
  6340. return str, string(bytesData)
  6341. }
  6342. func Gdyb3504(struct3504 models.Struct3504, secret_key string) (string, string) {
  6343. // 生成签名
  6344. nonce := GetRandomString(32)
  6345. timestamp := time.Now().Unix()
  6346. signature := setSignature(timestamp, nonce, secret_key)
  6347. // 生成输入报文
  6348. inputMessage := SetGdInputMessage(timestamp, struct3504.OrgName, struct3504.Opter, struct3504.FixmedinsCode, struct3504.InsuplcAdmdvs, struct3504.MdtrtareaAdmvs, struct3504.Cainfo)
  6349. input := make(map[string]interface{})
  6350. inputData := make(map[string]interface{})
  6351. inputMessage["infno"] = "3504" // 交易编码
  6352. inputData["med_list_codg"] = struct3504.MedListCodg // 定点医药机构目录编号
  6353. inputData["fixmedins_hilist_id"] = struct3504.FixmedinsHilistId // 定点医药机构目录编号
  6354. inputData["fixmedins_hilist_name"] = struct3504.FixmedinsHilistName // 定点医药机构目录名称
  6355. inputData["fixmedins_bchno"] = struct3504.FixmedinsBchno // 人员编号 (来自1101接口返回)
  6356. inputData["spler_name"] = struct3504.SplerName // 人员编号 (来自1101接口返回)
  6357. inputData["spler_pmtno"] = "" // 人员编号 (来自1101接口返回)
  6358. inputData["manu_date"] = struct3504.ManuDate // 人员编号 (来自1101接口返回)
  6359. inputData["expy_end"] = struct3504.ExpyEnd // 人员编号 (来自1101接口返回)
  6360. inputData["finl_trns_pric"] = struct3504.FinlTrnsPric // 人员编号 (来自1101接口返回)
  6361. inputData["purc_retn_cnt"] = struct3504.PurcRetnCnt // 人员编号 (来自1101接口返回)
  6362. inputData["purc_invo_codg"] = struct3504.PurcInvoCodg // 人员编号 (来自1101接口返回)
  6363. inputData["purc_invo_no"] = struct3504.PurcInvoNo // 人员编号 (来自1101接口返回)
  6364. inputData["rx_flag"] = struct3504.RxFlag // 人员编号 (来自1101接口返回)
  6365. inputData["purc_retn_stoin_time"] = struct3504.PurcRetnStoinTime // 人员编号 (来自1101接口返回)
  6366. inputData["purc_retn_opter_name"] = struct3504.PurcRetnOpterName // 人员编号 (来自1101接口返回)
  6367. inputData["medins_prod_purc_no"] = "" // 人员编号 (来自1101接口返回)
  6368. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  6369. input["purcinfo"] = inputData
  6370. inputMessage["input"] = input //交易输入
  6371. bytesData, err := json.Marshal(inputMessage)
  6372. fmt.Println(string(bytesData))
  6373. if err != nil {
  6374. fmt.Println(err.Error())
  6375. return err.Error(), ""
  6376. }
  6377. reader := bytes.NewReader(bytesData)
  6378. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6379. gdyb_url := beego.AppConfig.String("gdyb_url")
  6380. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6381. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6382. url := gdyb_url + "3504"
  6383. request, err := http.NewRequest("POST", url, reader)
  6384. if err != nil {
  6385. fmt.Println(err.Error())
  6386. return err.Error(), ""
  6387. }
  6388. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6389. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6390. request.Header.Set("x-tif-signature", signature)
  6391. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6392. request.Header.Set("x-tif-nonce", nonce)
  6393. client := http.Client{}
  6394. resp, err := client.Do(request)
  6395. if err != nil {
  6396. fmt.Println(err.Error())
  6397. return err.Error(), ""
  6398. }
  6399. respBytes, err := ioutil.ReadAll(resp.Body)
  6400. if err != nil {
  6401. fmt.Println(err.Error())
  6402. return err.Error(), ""
  6403. }
  6404. str := string(respBytes)
  6405. fmt.Println(str)
  6406. return str, string(bytesData)
  6407. }
  6408. func Gdyb3505(struct3505 models.Struct3505, secret_key string) (string, string) {
  6409. // 生成签名
  6410. nonce := GetRandomString(32)
  6411. timestamp := time.Now().Unix()
  6412. signature := setSignature(timestamp, nonce, secret_key)
  6413. // 生成输入报文
  6414. inputMessage := SetGdInputMessage(timestamp, struct3505.OrgName, struct3505.Opter, struct3505.FixmedinsHilistId, struct3505.InsuplcAdmdvs, struct3505.MdtrtareaAdmvs, struct3505.Cainfo)
  6415. input := make(map[string]interface{})
  6416. inputData := make(map[string]interface{})
  6417. inputMessage["infno"] = "3505" // 交易编码
  6418. inputData["med_list_codg"] = struct3505.MedListCodg // 定点医药机构目录编号
  6419. inputData["fixmedins_hilist_id"] = struct3505.FixmedinsHilistId // 定点医药机构目录编号
  6420. inputData["fixmedins_hilist_name"] = struct3505.FixmedinsHilistName // 定点医药机构目录名称
  6421. inputData["fixmedins_bchno"] = struct3505.FixmedinsBchno // 人员编号 (来自1101接口返回)
  6422. inputData["prsc_dr_cert_type"] = struct3505.PrscDrCertType // 人员编号 (来自1101接口返回)
  6423. inputData["prsc_dr_certno"] = struct3505.PrscDrCertno // 人员编号 (来自1101接口返回)
  6424. inputData["prsc_dr_name"] = struct3505.PrscDrName // 人员编号 (来自1101接口返回)
  6425. inputData["phar_cert_type"] = struct3505.PharCertType // 人员编号 (来自1101接口返回)
  6426. inputData["phar_certno"] = struct3505.PharCertno // 人员编号 (来自1101接口返回)
  6427. inputData["phar_name"] = struct3505.PharName // 人员编号 (来自1101接口返回)
  6428. inputData["phar_prac_cert_no"] = struct3505.PharPracCertNo // 人员编号 (来自1101接口返回)
  6429. inputData["hi_feesetl_type"] = struct3505.HiFeesetlType // 人员编号 (来自1101接口返回)
  6430. inputData["setl_id"] = struct3505.SetlId // 人员编号 (来自1101接口返回)
  6431. inputData["mdtrt_sn"] = struct3505.MdtrtSn // 人员编号 (来自1101接口返回)
  6432. inputData["psn_no"] = struct3505.PsnNo // 人员编号 (来自1101接口返回)
  6433. inputData["psn_cert_type"] = struct3505.PsnCertType // 人员编号 (来自1101接口返回)
  6434. inputData["certno"] = struct3505.CertNo // 人员编号 (来自1101接口返回)
  6435. inputData["psn_name"] = struct3505.PsnName // 人员编号 (来自1101接口返回)
  6436. inputData["manu_lotnum"] = struct3505.ManuLotnum // 人员编号 (来自1101接口返回)
  6437. inputData["manu_date"] = struct3505.ManuDate // 人员编号 (来自1101接口返回)
  6438. inputData["expy_end"] = struct3505.ExpyEnd // 人员编号 (来自1101接口返回)
  6439. inputData["rx_flag"] = struct3505.RxFlag // 人员编号 (来自1101接口返回)
  6440. inputData["trdn_flag"] = struct3505.TrdnFlag // 人员编号 (来自1101接口返回)
  6441. inputData["finl_trns_pric"] = struct3505.FinlTrnsPric // 人员编号 (来自1101接口返回)
  6442. inputData["rxno"] = struct3505.Rxno // 人员编号 (来自1101接口返回)
  6443. inputData["rx_circ_flag"] = struct3505.RxCircFlag // 人员编号 (来自1101接口返回)
  6444. inputData["rtal_docno"] = struct3505.RtalDocno // 人员编号 (来自1101接口返回)
  6445. inputData["stoout_no"] = struct3505.StooutNo // 人员编号 (来自1101接口返回)
  6446. inputData["bchno"] = struct3505.Bchno // 人员编号 (来自1101接口返回)
  6447. inputData["drug_trac_codg"] = struct3505.DrugTracCodg // 人员编号 (来自1101接口返回)
  6448. inputData["drug_prod_barc"] = struct3505.DrugProdBarc // 人员编号 (来自1101接口返回)
  6449. inputData["shelf_posi"] = struct3505.ShelfPosi // 人员编号 (来自1101接口返回)
  6450. inputData["sel_retn_cnt"] = struct3505.SelRetnCnt // 人员编号 (来自1101接口返回)
  6451. inputData["sel_retn_time"] = struct3505.SelRetnTime // 人员编号 (来自1101接口返回)
  6452. inputData["sel_retn_opter_name"] = struct3505.SelRetnOpterName // 人员编号 (来自1101接口返回)
  6453. inputData["memo"] = struct3505.Memo // 人员编号 (来自1101接口返回)
  6454. //input["selinfo"] = inputData
  6455. feedetail := make([]map[string]interface{}, 0)
  6456. codes := strings.Split(struct3505.DrugTracCodg,",")
  6457. for _,item := range codes{
  6458. druginputData := make(map[string]interface{})
  6459. druginputData["drug_trac_codg"] = item
  6460. feedetail = append(feedetail,druginputData)
  6461. }
  6462. inputData["drugtracinfo"] = feedetail
  6463. input["selinfo"] = inputData
  6464. inputMessage["input"] = input //交易输入
  6465. bytesData, err := json.Marshal(inputMessage)
  6466. fmt.Println(string(bytesData))
  6467. if err != nil {
  6468. fmt.Println(err.Error())
  6469. return err.Error(), ""
  6470. }
  6471. reader := bytes.NewReader(bytesData)
  6472. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6473. gdyb_url := beego.AppConfig.String("gdyb_url")
  6474. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6475. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6476. url := gdyb_url + "3505"
  6477. request, err := http.NewRequest("POST", url, reader)
  6478. if err != nil {
  6479. fmt.Println(err.Error())
  6480. return err.Error(), ""
  6481. }
  6482. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6483. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6484. request.Header.Set("x-tif-signature", signature)
  6485. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6486. request.Header.Set("x-tif-nonce", nonce)
  6487. client := http.Client{}
  6488. resp, err := client.Do(request)
  6489. if err != nil {
  6490. fmt.Println(err.Error())
  6491. return err.Error(), ""
  6492. }
  6493. respBytes, err := ioutil.ReadAll(resp.Body)
  6494. if err != nil {
  6495. fmt.Println(err.Error())
  6496. return err.Error(), ""
  6497. }
  6498. str := string(respBytes)
  6499. fmt.Println(str)
  6500. return str, ""
  6501. }
  6502. func Gdyb3506(struct3506 models.Struct3506, secret_key string) (string, string) {
  6503. // 生成签名
  6504. nonce := GetRandomString(32)
  6505. timestamp := time.Now().Unix()
  6506. signature := setSignature(timestamp, nonce, secret_key)
  6507. // 生成输入报文
  6508. inputMessage := SetGdInputMessage(timestamp, struct3506.OrgName, struct3506.Opter, struct3506.FixmedinsCode, struct3506.InsuplcAdmdvs, struct3506.MdtrtareaAdmvs, struct3506.Cainfo)
  6509. input := make(map[string]interface{})
  6510. inputData := make(map[string]interface{})
  6511. inputMessage["infno"] = "3506" // 交易编码
  6512. inputData["med_list_codg"] = struct3506.MedListCodg // 定点医药机构目录编号
  6513. inputData["fixmedins_hilist_id"] = struct3506.FixmedinsHilistId // 定点医药机构目录编号
  6514. inputData["fixmedins_hilist_name"] = struct3506.FixmedinsHilistName // 定点医药机构目录名称
  6515. inputData["fixmedins_bchno"] = struct3506.FixmedinsBchno // 人员编号 (来自1101接口返回)
  6516. inputData["setl_id"] = struct3506.SetlId // 人员编号 (来自1101接口返回)
  6517. inputData["psn_no"] = struct3506.PsnNo // 人员编号 (来自1101接口返回)
  6518. inputData["psn_cert_type"] = struct3506.PsnCertType // 人员编号 (来自1101接口返回)
  6519. inputData["certno"] = struct3506.Certno // 人员编号 (来自1101接口返回)
  6520. inputData["psn_name"] = struct3506.PsnName // 人员编号 (来自1101接口返回)
  6521. inputData["manu_lotnum"] = struct3506.ManuLotnum // 人员编号 (来自1101接口返回)
  6522. inputData["manu_date"] = struct3506.ManuDate // 人员编号 (来自1101接口返回)
  6523. inputData["expy_end"] = struct3506.ExpyEnd // 人员编号 (来自1101接口返回)
  6524. inputData["rx_flag"] = struct3506.RxFlag // 人员编号 (来自1101接口返回)
  6525. inputData["trdn_flag"] = struct3506.TrdnFlag // 人员编号 (来自1101接口返回)
  6526. inputData["finl_trns_pric"] = struct3506.FinlTrnsPric // 人员编号 (来自1101接口返回)
  6527. inputData["sel_retn_cnt"] = struct3506.SelRetnCnt // 人员编号 (来自1101接口返回)
  6528. inputData["sel_retn_time"] = struct3506.SelRetnTime // 人员编号 (来自1101接口返回)
  6529. inputData["sel_retn_opter_name"] = struct3506.SelRetnOpterName // 人员编号 (来自1101接口返回)
  6530. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  6531. inputData["medins_prod_sel_no"] = "" // 人员编号 (来自1101接口返回)
  6532. input["selinfo"] = inputData
  6533. inputMessage["input"] = input //交易输入
  6534. bytesData, err := json.Marshal(inputMessage)
  6535. fmt.Println(string(bytesData))
  6536. if err != nil {
  6537. fmt.Println(err.Error())
  6538. return err.Error(), ""
  6539. }
  6540. reader := bytes.NewReader(bytesData)
  6541. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6542. gdyb_url := beego.AppConfig.String("gdyb_url")
  6543. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6544. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6545. url := gdyb_url + "3506"
  6546. request, err := http.NewRequest("POST", url, reader)
  6547. if err != nil {
  6548. fmt.Println(err.Error())
  6549. return err.Error(), ""
  6550. }
  6551. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6552. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6553. request.Header.Set("x-tif-signature", signature)
  6554. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6555. request.Header.Set("x-tif-nonce", nonce)
  6556. client := http.Client{}
  6557. resp, err := client.Do(request)
  6558. if err != nil {
  6559. fmt.Println(err.Error())
  6560. return err.Error(), ""
  6561. }
  6562. respBytes, err := ioutil.ReadAll(resp.Body)
  6563. if err != nil {
  6564. fmt.Println(err.Error())
  6565. return err.Error(), ""
  6566. }
  6567. str := string(respBytes)
  6568. fmt.Println(str)
  6569. return str, string(bytesData)
  6570. }
  6571. func Gdyb3507(struct3507 models.Struct3507, secret_key string) (string, string) {
  6572. // 生成签名
  6573. nonce := GetRandomString(32)
  6574. timestamp := time.Now().Unix()
  6575. signature := setSignature(timestamp, nonce, secret_key)
  6576. // 生成输入报文
  6577. inputMessage := SetGdInputMessage(timestamp, struct3507.OrgName, struct3507.Opter, struct3507.FixmedinsCode, struct3507.InsuplcAdmdvs, struct3507.MdtrtareaAdmvs, struct3507.Cainfo)
  6578. input := make(map[string]interface{})
  6579. inputData := make(map[string]interface{})
  6580. inputMessage["infno"] = "3507" // 交易编码
  6581. inputData["fixmedins_bchno"] = struct3507.FixmedinsCode // 人员编号 (来自1101接口返回)
  6582. inputData["inv_data_type"] = struct3507.InvDataType // 人员编号 (来自1101接口返回)
  6583. input["data"] = inputData
  6584. inputMessage["input"] = input //交易输入
  6585. bytesData, err := json.Marshal(inputMessage)
  6586. fmt.Println(string(bytesData))
  6587. if err != nil {
  6588. fmt.Println(err.Error())
  6589. return err.Error(), ""
  6590. }
  6591. reader := bytes.NewReader(bytesData)
  6592. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6593. gdyb_url := beego.AppConfig.String("gdyb_url")
  6594. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6595. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6596. url := gdyb_url + "3507"
  6597. request, err := http.NewRequest("POST", url, reader)
  6598. if err != nil {
  6599. fmt.Println(err.Error())
  6600. return err.Error(), ""
  6601. }
  6602. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6603. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6604. request.Header.Set("x-tif-signature", signature)
  6605. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6606. request.Header.Set("x-tif-nonce", nonce)
  6607. client := http.Client{}
  6608. resp, err := client.Do(request)
  6609. if err != nil {
  6610. fmt.Println(err.Error())
  6611. return err.Error(), ""
  6612. }
  6613. respBytes, err := ioutil.ReadAll(resp.Body)
  6614. if err != nil {
  6615. fmt.Println(err.Error())
  6616. return err.Error(), ""
  6617. }
  6618. str := string(respBytes)
  6619. fmt.Println(str)
  6620. return str, string(bytesData)
  6621. }
  6622. func Gdyb3508(struct3508 models.Struct3508, secret_key string) (string, string) {
  6623. // 生成签名
  6624. nonce := GetRandomString(32)
  6625. timestamp := time.Now().Unix()
  6626. signature := setSignature(timestamp, nonce, secret_key)
  6627. // 生成输入报文
  6628. inputMessage := SetGdInputMessage(timestamp, struct3508.OrgName, struct3508.Opter, struct3508.FixmedinsCode, struct3508.InsuplcAdmdvs, struct3508.MdtrtareaAdmvs, struct3508.Cainfo)
  6629. input := make(map[string]interface{})
  6630. inputData := make(map[string]interface{})
  6631. inputMessage["infno"] = "3508"
  6632. inputData["fixmedins_code"] = struct3508.FixmedinsCode
  6633. inputData["medins_list_codg"] = struct3508.MedListCodg
  6634. inputData["fixmedins_bchno"] = ""
  6635. inputData["begndate"] = struct3508.Begndate
  6636. inputData["enddate"] = struct3508.Enddate
  6637. inputData["medins_prod_inv_no"] = ""
  6638. inputData["medins_list_name"] = ""
  6639. inputData["rx_flag"] = ""
  6640. inputData["list_sp_item_flag"] = ""
  6641. inputData["trdn_flag"] = ""
  6642. inputData["invdate"] = ""
  6643. inputData["manu_lotnum"] = ""
  6644. inputData["manu_date"] = ""
  6645. inputData["expy_end"] = ""
  6646. inputData["memo"] = ""
  6647. inputData["vali_flag"] = ""
  6648. inputData["rid"] = ""
  6649. inputData["crter_id"] = ""
  6650. inputData["crter_name"] = ""
  6651. inputData["crte_optins_no"] = ""
  6652. inputData["opter_id"] = ""
  6653. inputData["opter_name"] = ""
  6654. inputData["optins_no"] = ""
  6655. inputData["poolarea_no"] = ""
  6656. inputData["fixmedins_bchno"] = ""
  6657. inputData["inv_data_type"] = ""
  6658. input["data"] = inputData
  6659. inputMessage["input"] = input //交易输入
  6660. bytesData, err := json.Marshal(inputMessage)
  6661. fmt.Println(string(bytesData))
  6662. if err != nil {
  6663. fmt.Println(err.Error())
  6664. return err.Error(), ""
  6665. }
  6666. reader := bytes.NewReader(bytesData)
  6667. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6668. gdyb_url := beego.AppConfig.String("gdyb_url")
  6669. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6670. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6671. url := gdyb_url + "3508"
  6672. request, err := http.NewRequest("POST", url, reader)
  6673. if err != nil {
  6674. fmt.Println(err.Error())
  6675. return err.Error(), ""
  6676. }
  6677. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6678. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6679. request.Header.Set("x-tif-signature", signature)
  6680. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6681. request.Header.Set("x-tif-nonce", nonce)
  6682. client := http.Client{}
  6683. resp, err := client.Do(request)
  6684. if err != nil {
  6685. fmt.Println(err.Error())
  6686. return err.Error(), ""
  6687. }
  6688. respBytes, err := ioutil.ReadAll(resp.Body)
  6689. if err != nil {
  6690. fmt.Println(err.Error())
  6691. return err.Error(), ""
  6692. }
  6693. str := string(respBytes)
  6694. fmt.Println(str)
  6695. return str, string(bytesData)
  6696. }
  6697. func Gdyb3509(struct3509 models.Struct3509, secret_key string) (string, string) {
  6698. // 生成签名
  6699. nonce := GetRandomString(32)
  6700. timestamp := time.Now().Unix()
  6701. signature := setSignature(timestamp, nonce, secret_key)
  6702. // 生成输入报文
  6703. inputMessage := SetGdInputMessage(timestamp, struct3509.OrgName, struct3509.Opter, struct3509.FixmedinsCode, struct3509.InsuplcAdmdvs, struct3509.MdtrtareaAdmvs, struct3509.Cainfo)
  6704. input := make(map[string]interface{})
  6705. inputData := make(map[string]interface{})
  6706. inputMessage["infno"] = "3509"
  6707. inputData["fixmedins_code"] = struct3509.FixmedinsCode
  6708. //inputData["med_list_codg"] = struct3509.MedinsListCodg
  6709. inputData["medins_list_codg"] = struct3509.MedListCodg
  6710. inputData["fixmedins_bchno"] = ""
  6711. inputData["begndate"] = struct3509.Begndate
  6712. inputData["enddate"] = struct3509.Enddate
  6713. inputData["medins_prod_inv_no"] = ""
  6714. inputData["medins_list_name"] = ""
  6715. inputData["rx_flag"] = ""
  6716. inputData["list_sp_item_flag"] = ""
  6717. inputData["trdn_flag"] = ""
  6718. inputData["invdate"] = ""
  6719. inputData["manu_lotnum"] = ""
  6720. inputData["manu_date"] = ""
  6721. inputData["expy_end"] = ""
  6722. inputData["memo"] = ""
  6723. inputData["vali_flag"] = ""
  6724. inputData["rid"] = ""
  6725. inputData["crter_id"] = ""
  6726. inputData["crter_name"] = ""
  6727. inputData["crte_optins_no"] = ""
  6728. inputData["opter_id"] = ""
  6729. inputData["opter_name"] = ""
  6730. inputData["optins_no"] = ""
  6731. inputData["poolarea_no"] = ""
  6732. inputData["fixmedins_bchno"] = ""
  6733. inputData["inv_data_type"] = ""
  6734. input["data"] = inputData
  6735. inputMessage["input"] = input //交易输入
  6736. bytesData, err := json.Marshal(inputMessage)
  6737. fmt.Println(string(bytesData))
  6738. if err != nil {
  6739. fmt.Println(err.Error())
  6740. return err.Error(), ""
  6741. }
  6742. reader := bytes.NewReader(bytesData)
  6743. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6744. gdyb_url := beego.AppConfig.String("gdyb_url")
  6745. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6746. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6747. url := gdyb_url + "3509"
  6748. request, err := http.NewRequest("POST", url, reader)
  6749. if err != nil {
  6750. fmt.Println(err.Error())
  6751. return err.Error(), ""
  6752. }
  6753. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6754. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6755. request.Header.Set("x-tif-signature", signature)
  6756. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6757. request.Header.Set("x-tif-nonce", nonce)
  6758. client := http.Client{}
  6759. resp, err := client.Do(request)
  6760. if err != nil {
  6761. fmt.Println(err.Error())
  6762. return err.Error(), ""
  6763. }
  6764. respBytes, err := ioutil.ReadAll(resp.Body)
  6765. if err != nil {
  6766. fmt.Println(err.Error())
  6767. return err.Error(), ""
  6768. }
  6769. str := string(respBytes)
  6770. fmt.Println(str)
  6771. return str, string(bytesData)
  6772. }
  6773. func Gdyb3510(struct3510 models.Struct3510, secret_key string) (string, string) {
  6774. // 生成签名
  6775. nonce := GetRandomString(32)
  6776. timestamp := time.Now().Unix()
  6777. signature := setSignature(timestamp, nonce, secret_key)
  6778. // 生成输入报文
  6779. inputMessage := SetGdInputMessage(timestamp, struct3510.OrgName, struct3510.Opter, struct3510.FixmedinsCode, struct3510.InsuplcAdmdvs, struct3510.MdtrtareaAdmvs, struct3510.Cainfo)
  6780. input := make(map[string]interface{})
  6781. inputData := make(map[string]interface{})
  6782. inputMessage["infno"] = "3510"
  6783. inputData["fixmedins_code"] = struct3510.FixmedinsCode
  6784. //inputData["medins_list_codg"] = struct3510.MedinsListCodg
  6785. inputData["medins_list_codg"] = struct3510.MedListCodg
  6786. inputData["fixmedins_bchno"] = ""
  6787. inputData["begndate"] = struct3510.Begndate
  6788. inputData["enddate"] = struct3510.Enddate
  6789. inputData["medins_prod_inv_no"] = ""
  6790. inputData["medins_list_name"] = ""
  6791. inputData["rx_flag"] = ""
  6792. inputData["list_sp_item_flag"] = ""
  6793. inputData["trdn_flag"] = ""
  6794. inputData["invdate"] = ""
  6795. inputData["manu_lotnum"] = ""
  6796. inputData["manu_date"] = ""
  6797. inputData["expy_end"] = ""
  6798. inputData["memo"] = ""
  6799. inputData["vali_flag"] = ""
  6800. inputData["rid"] = ""
  6801. inputData["crter_id"] = ""
  6802. inputData["crter_name"] = ""
  6803. inputData["crte_optins_no"] = ""
  6804. inputData["opter_id"] = ""
  6805. inputData["opter_name"] = ""
  6806. inputData["optins_no"] = ""
  6807. inputData["poolarea_no"] = ""
  6808. inputData["fixmedins_bchno"] = ""
  6809. inputData["inv_data_type"] = ""
  6810. input["data"] = inputData
  6811. inputMessage["input"] = input //交易输入
  6812. bytesData, err := json.Marshal(inputMessage)
  6813. fmt.Println(string(bytesData))
  6814. if err != nil {
  6815. fmt.Println(err.Error())
  6816. return err.Error(), ""
  6817. }
  6818. reader := bytes.NewReader(bytesData)
  6819. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6820. gdyb_url := beego.AppConfig.String("gdyb_url")
  6821. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6822. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6823. url := gdyb_url + "3510"
  6824. request, err := http.NewRequest("POST", url, reader)
  6825. if err != nil {
  6826. fmt.Println(err.Error())
  6827. return err.Error(), ""
  6828. }
  6829. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6830. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6831. request.Header.Set("x-tif-signature", signature)
  6832. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6833. request.Header.Set("x-tif-nonce", nonce)
  6834. client := http.Client{}
  6835. resp, err := client.Do(request)
  6836. if err != nil {
  6837. fmt.Println(err.Error())
  6838. return err.Error(), ""
  6839. }
  6840. respBytes, err := ioutil.ReadAll(resp.Body)
  6841. if err != nil {
  6842. fmt.Println(err.Error())
  6843. return err.Error(), ""
  6844. }
  6845. str := string(respBytes)
  6846. fmt.Println(str)
  6847. return str, string(bytesData)
  6848. }
  6849. func Gdyb3511(struct3511 models.Struct3511, secret_key string) (string, string) {
  6850. // 生成签名
  6851. nonce := GetRandomString(32)
  6852. timestamp := time.Now().Unix()
  6853. signature := setSignature(timestamp, nonce, secret_key)
  6854. // 生成输入报文
  6855. inputMessage := SetGdInputMessage(timestamp, struct3511.OrgName, struct3511.Opter, struct3511.FixmedinsCode, struct3511.InsuplcAdmdvs, struct3511.MdtrtareaAdmvs, struct3511.Cainfo)
  6856. input := make(map[string]interface{})
  6857. inputData := make(map[string]interface{})
  6858. inputMessage["infno"] = "3511"
  6859. inputData["fixmedins_code"] = struct3511.FixmedinsCode
  6860. //inputData["medins_list_codg"] = struct3511.MedinsListCodg
  6861. inputData["medins_list_codg"] = struct3511.MedListCodg
  6862. inputData["fixmedins_bchno"] = ""
  6863. inputData["begndate"] = struct3511.Begndate
  6864. inputData["enddate"] = struct3511.Enddate
  6865. inputData["medins_prod_inv_no"] = ""
  6866. inputData["medins_list_name"] = ""
  6867. inputData["rx_flag"] = ""
  6868. inputData["list_sp_item_flag"] = ""
  6869. inputData["trdn_flag"] = ""
  6870. inputData["invdate"] = ""
  6871. inputData["manu_lotnum"] = ""
  6872. inputData["manu_date"] = ""
  6873. inputData["expy_end"] = ""
  6874. inputData["memo"] = ""
  6875. inputData["vali_flag"] = ""
  6876. inputData["rid"] = ""
  6877. inputData["crter_id"] = ""
  6878. inputData["crter_name"] = ""
  6879. inputData["crte_optins_no"] = ""
  6880. inputData["opter_id"] = ""
  6881. inputData["opter_name"] = ""
  6882. inputData["optins_no"] = ""
  6883. inputData["poolarea_no"] = ""
  6884. inputData["fixmedins_bchno"] = ""
  6885. inputData["inv_data_type"] = ""
  6886. input["data"] = inputData
  6887. inputMessage["input"] = input //交易输入
  6888. bytesData, err := json.Marshal(inputMessage)
  6889. fmt.Println(string(bytesData))
  6890. if err != nil {
  6891. fmt.Println(err.Error())
  6892. return err.Error(), ""
  6893. }
  6894. reader := bytes.NewReader(bytesData)
  6895. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6896. gdyb_url := beego.AppConfig.String("gdyb_url")
  6897. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6898. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6899. url := gdyb_url + "3511"
  6900. request, err := http.NewRequest("POST", url, reader)
  6901. if err != nil {
  6902. fmt.Println(err.Error())
  6903. return err.Error(), ""
  6904. }
  6905. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6906. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6907. request.Header.Set("x-tif-signature", signature)
  6908. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6909. request.Header.Set("x-tif-nonce", nonce)
  6910. client := http.Client{}
  6911. resp, err := client.Do(request)
  6912. if err != nil {
  6913. fmt.Println(err.Error())
  6914. return err.Error(), ""
  6915. }
  6916. respBytes, err := ioutil.ReadAll(resp.Body)
  6917. if err != nil {
  6918. fmt.Println(err.Error())
  6919. return err.Error(), ""
  6920. }
  6921. str := string(respBytes)
  6922. fmt.Println(str)
  6923. return str, string(bytesData)
  6924. }
  6925. func Gdyb3512(struct3512 models.Struct3512, secret_key string) (string, string) {
  6926. // 生成签名
  6927. nonce := GetRandomString(32)
  6928. timestamp := time.Now().Unix()
  6929. signature := setSignature(timestamp, nonce, secret_key)
  6930. // 生成输入报文
  6931. inputMessage := SetGdInputMessage(timestamp, struct3512.OrgName, struct3512.Opter, struct3512.FixmedinsCode, struct3512.InsuplcAdmdvs, struct3512.MdtrtareaAdmvs, struct3512.Cainfo)
  6932. input := make(map[string]interface{})
  6933. inputData := make(map[string]interface{})
  6934. inputMessage["infno"] = "3512"
  6935. inputData["fixmedins_code"] = struct3512.FixmedinsCode
  6936. //inputData["medins_list_codg"] = struct3512.MedinsListCodg
  6937. inputData["medins_list_codg"] = struct3512.MedListCodg
  6938. inputData["fixmedins_bchno"] = ""
  6939. inputData["begndate"] = struct3512.Begndate
  6940. inputData["enddate"] = struct3512.Enddate
  6941. inputData["medins_prod_inv_no"] = ""
  6942. inputData["medins_list_name"] = ""
  6943. inputData["rx_flag"] = ""
  6944. inputData["list_sp_item_flag"] = ""
  6945. inputData["trdn_flag"] = ""
  6946. inputData["invdate"] = ""
  6947. inputData["manu_lotnum"] = ""
  6948. inputData["manu_date"] = ""
  6949. inputData["expy_end"] = ""
  6950. inputData["memo"] = ""
  6951. inputData["vali_flag"] = ""
  6952. inputData["rid"] = ""
  6953. inputData["crter_id"] = ""
  6954. inputData["crter_name"] = ""
  6955. inputData["crte_optins_no"] = ""
  6956. inputData["opter_id"] = ""
  6957. inputData["opter_name"] = ""
  6958. inputData["optins_no"] = ""
  6959. inputData["poolarea_no"] = ""
  6960. inputData["fixmedins_bchno"] = ""
  6961. inputData["inv_data_type"] = ""
  6962. input["data"] = inputData
  6963. inputMessage["input"] = input //交易输入
  6964. bytesData, err := json.Marshal(inputMessage)
  6965. fmt.Println(string(bytesData))
  6966. if err != nil {
  6967. fmt.Println(err.Error())
  6968. return err.Error(), ""
  6969. }
  6970. reader := bytes.NewReader(bytesData)
  6971. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6972. gdyb_url := beego.AppConfig.String("gdyb_url")
  6973. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6974. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6975. url := gdyb_url + "3512"
  6976. request, err := http.NewRequest("POST", url, reader)
  6977. if err != nil {
  6978. fmt.Println(err.Error())
  6979. return err.Error(), ""
  6980. }
  6981. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6982. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6983. request.Header.Set("x-tif-signature", signature)
  6984. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6985. request.Header.Set("x-tif-nonce", nonce)
  6986. client := http.Client{}
  6987. resp, err := client.Do(request)
  6988. if err != nil {
  6989. fmt.Println(err.Error())
  6990. return err.Error(), ""
  6991. }
  6992. respBytes, err := ioutil.ReadAll(resp.Body)
  6993. if err != nil {
  6994. fmt.Println(err.Error())
  6995. return err.Error(), ""
  6996. }
  6997. str := string(respBytes)
  6998. fmt.Println(str)
  6999. return str, string(bytesData)
  7000. }
  7001. func Gdyb3513(struct3513 models.Struct3513, secret_key string) (string, string) {
  7002. // 生成签名
  7003. nonce := GetRandomString(32)
  7004. timestamp := time.Now().Unix()
  7005. signature := setSignature(timestamp, nonce, secret_key)
  7006. // 生成输入报文
  7007. inputMessage := SetGdInputMessage(timestamp, struct3513.OrgName, struct3513.Opter, struct3513.FixmedinsCode, struct3513.InsuplcAdmdvs, struct3513.MdtrtareaAdmvs, struct3513.Cainfo)
  7008. input := make(map[string]interface{})
  7009. inputData := make(map[string]interface{})
  7010. inputMessage["infno"] = "3513"
  7011. inputData["fixmedins_code"] = struct3513.FixmedinsCode
  7012. //inputData["medins_list_codg"] = struct3513.MedinsListCodg
  7013. inputData["medins_list_codg"] = struct3513.MedListCodg
  7014. inputData["fixmedins_bchno"] = ""
  7015. inputData["begndate"] = struct3513.Begndate
  7016. inputData["enddate"] = struct3513.Enddate
  7017. inputData["medins_prod_inv_no"] = ""
  7018. inputData["med_list_codg"] = ""
  7019. inputData["medins_list_name"] = ""
  7020. inputData["rx_flag"] = ""
  7021. inputData["list_sp_item_flag"] = ""
  7022. inputData["trdn_flag"] = ""
  7023. inputData["invdate"] = ""
  7024. inputData["manu_lotnum"] = ""
  7025. inputData["manu_date"] = ""
  7026. inputData["expy_end"] = ""
  7027. inputData["memo"] = ""
  7028. inputData["vali_flag"] = ""
  7029. inputData["rid"] = ""
  7030. inputData["crter_id"] = ""
  7031. inputData["crter_name"] = ""
  7032. inputData["crte_optins_no"] = ""
  7033. inputData["opter_id"] = ""
  7034. inputData["opter_name"] = ""
  7035. inputData["optins_no"] = ""
  7036. inputData["poolarea_no"] = ""
  7037. inputData["fixmedins_bchno"] = ""
  7038. inputData["inv_data_type"] = ""
  7039. input["data"] = inputData
  7040. inputMessage["input"] = input //交易输入
  7041. bytesData, err := json.Marshal(inputMessage)
  7042. fmt.Println(string(bytesData))
  7043. if err != nil {
  7044. fmt.Println(err.Error())
  7045. return err.Error(), ""
  7046. }
  7047. reader := bytes.NewReader(bytesData)
  7048. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7049. gdyb_url := beego.AppConfig.String("gdyb_url")
  7050. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7051. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7052. url := gdyb_url + "3513"
  7053. request, err := http.NewRequest("POST", url, reader)
  7054. if err != nil {
  7055. fmt.Println(err.Error())
  7056. return err.Error(), ""
  7057. }
  7058. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  7059. request.Header.Set("x-tif-paasid", gdyb_paasid)
  7060. request.Header.Set("x-tif-signature", signature)
  7061. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  7062. request.Header.Set("x-tif-nonce", nonce)
  7063. client := http.Client{}
  7064. resp, err := client.Do(request)
  7065. if err != nil {
  7066. fmt.Println(err.Error())
  7067. return err.Error(), ""
  7068. }
  7069. respBytes, err := ioutil.ReadAll(resp.Body)
  7070. if err != nil {
  7071. fmt.Println(err.Error())
  7072. return err.Error(), ""
  7073. }
  7074. str := string(respBytes)
  7075. fmt.Println(str)
  7076. return str, string(bytesData)
  7077. }
  7078. // 生成基础报文
  7079. func SetGdInputMessage(timestamp int64, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, cainfo string) map[string]interface{} {
  7080. // 生成签名
  7081. tempTime := time.Unix(timestamp, 0)
  7082. //timeFormat := tempTime.Format("20060102150405")
  7083. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  7084. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  7085. month := time.Unix(1557042972, 0).Format("1")
  7086. year := time.Now().Format("2006")
  7087. month = time.Now().Format("01")
  7088. day := time.Now().Format("02")
  7089. hour := time.Now().Format("15")
  7090. min := time.Now().Format("04")
  7091. sec := time.Now().Format("05")
  7092. msec := time.Now().Format("000")
  7093. // 生成输入报文
  7094. inputMessage := make(map[string]interface{})
  7095. inputMessage["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  7096. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  7097. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  7098. inputMessage["recer_sys_code"] = "MBS_LOCAL" // 接收方系统代码
  7099. inputMessage["dev_no"] = "1" // 设备编号
  7100. inputMessage["dev_safe_info"] = "1" // 设备安全信息
  7101. inputMessage["cainfo"] = cainfo // 数字签名信息
  7102. inputMessage["signtype"] = "SM3" // 签名类型
  7103. inputMessage["infver"] = "1.0.0" // 接收方系统代码
  7104. inputMessage["opter_type"] = "1" // 经办人类别
  7105. inputMessage["opter"] = doctor // 经办人
  7106. inputMessage["opter_name"] = doctor // 经办人姓名
  7107. inputMessage["inf_time"] = timeFormatOne // 交易时间
  7108. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  7109. inputMessage["fixmedins_name"] = org_name
  7110. inputMessage["fixmedins_soft_fcty"] = "深圳市领透科技有限公司" //定点医药机构名称
  7111. //定点医药机构名称
  7112. inputMessage["sign_no"] = "" //交易签到流水号
  7113. return inputMessage
  7114. }
  7115. 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) {
  7116. nonce := GetRandomString(32)
  7117. timestamp := time.Now().Unix()
  7118. signature := setSignature(timestamp, nonce, params.SecretKey)
  7119. // 生成输入报文
  7120. inputMessage := SetGdInputMessage(timestamp, params.FixmedinsName, params.OpterName, params.FixmedinsCode, params.InsuplcAdmdvs, params.MdtrtareaAdmvs, params.Cainfo)
  7121. //inputMessage := SetJSInputMessage(timestamp, params.FixmedinsName, params.OpterName, params.FixmedinsCode, params.InsuplcAdmdvs, params.MdtrtareaAdmvs, params.Cainfo)
  7122. input := make(map[string]interface{})
  7123. inputData := make(map[string]interface{})
  7124. patientDtosinputData := make(map[string]interface{})
  7125. fisEncounterDtosData := make(map[string]interface{})
  7126. fsiDiagnoseDtosDatas := make([]map[string]interface{}, 0)
  7127. fsiOrderDtosDatas := make([]map[string]interface{}, 0)
  7128. fsiOperationDtosData := make(map[string]interface{})
  7129. fsiOperationDtosDatas := make([]map[string]interface{}, 0)
  7130. //就诊信息
  7131. fisEncounterDtosData["mdtrt_id"] = fed.MdtrtID
  7132. fisEncounterDtosData["medins_id"] = fed.MedinsID
  7133. fisEncounterDtosData["medins_name"] = fed.MedinsName
  7134. fisEncounterDtosData["medins_admdvs"] = fed.MedinsAdmdvs
  7135. fisEncounterDtosData["medins_type"] = fed.MedinsType
  7136. fisEncounterDtosData["medins_lv"] = fed.MedinsLv
  7137. fisEncounterDtosData["wardarea_codg"] = fed.WardareaCodg
  7138. fisEncounterDtosData["wardno"] = fed.Wardno
  7139. fisEncounterDtosData["bedno"] = fed.Bedno
  7140. fisEncounterDtosData["adm_date"] = fed.AdmDate
  7141. fisEncounterDtosData["dscg_date"] = fed.DscgDate
  7142. fisEncounterDtosData["dscg_main_dise_codg"] = fed.DscgMainDiseCodg
  7143. fisEncounterDtosData["dscg_main_dise_name"] = fed.DscgMainDiseName
  7144. for _, fdd := range fdds {
  7145. fsiDiagnoseDtosData := make(map[string]interface{})
  7146. //诊断集合
  7147. fsiDiagnoseDtosData["dise_id"] = fdd.DiseID
  7148. fsiDiagnoseDtosData["inout_dise_type"] = fdd.InoutDiseType
  7149. fsiDiagnoseDtosData["maindise_flag"] = fdd.MaindiseFlag
  7150. fsiDiagnoseDtosData["dias_srt_no"] = fdd.DiasSrtNo
  7151. fsiDiagnoseDtosData["dise_codg"] = fdd.DiseCodg
  7152. fsiDiagnoseDtosData["dise_name"] = fdd.DiseName
  7153. fsiDiagnoseDtosData["dise_date"] = fdd.DiseDate
  7154. fsiDiagnoseDtosDatas = append(fsiDiagnoseDtosDatas, fsiDiagnoseDtosData)
  7155. }
  7156. fisEncounterDtosData["fsi_diagnose_dtos"] = fsiDiagnoseDtosDatas
  7157. fisEncounterDtosData["dr_codg"] = fed.DrCodg
  7158. fisEncounterDtosData["adm_dept_codg"] = fed.AdmDeptCodg
  7159. fisEncounterDtosData["adm_dept_name"] = fed.AdmDeptName
  7160. fisEncounterDtosData["dscg_dept_codg"] = fed.DscgDeptCodg
  7161. fisEncounterDtosData["dscg_dept_name"] = fed.DscgDeptName
  7162. fisEncounterDtosData["med_mdtrt_type"] = fed.MedMdtrtType
  7163. fisEncounterDtosData["med_type"] = fed.MedType
  7164. for _, fod := range fods {
  7165. fsiOrderDtosData := make(map[string]interface{})
  7166. //医嘱集合
  7167. fsiOrderDtosData["rx_id"] = fod.RxID
  7168. fsiOrderDtosData["rxno"] = fod.Rxno
  7169. fsiOrderDtosData["grpno"] = fod.Grpno
  7170. fsiOrderDtosData["long_drord_flag"] = fod.LongDrordFlag
  7171. fsiOrderDtosData["hilist_type"] = fod.HilistType
  7172. fsiOrderDtosData["chrg_type"] = fod.ChrgType
  7173. fsiOrderDtosData["drord_bhvr"] = fod.DrordBhvr
  7174. fsiOrderDtosData["hilist_code"] = fod.HilistCode
  7175. fsiOrderDtosData["hilist_name"] = fod.HosplistName
  7176. fsiOrderDtosData["hilist_dosform"] = fod.HilistDosform
  7177. fsiOrderDtosData["hilist_lv"] = fod.HilistLv
  7178. fsiOrderDtosData["hilist_pric"] = fod.HilistPric
  7179. fsiOrderDtosData["lv1_hosp_item_pric"] = fod.Lv1HospItemPric
  7180. fsiOrderDtosData["lv2_hosp_item_pric"] = fod.Lv2HospItemPric
  7181. fsiOrderDtosData["lv3_hosp_item_pric"] = fod.Lv3HospItemPric
  7182. fsiOrderDtosData["hilist_memo"] = fod.HilistMemo
  7183. fsiOrderDtosData["hosplist_code"] = fod.HosplistCode
  7184. fsiOrderDtosData["hosplist_name"] = fod.HosplistName
  7185. fsiOrderDtosData["hosplist_dosform"] = fod.HosplistDosform
  7186. fsiOrderDtosData["cnt"] = fod.Cnt
  7187. fsiOrderDtosData["pric"] = fod.Pric
  7188. fsiOrderDtosData["sumamt"] = fod.Sumamt
  7189. fsiOrderDtosData["ownpay_amt"] = fod.OwnpayAmt
  7190. fsiOrderDtosData["selfpay_amt"] = fod.SelfpayAmt
  7191. fsiOrderDtosData["spec"] = fod.Spec
  7192. fsiOrderDtosData["spec_unt"] = fod.SpecUnt
  7193. fsiOrderDtosData["drord_begn_date"] = fod.DrordBegnDate
  7194. fsiOrderDtosData["drord_stop_date"] = fod.DrordStopDate
  7195. fsiOrderDtosData["drord_dept_codg"] = fod.DrordDeptCodg
  7196. fsiOrderDtosData["drord_dept_name"] = fod.DrordDeptName
  7197. fsiOrderDtosData["drord_dr_codg"] = fod.DrordDrCodg
  7198. fsiOrderDtosData["drord_dr_name"] = fod.DrordDrName
  7199. fsiOrderDtosData["drord_dr_profttl"] = fod.DrordDrProfttl
  7200. fsiOrderDtosData["curr_drord_flag"] = fod.CurrDrordFlag
  7201. fsiOrderDtosDatas = append(fsiOrderDtosDatas, fsiOrderDtosData)
  7202. }
  7203. fisEncounterDtosData["fsi_order_dtos"] = fsiOrderDtosDatas
  7204. fisEncounterDtosData["matn_stas"] = fed.MatnStas
  7205. fisEncounterDtosData["medfee_sumamt"] = fed.MedfeeSumamt
  7206. fisEncounterDtosData["ownpay_amt"] = fed.OwnpayAmt
  7207. fisEncounterDtosData["selfpay_amt"] = fed.SelfpayAmt
  7208. fisEncounterDtosData["acct_payamt"] = fed.AcctPayamt
  7209. fisEncounterDtosData["ma_amt"] = fed.MaAmt
  7210. fisEncounterDtosData["hifp_payamt"] = fed.HifpPayamt
  7211. fisEncounterDtosData["setl_totlnum"] = fed.SetlTotlnum
  7212. fisEncounterDtosData["insutype"] = fed.Insutype
  7213. fisEncounterDtosData["reim_flag"] = fed.ReimFlag
  7214. fisEncounterDtosData["out_setl_flag"] = fed.OutSetlFlag
  7215. //手术操作
  7216. for _, fopd := range fopds {
  7217. fsiOperationDtosData["setl_list_oprn_id"] = fopd.Setl_list_oprn_id
  7218. fsiOperationDtosData["oprn_code"] = fopd.Oprn_code
  7219. fsiOperationDtosData["oprn_name"] = fopd.Oprn_name
  7220. fsiOperationDtosData["main_oprn_flag"] = fopd.Main_oprn_flag
  7221. fsiOperationDtosData["oprn_date"] = fopd.Oprn_date
  7222. fsiOperationDtosData["anst_way"] = fopd.Anst_way
  7223. fsiOperationDtosData["oper_dr_name"] = fopd.Oper_dr_name
  7224. fsiOperationDtosData["oper_dr_code"] = fopd.Oper_dr_code
  7225. fsiOperationDtosData["anst_dr_name"] = fopd.Anst_dr_name
  7226. fsiOperationDtosData["anst_dr_code"] = fopd.Anst_dr_code
  7227. fsiOperationDtosDatas = append(fsiOperationDtosDatas, fsiOperationDtosData)
  7228. }
  7229. fisEncounterDtosData["fsi_operation_dtos"] = fsiOperationDtosDatas
  7230. patientDtosinputData["patn_id"] = pd.PatnID
  7231. patientDtosinputData["patn_name"] = pd.PatnName
  7232. patientDtosinputData["gend"] = pd.Gend
  7233. patientDtosinputData["brdy"] = pd.Brdy
  7234. patientDtosinputData["poolarea"] = pd.Poolarea
  7235. patientDtosinputData["curr_mdtrt_id"] = pd.CurrMdtrtID
  7236. patientDtosinputData["fsi_his_data_dto"] = ""
  7237. patientDtosinputData["fsi_encounter_dtos"] = fisEncounterDtosData
  7238. inputData["syscode"] = "LinkDialysis"
  7239. inputData["trig_scen"] = trig_scen
  7240. inputData["rule_ids"] = ""
  7241. inputData["task_id"] = ""
  7242. inputData["patient_dtos"] = patientDtosinputData
  7243. input["data"] = inputData
  7244. inputMessage["infno"] = "3101"
  7245. inputMessage["input"] = input //交易输入
  7246. bytesData, err := json.Marshal(inputMessage)
  7247. fmt.Println(string(bytesData))
  7248. if err != nil {
  7249. fmt.Println(err.Error())
  7250. return err.Error(), ""
  7251. }
  7252. reader := bytes.NewReader(bytesData)
  7253. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7254. gdyb_url := beego.AppConfig.String("gdyb_url")
  7255. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7256. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7257. url := gdyb_url + "3101"
  7258. request, err := http.NewRequest("POST", url, reader)
  7259. if err != nil {
  7260. fmt.Println(err.Error())
  7261. return err.Error(), ""
  7262. }
  7263. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  7264. request.Header.Set("x-tif-paasid", gdyb_paasid)
  7265. request.Header.Set("x-tif-signature", signature)
  7266. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  7267. request.Header.Set("x-tif-nonce", nonce)
  7268. client := http.Client{}
  7269. resp, err := client.Do(request)
  7270. if err != nil {
  7271. fmt.Println(err.Error())
  7272. return err.Error(), ""
  7273. }
  7274. respBytes, err := ioutil.ReadAll(resp.Body)
  7275. if err != nil {
  7276. fmt.Println(err.Error())
  7277. return err.Error(), ""
  7278. }
  7279. str := string(respBytes)
  7280. fmt.Println(str)
  7281. return str, string(bytesData)
  7282. }
  7283. 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) {
  7284. nonce := GetRandomString(32)
  7285. timestamp := time.Now().Unix()
  7286. signature := setSignature(timestamp, nonce, params.SecretKey)
  7287. // 生成输入报文
  7288. inputMessage := SetGdInputMessage(timestamp, params.FixmedinsName, params.OpterName, params.FixmedinsCode, params.InsuplcAdmdvs, params.MdtrtareaAdmvs, params.Cainfo)
  7289. input := make(map[string]interface{})
  7290. inputData := make(map[string]interface{})
  7291. patientDtosinputData := make(map[string]interface{})
  7292. fisEncounterDtosData := make(map[string]interface{})
  7293. fsiDiagnoseDtosDatas := make([]map[string]interface{}, 0)
  7294. fsiOrderDtosDatas := make([]map[string]interface{}, 0)
  7295. fsiOperationDtosData := make(map[string]interface{})
  7296. fsiOperationDtosDatas := make([]map[string]interface{}, 0)
  7297. //就诊信息
  7298. fisEncounterDtosData["mdtrt_id"] = fed.MdtrtID
  7299. fisEncounterDtosData["medins_id"] = fed.MedinsID
  7300. fisEncounterDtosData["medins_name"] = fed.MedinsName
  7301. fisEncounterDtosData["medins_admdvs"] = fed.MedinsAdmdvs
  7302. fisEncounterDtosData["medins_type"] = fed.MedinsType
  7303. fisEncounterDtosData["medins_lv"] = fed.MedinsLv
  7304. fisEncounterDtosData["wardarea_codg"] = fed.WardareaCodg
  7305. fisEncounterDtosData["wardno"] = fed.Wardno
  7306. fisEncounterDtosData["bedno"] = fed.Bedno
  7307. fisEncounterDtosData["adm_date"] = fed.AdmDate
  7308. fisEncounterDtosData["dscg_date"] = fed.DscgDate
  7309. fisEncounterDtosData["dscg_main_dise_codg"] = fed.DscgMainDiseCodg
  7310. fisEncounterDtosData["dscg_main_dise_name"] = fed.DscgMainDiseName
  7311. for _, fdd := range fdds {
  7312. fsiDiagnoseDtosData := make(map[string]interface{})
  7313. //诊断集合
  7314. fsiDiagnoseDtosData["dise_id"] = fdd.DiseID
  7315. fsiDiagnoseDtosData["inout_dise_type"] = fdd.InoutDiseType
  7316. fsiDiagnoseDtosData["maindise_flag"] = fdd.MaindiseFlag
  7317. fsiDiagnoseDtosData["dias_srt_no"] = fdd.DiasSrtNo
  7318. fsiDiagnoseDtosData["dise_codg"] = fdd.DiseCodg
  7319. fsiDiagnoseDtosData["dise_name"] = fdd.DiseName
  7320. fsiDiagnoseDtosData["dise_date"] = fdd.DiseDate
  7321. fsiDiagnoseDtosDatas = append(fsiDiagnoseDtosDatas, fsiDiagnoseDtosData)
  7322. }
  7323. fisEncounterDtosData["fsi_diagnose_dtos"] = fsiDiagnoseDtosDatas
  7324. fisEncounterDtosData["dr_codg"] = fed.DrCodg
  7325. fisEncounterDtosData["adm_dept_codg"] = fed.AdmDeptCodg
  7326. fisEncounterDtosData["adm_dept_name"] = fed.AdmDeptName
  7327. fisEncounterDtosData["dscg_dept_codg"] = fed.DscgDeptCodg
  7328. fisEncounterDtosData["dscg_dept_name"] = fed.DscgDeptName
  7329. fisEncounterDtosData["med_mdtrt_type"] = fed.MedMdtrtType
  7330. fisEncounterDtosData["med_type"] = fed.MedType
  7331. for _, fod := range fods {
  7332. fsiOrderDtosData := make(map[string]interface{})
  7333. //医嘱集合
  7334. fsiOrderDtosData["rx_id"] = fod.RxID
  7335. fsiOrderDtosData["rxno"] = fod.Rxno
  7336. fsiOrderDtosData["grpno"] = fod.Grpno
  7337. fsiOrderDtosData["long_drord_flag"] = fod.LongDrordFlag
  7338. fsiOrderDtosData["hilist_type"] = fod.HilistType
  7339. fsiOrderDtosData["chrg_type"] = fod.ChrgType
  7340. fsiOrderDtosData["drord_bhvr"] = fod.DrordBhvr
  7341. fsiOrderDtosData["hilist_code"] = fod.HosplistCode
  7342. fsiOrderDtosData["hilist_name"] = fod.HosplistName
  7343. fsiOrderDtosData["hilist_dosform"] = fod.HilistDosform
  7344. fsiOrderDtosData["hilist_lv"] = fod.HilistLv
  7345. fsiOrderDtosData["hilist_pric"] = fod.HilistPric
  7346. fsiOrderDtosData["lv1_hosp_item_pric"] = fod.Lv1HospItemPric
  7347. fsiOrderDtosData["lv2_hosp_item_pric"] = fod.Lv2HospItemPric
  7348. fsiOrderDtosData["lv3_hosp_item_pric"] = fod.Lv3HospItemPric
  7349. fsiOrderDtosData["hilist_memo"] = fod.HilistMemo
  7350. fsiOrderDtosData["hosplist_code"] = fod.HosplistCode
  7351. fsiOrderDtosData["hosplist_name"] = fod.HosplistName
  7352. fsiOrderDtosData["hosplist_dosform"] = fod.HosplistDosform
  7353. fsiOrderDtosData["cnt"] = fod.Cnt
  7354. fsiOrderDtosData["pric"] = fod.Pric
  7355. fsiOrderDtosData["sumamt"] = fod.Sumamt
  7356. fsiOrderDtosData["ownpay_amt"] = fod.OwnpayAmt
  7357. fsiOrderDtosData["selfpay_amt"] = fod.SelfpayAmt
  7358. fsiOrderDtosData["spec"] = fod.Spec
  7359. fsiOrderDtosData["spec_unt"] = fod.SpecUnt
  7360. fsiOrderDtosData["drord_begn_date"] = fod.DrordBegnDate
  7361. fsiOrderDtosData["drord_stop_date"] = fod.DrordStopDate
  7362. fsiOrderDtosData["drord_dept_codg"] = fod.DrordDeptCodg
  7363. fsiOrderDtosData["drord_dept_name"] = fod.DrordDeptName
  7364. fsiOrderDtosData["drord_dr_codg"] = fod.DrordDrCodg
  7365. fsiOrderDtosData["drord_dr_name"] = fod.DrordDrName
  7366. fsiOrderDtosData["drord_dr_profttl"] = fod.DrordDrProfttl
  7367. fsiOrderDtosData["curr_drord_flag"] = fod.CurrDrordFlag
  7368. fsiOrderDtosDatas = append(fsiOrderDtosDatas, fsiOrderDtosData)
  7369. }
  7370. fisEncounterDtosData["fsi_order_dtos"] = fsiOrderDtosDatas
  7371. fisEncounterDtosData["matn_stas"] = fed.MatnStas
  7372. fisEncounterDtosData["medfee_sumamt"] = fed.MedfeeSumamt
  7373. fisEncounterDtosData["ownpay_amt"] = fed.OwnpayAmt
  7374. fisEncounterDtosData["selfpay_amt"] = fed.SelfpayAmt
  7375. fisEncounterDtosData["acct_payamt"] = fed.AcctPayamt
  7376. fisEncounterDtosData["ma_amt"] = fed.MaAmt
  7377. fisEncounterDtosData["hifp_payamt"] = fed.HifpPayamt
  7378. fisEncounterDtosData["setl_totlnum"] = fed.SetlTotlnum
  7379. fisEncounterDtosData["insutype"] = fed.Insutype
  7380. fisEncounterDtosData["reim_flag"] = fed.ReimFlag
  7381. fisEncounterDtosData["out_setl_flag"] = fed.OutSetlFlag
  7382. //手术操作
  7383. for _, fopd := range fopds {
  7384. fsiOperationDtosData["setl_list_oprn_id"] = fopd.Setl_list_oprn_id
  7385. fsiOperationDtosData["oprn_code"] = fopd.Oprn_code
  7386. fsiOperationDtosData["oprn_name"] = fopd.Oprn_name
  7387. fsiOperationDtosData["main_oprn_flag"] = fopd.Main_oprn_flag
  7388. fsiOperationDtosData["oprn_date"] = fopd.Oprn_date
  7389. fsiOperationDtosData["anst_way"] = fopd.Anst_way
  7390. fsiOperationDtosData["oper_dr_name"] = fopd.Oper_dr_name
  7391. fsiOperationDtosData["oper_dr_code"] = fopd.Oper_dr_code
  7392. fsiOperationDtosData["anst_dr_name"] = fopd.Anst_dr_name
  7393. fsiOperationDtosData["anst_dr_code"] = fopd.Anst_dr_code
  7394. fsiOperationDtosDatas = append(fsiOperationDtosDatas, fsiOperationDtosData)
  7395. }
  7396. fisEncounterDtosData["fsi_operation_dtos"] = fsiOperationDtosDatas
  7397. patientDtosinputData["patn_id"] = pd.PatnID
  7398. patientDtosinputData["patn_name"] = pd.PatnName
  7399. patientDtosinputData["gend"] = pd.Gend
  7400. patientDtosinputData["brdy"] = pd.Brdy
  7401. patientDtosinputData["poolarea"] = pd.Poolarea
  7402. patientDtosinputData["curr_mdtrt_id"] = pd.CurrMdtrtID
  7403. patientDtosinputData["fsi_his_data_dto"] = ""
  7404. patientDtosinputData["fsi_encounter_dtos"] = fisEncounterDtosData
  7405. inputData["syscode"] = "LinkDialysis"
  7406. inputData["trig_scen"] = trig_scen
  7407. inputData["rule_ids"] = ""
  7408. inputData["task_id"] = ""
  7409. inputData["patient_dtos"] = patientDtosinputData
  7410. input["data"] = inputData
  7411. inputMessage["infno"] = "3102"
  7412. inputMessage["input"] = input //交易输入
  7413. bytesData, err := json.Marshal(inputMessage)
  7414. fmt.Println(string(bytesData))
  7415. if err != nil {
  7416. fmt.Println(err.Error())
  7417. return err.Error(), ""
  7418. }
  7419. reader := bytes.NewReader(bytesData)
  7420. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7421. gdyb_url := beego.AppConfig.String("gdyb_url")
  7422. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7423. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7424. url := gdyb_url + "3102"
  7425. request, err := http.NewRequest("POST", url, reader)
  7426. if err != nil {
  7427. fmt.Println(err.Error())
  7428. return err.Error(), ""
  7429. }
  7430. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  7431. request.Header.Set("x-tif-paasid", gdyb_paasid)
  7432. request.Header.Set("x-tif-signature", signature)
  7433. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  7434. request.Header.Set("x-tif-nonce", nonce)
  7435. client := http.Client{}
  7436. resp, err := client.Do(request)
  7437. if err != nil {
  7438. fmt.Println(err.Error())
  7439. return err.Error(), ""
  7440. }
  7441. respBytes, err := ioutil.ReadAll(resp.Body)
  7442. if err != nil {
  7443. fmt.Println(err.Error())
  7444. return err.Error(), ""
  7445. }
  7446. str := string(respBytes)
  7447. fmt.Println(str)
  7448. return str, string(bytesData)
  7449. }
  7450. // 分页函数
  7451. func paginate(data []map[string]interface{}, pageSize int) [][]map[string]interface{} {
  7452. var pages [][]map[string]interface{}
  7453. totalItems := len(data)
  7454. for i := 0; i < totalItems; i += pageSize {
  7455. end := i + pageSize
  7456. if end > totalItems {
  7457. end = totalItems
  7458. }
  7459. pages = append(pages, data[i:end])
  7460. }
  7461. return pages
  7462. }
  7463. func Gzyb3501(struct3501 models.Struct3501, secret_key string) (string, string) {
  7464. // 生成签名
  7465. nonce := GetRandomString(32)
  7466. timestamp := time.Now().Unix()
  7467. signature := setSignature(timestamp, nonce, secret_key)
  7468. // 生成输入报文
  7469. //inputMessage := SetInputMessage(timestamp, struct3501.OrgName, struct3501.Opter, struct3501.FixmedinsHilistId, struct3501.InsuplcAdmdvs, struct3501.MdtrtareaAdmvs, struct3501.Cainfo,"")
  7470. sign := GetSignInInfo(struct3501.FixmedinsCode)
  7471. inputMessage := SetInputMessage(nonce, timestamp, struct3501.OrgName, struct3501.Opter, struct3501.FixmedinsCode, struct3501.InsuplcAdmdvs, struct3501.MdtrtareaAdmvs, sign)
  7472. input := make(map[string]interface{})
  7473. inputData := make(map[string]interface{})
  7474. inputMessage["infno"] = "3501" // 交易编码
  7475. inputData["med_list_codg"] = struct3501.MedListCodg // 定点医药机构目录编号
  7476. inputData["fixmedins_hilist_id"] = struct3501.FixmedinsHilistId // 定点医药机构目录编号
  7477. inputData["fixmedins_hilist_name"] = struct3501.OrgName // 定点医药机构目录名称
  7478. inputData["rx_flag"] = struct3501.RxFlag //
  7479. inputData["invdate"] = struct3501.Invdate // 人员编号 (来自1101接口返回)
  7480. inputData["inv_cnt"] = struct3501.InvCnt // 人员编号 (来自1101接口返回)
  7481. inputData["manu_lotnum"] = struct3501.ManuLotnum // 人员编号 (来自1101接口返回)
  7482. inputData["fixmedins_bchno"] = struct3501.FixmedinsBchno // 人员编号 (来自1101接口返回)
  7483. inputData["manu_date"] = struct3501.ManuDate // 人员编号 (来自1101接口返回)
  7484. inputData["expy_end"] = struct3501.ExpyEnd // 人员编号 (来自1101接口返回)
  7485. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  7486. input["invinfo"] = inputData
  7487. inputMessage["input"] = input //交易输入
  7488. bytesData, err := json.Marshal(inputMessage)
  7489. fmt.Println(string(bytesData))
  7490. if err != nil {
  7491. fmt.Println(err.Error())
  7492. return err.Error(), ""
  7493. }
  7494. reader := bytes.NewReader(bytesData)
  7495. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7496. gdyb_url := beego.AppConfig.String("gdyb_url")
  7497. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7498. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7499. url := gdyb_url + "3501"
  7500. request, err := http.NewRequest("POST", url, reader)
  7501. if err != nil {
  7502. fmt.Println(err.Error())
  7503. return err.Error(), ""
  7504. }
  7505. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  7506. request.Header.Set("x-tif-paasid", gdyb_paasid)
  7507. request.Header.Set("x-tif-signature", signature)
  7508. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  7509. request.Header.Set("x-tif-nonce", nonce)
  7510. client := http.Client{}
  7511. resp, err := client.Do(request)
  7512. if err != nil {
  7513. fmt.Println(err.Error())
  7514. return err.Error(), ""
  7515. }
  7516. respBytes, err := ioutil.ReadAll(resp.Body)
  7517. if err != nil {
  7518. fmt.Println(err.Error())
  7519. return err.Error(), ""
  7520. }
  7521. str := string(respBytes)
  7522. fmt.Println(str)
  7523. return str, string(bytesData)
  7524. }
  7525. func Gzyb3502(struct3502 models.Struct3502, secret_key string) (string, string) {
  7526. // 生成签名
  7527. nonce := GetRandomString(32)
  7528. timestamp := time.Now().Unix()
  7529. signature := setSignature(timestamp, nonce, secret_key)
  7530. sign := GetSignInInfo(struct3502.FixmedinsCode)
  7531. inputMessage := SetGZInputMessage(nonce, timestamp, struct3502.OrgName, struct3502.Opter, struct3502.FixmedinsCode, struct3502.InsuplcAdmdvs, struct3502.MdtrtareaAdmvs, sign)
  7532. // 生成输入报文
  7533. //inputMessage := SetGdInputMessage(timestamp, struct3502.OrgName, struct3502.Opter, struct3502.FixmedinsCode, struct3502.InsuplcAdmdvs, struct3502.MdtrtareaAdmvs, struct3502.Cainfo,sign)
  7534. input := make(map[string]interface{})
  7535. inputData := make(map[string]interface{})
  7536. inputMessage["infno"] = "3502" // 交易编码
  7537. inputData["med_list_codg"] = struct3502.MedListCodg // 定点医药机构目录编号
  7538. inputData["inv_chg_type"] = struct3502.InvChgType // 定点医药机构目录编号
  7539. inputData["fixmedins_hilist_id"] = struct3502.FixmedinsCode // 定点医药机构目录编号
  7540. inputData["fixmedins_hilist_name"] = struct3502.OrgName // 定点医药机构目录名称
  7541. inputData["fixmedins_bchno"] = struct3502.FixmedinsBchno // 人员编号 (来自1101接口返回)
  7542. inputData["pric"] = struct3502.Pric // 人员编号 (来自1101接口返回)
  7543. inputData["cnt"] = struct3502.Cnt // 人员编号 (来自1101接口返回)
  7544. inputData["rx_flag"] = struct3502.RxFlag //
  7545. inputData["inv_chg_time"] = struct3502.InvChgTime // 人员编号 (来自1101接口返回)
  7546. inputData["inv_chg_opter_name"] = "" // 人员编号 (来自1101接口返回)
  7547. inputData["memo"] = struct3502.Memo // 人员编号 (来自1101接口返回)
  7548. inputData["trdn_flag"] = "" // 人员编号 (来自1101接口返回)
  7549. input["invinfo"] = inputData
  7550. inputMessage["input"] = input //交易输入
  7551. bytesData, err := json.Marshal(inputMessage)
  7552. fmt.Println(string(bytesData))
  7553. if err != nil {
  7554. fmt.Println(err.Error())
  7555. return err.Error(), ""
  7556. }
  7557. reader := bytes.NewReader(bytesData)
  7558. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7559. gdyb_url := beego.AppConfig.String("gdyb_url")
  7560. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7561. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7562. url := gdyb_url + "3502"
  7563. request, err := http.NewRequest("POST", url, reader)
  7564. if err != nil {
  7565. fmt.Println(err.Error())
  7566. return err.Error(), ""
  7567. }
  7568. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  7569. request.Header.Set("x-tif-paasid", gdyb_paasid)
  7570. request.Header.Set("x-tif-signature", signature)
  7571. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  7572. request.Header.Set("x-tif-nonce", nonce)
  7573. client := http.Client{}
  7574. resp, err := client.Do(request)
  7575. if err != nil {
  7576. fmt.Println(err.Error())
  7577. return err.Error(), ""
  7578. }
  7579. respBytes, err := ioutil.ReadAll(resp.Body)
  7580. if err != nil {
  7581. fmt.Println(err.Error())
  7582. return err.Error(), ""
  7583. }
  7584. str := string(respBytes)
  7585. fmt.Println(str)
  7586. return str, string(bytesData)
  7587. }
  7588. func Gzyb3503(struct3503 models.Struct3503, secret_key string) (string, string) {
  7589. // 生成签名
  7590. nonce := GetRandomString(32)
  7591. timestamp := time.Now().Unix()
  7592. signature := setSignature(timestamp, nonce, secret_key)
  7593. // 生成输入报文
  7594. sign := GetSignInInfo(struct3503.FixmedinsCode)
  7595. inputMessage := SetGZInputMessage(nonce, timestamp, struct3503.OrgName, struct3503.Opter, struct3503.FixmedinsCode, struct3503.InsuplcAdmdvs, struct3503.MdtrtareaAdmvs, sign)
  7596. input := make(map[string]interface{})
  7597. inputMessage["infno"] = "3503"
  7598. item := struct3503
  7599. feedetailInfo := make(map[string]interface{})
  7600. feedetailInfo["med_list_codg"] = item.MedListCodg
  7601. feedetailInfo["fixmedins_hilist_id"] = item.FixmedinsHilistId
  7602. feedetailInfo["fixmedins_hilist_name"] = item.FixmedinsHilistName
  7603. feedetailInfo["dynt_no"] = ""
  7604. feedetailInfo["fixmedins_bchno"] = item.FixmedinsBchno // 人员编号 (来自1101接口返回)
  7605. feedetailInfo["spler_name"] = item.SplerName // 人员编号 (来自1101接口返回)
  7606. feedetailInfo["spler_pmtno"] = "" // 人员编号 (来自1101接口返回)
  7607. feedetailInfo["manu_lotnum"] = item.ManuLotnum // 人员编号 (来自1101接口返回)
  7608. feedetailInfo["prodentp_name"] = item.ProdentpName // 人员编号 (来自1101接口返回)
  7609. feedetailInfo["aprvno"] = item.Aprvno // 人员编号 (来自1101接口返回)
  7610. feedetailInfo["manu_date"] = item.ManuDate // 人员编号 (来自1101接口返回)
  7611. feedetailInfo["expy_end"] = item.ExpyEnd // 人员编号 (来自1101接口返回)
  7612. feedetailInfo["finl_trns_pric"] = item.FinlTrnsPric // 人员编号 (来自1101接口返回)
  7613. feedetailInfo["purc_retn_cnt"] = item.PurcRetnCnt // 人员编号 (来自1101接口返回)
  7614. feedetailInfo["purc_invo_codg"] = item.PurcInvoCodg // 人员编号 (来自1101接口返回)
  7615. feedetailInfo["purc_invo_no"] = item.PurcInvoNo // 人员编号 (来自1101接口返回)
  7616. feedetailInfo["rx_flag"] = item.RxFlag // 人员编号 (来自1101接口返回)
  7617. feedetailInfo["purc_retn_stoin_time"] = item.PurcRetnStoinTime // 人员编号 (来自1101接口返回)
  7618. feedetailInfo["purc_retn_opter_name"] = item.PurcRetnOpterName // 人员编号 (来自1101接口返回)
  7619. feedetailInfo["prod_geay_flag"] = "" // 人员编号 (来自1101接口返回)
  7620. feedetailInfo["memo"] = "" // 人员编号 (来自1101接口返回)
  7621. input["purcinfo"] = feedetailInfo
  7622. inputMessage["input"] = input //交易输入
  7623. bytesData, err := json.Marshal(inputMessage)
  7624. fmt.Println(string(bytesData))
  7625. if err != nil {
  7626. fmt.Println(err.Error())
  7627. return err.Error(), ""
  7628. }
  7629. reader := bytes.NewReader(bytesData)
  7630. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7631. gdyb_url := beego.AppConfig.String("gdyb_url")
  7632. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7633. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7634. url := gdyb_url + "3503"
  7635. request, err := http.NewRequest("POST", url, reader)
  7636. if err != nil {
  7637. fmt.Println(err.Error())
  7638. return err.Error(), ""
  7639. }
  7640. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  7641. request.Header.Set("x-tif-paasid", gdyb_paasid)
  7642. request.Header.Set("x-tif-signature", signature)
  7643. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  7644. request.Header.Set("x-tif-nonce", nonce)
  7645. client := http.Client{}
  7646. resp, err := client.Do(request)
  7647. if err != nil {
  7648. fmt.Println(err.Error())
  7649. return err.Error(), ""
  7650. }
  7651. respBytes, err := ioutil.ReadAll(resp.Body)
  7652. if err != nil {
  7653. fmt.Println(err.Error())
  7654. return err.Error(), ""
  7655. }
  7656. str := string(respBytes)
  7657. fmt.Println(str)
  7658. return str, string(bytesData)
  7659. }
  7660. func Gzyb3504(struct3504 models.Struct3504, secret_key string) (string, string) {
  7661. // 生成签名
  7662. nonce := GetRandomString(32)
  7663. timestamp := time.Now().Unix()
  7664. signature := setSignature(timestamp, nonce, secret_key)
  7665. // 生成输入报文
  7666. //inputMessage := SetGdInputMessage(timestamp, struct3504.OrgName, struct3504.Opter, struct3504.FixmedinsCode, struct3504.InsuplcAdmdvs, struct3504.MdtrtareaAdmvs, struct3504.Cainfo)
  7667. sign := GetSignInInfo(struct3504.FixmedinsCode)
  7668. inputMessage := SetGZInputMessage(nonce, timestamp, struct3504.OrgName, struct3504.Opter, struct3504.FixmedinsCode, struct3504.InsuplcAdmdvs, struct3504.MdtrtareaAdmvs, sign)
  7669. input := make(map[string]interface{})
  7670. inputData := make(map[string]interface{})
  7671. inputMessage["infno"] = "3504" // 交易编码
  7672. inputData["med_list_codg"] = struct3504.MedListCodg // 定点医药机构目录编号
  7673. inputData["fixmedins_hilist_id"] = struct3504.FixmedinsHilistId // 定点医药机构目录编号
  7674. inputData["fixmedins_hilist_name"] = struct3504.FixmedinsHilistName // 定点医药机构目录名称
  7675. inputData["fixmedins_bchno"] = struct3504.FixmedinsBchno // 人员编号 (来自1101接口返回)
  7676. inputData["spler_name"] = struct3504.SplerName // 人员编号 (来自1101接口返回)
  7677. inputData["spler_pmtno"] = "" // 人员编号 (来自1101接口返回)
  7678. inputData["manu_date"] = struct3504.ManuDate // 人员编号 (来自1101接口返回)
  7679. inputData["expy_end"] = struct3504.ExpyEnd // 人员编号 (来自1101接口返回)
  7680. inputData["finl_trns_pric"] = struct3504.FinlTrnsPric // 人员编号 (来自1101接口返回)
  7681. inputData["purc_retn_cnt"] = struct3504.PurcRetnCnt // 人员编号 (来自1101接口返回)
  7682. inputData["purc_invo_codg"] = struct3504.PurcInvoCodg // 人员编号 (来自1101接口返回)
  7683. inputData["purc_invo_no"] = struct3504.PurcInvoNo // 人员编号 (来自1101接口返回)
  7684. inputData["rx_flag"] = struct3504.RxFlag
  7685. inputData["purc_retn_stoin_time"] = struct3504.PurcRetnStoin
  7686. inputData["purc_retn_opter_name"] = struct3504.PurcRetnStoin
  7687. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  7688. inputData["medins_prod_purc_no"] = "" // 人员编号 (来自1101接口返回)
  7689. input["purcinfo"] = inputData
  7690. inputMessage["input"] = input //交易输入
  7691. bytesData, err := json.Marshal(inputMessage)
  7692. fmt.Println(string(bytesData))
  7693. if err != nil {
  7694. fmt.Println(err.Error())
  7695. return err.Error(), ""
  7696. }
  7697. reader := bytes.NewReader(bytesData)
  7698. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7699. gdyb_url := beego.AppConfig.String("gdyb_url")
  7700. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7701. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7702. url := gdyb_url + "3504"
  7703. request, err := http.NewRequest("POST", url, reader)
  7704. if err != nil {
  7705. fmt.Println(err.Error())
  7706. return err.Error(), ""
  7707. }
  7708. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  7709. request.Header.Set("x-tif-paasid", gdyb_paasid)
  7710. request.Header.Set("x-tif-signature", signature)
  7711. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  7712. request.Header.Set("x-tif-nonce", nonce)
  7713. client := http.Client{}
  7714. resp, err := client.Do(request)
  7715. if err != nil {
  7716. fmt.Println(err.Error())
  7717. return err.Error(), ""
  7718. }
  7719. respBytes, err := ioutil.ReadAll(resp.Body)
  7720. if err != nil {
  7721. fmt.Println(err.Error())
  7722. return err.Error(), ""
  7723. }
  7724. str := string(respBytes)
  7725. fmt.Println(str)
  7726. return str, string(bytesData)
  7727. }
  7728. func Gzyb3505(struct3505 models.Struct3505, secret_key string) (string, string) {
  7729. // 生成签名
  7730. nonce := GetRandomString(32)
  7731. timestamp := time.Now().Unix()
  7732. signature := setSignature(timestamp, nonce, secret_key)
  7733. // 生成输入报文
  7734. //inputMessage := SetGdInputMessage(timestamp, struct3505.OrgName, struct3505.Opter, struct3505.FixmedinsHilistId, struct3505.InsuplcAdmdvs, struct3505.MdtrtareaAdmvs, struct3505.Cainfo)
  7735. sign := GetSignInInfo(struct3505.FixmedinsCode)
  7736. inputMessage := SetGZInputMessage(nonce, timestamp, struct3505.OrgName, struct3505.Opter, struct3505.FixmedinsCode, struct3505.InsuplcAdmdvs, struct3505.MdtrtareaAdmvs, sign)
  7737. input := make(map[string]interface{})
  7738. inputData := make(map[string]interface{})
  7739. inputMessage["infno"] = "3505" // 交易编码
  7740. inputData["med_list_codg"] = struct3505.MedListCodg // 定点医药机构目录编号
  7741. inputData["fixmedins_hilist_id"] = struct3505.FixmedinsHilistId // 定点医药机构目录编号
  7742. inputData["fixmedins_hilist_name"] = struct3505.OrgName // 定点医药机构目录名称
  7743. inputData["fixmedins_bchno"] = struct3505.FixmedinsBchno // 人员编号 (来自1101接口返回)
  7744. inputData["prsc_dr_cert_type"] = struct3505.PrscDrCertType // 人员编号 (来自1101接口返回)
  7745. inputData["prsc_dr_certno"] = struct3505.PrscDrCertno // 人员编号 (来自1101接口返回)
  7746. inputData["prsc_dr_name"] = struct3505.PrscDrName // 人员编号 (来自1101接口返回)
  7747. inputData["phar_cert_type"] = struct3505.PharCertType // 人员编号 (来自1101接口返回)
  7748. inputData["phar_certno"] = struct3505.PharCertno // 人员编号 (来自1101接口返回)
  7749. inputData["phar_name"] = struct3505.PharName // 人员编号 (来自1101接口返回)
  7750. inputData["phar_prac_cert_no"] = struct3505.PharPracCertNo // 人员编号 (来自1101接口返回)
  7751. inputData["hi_feesetl_type"] = struct3505.HiFeesetlType // 人员编号 (来自1101接口返回)
  7752. inputData["setl_id"] = struct3505.SetlId // 人员编号 (来自1101接口返回)
  7753. inputData["mdtrt_sn"] = struct3505.MdtrtSn // 人员编号 (来自1101接口返回)
  7754. inputData["psn_no"] = struct3505.PsnNo // 人员编号 (来自1101接口返回)
  7755. inputData["psn_cert_type"] = struct3505.PsnCertType // 人员编号 (来自1101接口返回)
  7756. inputData["certno"] = struct3505.CertNo // 人员编号 (来自1101接口返回)
  7757. inputData["psn_name"] = struct3505.PsnName // 人员编号 (来自1101接口返回)
  7758. inputData["manu_lotnum"] = struct3505.ManuLotnum // 人员编号 (来自1101接口返回)
  7759. inputData["manu_date"] = struct3505.ManuDate // 人员编号 (来自1101接口返回)
  7760. inputData["expy_end"] = struct3505.ExpyEnd // 人员编号 (来自1101接口返回)
  7761. inputData["rx_flag"] = struct3505.RxFlag // 人员编号 (来自1101接口返回)
  7762. inputData["trdn_flag"] = struct3505.TrdnFlag // 人员编号 (来自1101接口返回)
  7763. inputData["finl_trns_pric"] = struct3505.FinlTrnsPric // 人员编号 (来自1101接口返回)
  7764. inputData["rxno"] = struct3505.Rxno // 人员编号 (来自1101接口返回)
  7765. inputData["rx_circ_flag"] = struct3505.RxCircFlag // 人员编号 (来自1101接口返回)
  7766. inputData["rtal_docno"] = struct3505.RtalDocno // 人员编号 (来自1101接口返回)
  7767. inputData["stoout_no"] = struct3505.StooutNo // 人员编号 (来自1101接口返回)
  7768. inputData["bchno"] = struct3505.Bchno // 人员编号 (来自1101接口返回)
  7769. inputData["drug_trac_codg"] = struct3505.DrugTracCodg // 人员编号 (来自1101接口返回)
  7770. inputData["drug_prod_barc"] = struct3505.DrugProdBarc // 人员编号 (来自1101接口返回)
  7771. inputData["shelf_posi"] = struct3505.ShelfPosi // 人员编号 (来自1101接口返回)
  7772. inputData["sel_retn_cnt"] = struct3505.SelRetnCnt // 人员编号 (来自1101接口返回)
  7773. inputData["sel_retn_time"] = struct3505.SelRetnTime // 人员编号 (来自1101接口返回)
  7774. inputData["sel_retn_opter_name"] = struct3505.SelRetnOpterName // 人员编号 (来自1101接口返回)
  7775. inputData["memo"] = struct3505.Memo // 人员编号 (来自1101接口返回)
  7776. input["selinfo"] = inputData
  7777. inputMessage["input"] = input //交易输入
  7778. bytesData, err := json.Marshal(inputMessage)
  7779. fmt.Println(string(bytesData))
  7780. if err != nil {
  7781. fmt.Println(err.Error())
  7782. return err.Error(), ""
  7783. }
  7784. reader := bytes.NewReader(bytesData)
  7785. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7786. gdyb_url := beego.AppConfig.String("gdyb_url")
  7787. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7788. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7789. url := gdyb_url + "3505"
  7790. request, err := http.NewRequest("POST", url, reader)
  7791. if err != nil {
  7792. fmt.Println(err.Error())
  7793. return err.Error(), ""
  7794. }
  7795. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  7796. request.Header.Set("x-tif-paasid", gdyb_paasid)
  7797. request.Header.Set("x-tif-signature", signature)
  7798. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  7799. request.Header.Set("x-tif-nonce", nonce)
  7800. client := http.Client{}
  7801. resp, err := client.Do(request)
  7802. if err != nil {
  7803. fmt.Println(err.Error())
  7804. return err.Error(), ""
  7805. }
  7806. respBytes, err := ioutil.ReadAll(resp.Body)
  7807. if err != nil {
  7808. fmt.Println(err.Error())
  7809. return err.Error(), ""
  7810. }
  7811. str := string(respBytes)
  7812. fmt.Println(str)
  7813. return str, string(bytesData)
  7814. }
  7815. func Gzyb3506(struct3506 models.Struct3506, secret_key string) (string, string) {
  7816. // 生成签名
  7817. nonce := GetRandomString(32)
  7818. timestamp := time.Now().Unix()
  7819. signature := setSignature(timestamp, nonce, secret_key)
  7820. // 生成输入报文
  7821. //inputMessage := SetGdInputMessage(timestamp, struct3506.OrgName, struct3506.Opter, struct3506.FixmedinsCode, struct3506.InsuplcAdmdvs, struct3506.MdtrtareaAdmvs, struct3506.Cainfo)
  7822. sign := GetSignInInfo(struct3506.FixmedinsCode)
  7823. inputMessage := SetGZInputMessage(nonce, timestamp, struct3506.OrgName, struct3506.Opter, struct3506.FixmedinsCode, struct3506.InsuplcAdmdvs, struct3506.MdtrtareaAdmvs, sign)
  7824. input := make(map[string]interface{})
  7825. inputData := make(map[string]interface{})
  7826. inputMessage["infno"] = "3506" // 交易编码
  7827. inputData["med_list_codg"] = struct3506.MedListCodg // 定点医药机构目录编号
  7828. inputData["fixmedins_hilist_id"] = struct3506.FixmedinsHilistId // 定点医药机构目录编号
  7829. inputData["fixmedins_hilist_name"] = struct3506.OrgName // 定点医药机构目录名称
  7830. inputData["fixmedins_bchno"] = struct3506.FixmedinsBchno // 人员编号 (来自1101接口返回)
  7831. inputData["setl_id"] = struct3506.SetlId // 人员编号 (来自1101接口返回)
  7832. inputData["psn_no"] = struct3506.PsnNo // 人员编号 (来自1101接口返回)
  7833. inputData["psn_cert_type"] = struct3506.PsnCertType // 人员编号 (来自1101接口返回)
  7834. inputData["certno"] = struct3506.Certno // 人员编号 (来自1101接口返回)
  7835. inputData["psn_name"] = struct3506.PsnName // 人员编号 (来自1101接口返回)
  7836. inputData["manu_lotnum"] = struct3506.ManuLotnum // 人员编号 (来自1101接口返回)
  7837. inputData["manu_date"] = struct3506.ManuDate // 人员编号 (来自1101接口返回)
  7838. inputData["expy_end"] = struct3506.ExpyEnd // 人员编号 (来自1101接口返回)
  7839. inputData["rx_flag"] = struct3506.RxFlag // 人员编号 (来自1101接口返回)
  7840. inputData["trdn_flag"] = struct3506.TrdnFlag // 人员编号 (来自1101接口返回)
  7841. inputData["finl_trns_pric"] = struct3506.FinlTrnsPric // 人员编号 (来自1101接口返回)
  7842. inputData["sel_retn_cnt"] = struct3506.SelRetnCnt // 人员编号 (来自1101接口返回)
  7843. inputData["sel_retn_time"] = struct3506.SelRetnTime // 人员编号 (来自1101接口返回)
  7844. inputData["sel_retn_opter_name"] = struct3506.SelRetnOpterName // 人员编号 (来自1101接口返回)
  7845. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  7846. inputData["medins_prod_sel_no"] = "" // 人员编号 (来自1101接口返回)
  7847. input["selinfo"] = inputData
  7848. inputMessage["input"] = input //交易输入
  7849. bytesData, err := json.Marshal(inputMessage)
  7850. fmt.Println(string(bytesData))
  7851. if err != nil {
  7852. fmt.Println(err.Error())
  7853. return err.Error(), ""
  7854. }
  7855. reader := bytes.NewReader(bytesData)
  7856. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7857. gdyb_url := beego.AppConfig.String("gdyb_url")
  7858. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7859. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7860. url := gdyb_url + "3506"
  7861. request, err := http.NewRequest("POST", url, reader)
  7862. if err != nil {
  7863. fmt.Println(err.Error())
  7864. return err.Error(), ""
  7865. }
  7866. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  7867. request.Header.Set("x-tif-paasid", gdyb_paasid)
  7868. request.Header.Set("x-tif-signature", signature)
  7869. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  7870. request.Header.Set("x-tif-nonce", nonce)
  7871. client := http.Client{}
  7872. resp, err := client.Do(request)
  7873. if err != nil {
  7874. fmt.Println(err.Error())
  7875. return err.Error(), ""
  7876. }
  7877. respBytes, err := ioutil.ReadAll(resp.Body)
  7878. if err != nil {
  7879. fmt.Println(err.Error())
  7880. return err.Error(), ""
  7881. }
  7882. str := string(respBytes)
  7883. fmt.Println(str)
  7884. return str, string(bytesData)
  7885. }
  7886. func Gzyb3507(struct3507 models.Struct3507, secret_key string) (string, string) {
  7887. // 生成签名
  7888. nonce := GetRandomString(32)
  7889. timestamp := time.Now().Unix()
  7890. signature := setSignature(timestamp, nonce, secret_key)
  7891. // 生成输入报文
  7892. //inputMessage := SetGdInputMessage(timestamp, struct3507.OrgName, struct3507.Opter, struct3507.FixmedinsCode, struct3507.InsuplcAdmdvs, struct3507.MdtrtareaAdmvs, struct3507.Cainfo)
  7893. sign := GetSignInInfo(struct3507.FixmedinsCode)
  7894. inputMessage := SetGZInputMessage(nonce, timestamp, struct3507.OrgName, struct3507.Opter, struct3507.FixmedinsCode, struct3507.InsuplcAdmdvs, struct3507.MdtrtareaAdmvs, sign)
  7895. input := make(map[string]interface{})
  7896. inputData := make(map[string]interface{})
  7897. inputMessage["infno"] = "3507" // 交易编码
  7898. inputData["fixmedins_bchno"] = struct3507.FixmedinsCode // 人员编号 (来自1101接口返回)
  7899. inputData["inv_data_type"] = struct3507.InvDataType // 人员编号 (来自1101接口返回)
  7900. input["data"] = inputData
  7901. inputMessage["input"] = input //交易输入
  7902. bytesData, err := json.Marshal(inputMessage)
  7903. fmt.Println(string(bytesData))
  7904. if err != nil {
  7905. fmt.Println(err.Error())
  7906. return err.Error(), ""
  7907. }
  7908. reader := bytes.NewReader(bytesData)
  7909. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7910. gdyb_url := beego.AppConfig.String("gdyb_url")
  7911. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7912. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7913. url := gdyb_url + "3507"
  7914. request, err := http.NewRequest("POST", url, reader)
  7915. if err != nil {
  7916. fmt.Println(err.Error())
  7917. return err.Error(), ""
  7918. }
  7919. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  7920. request.Header.Set("x-tif-paasid", gdyb_paasid)
  7921. request.Header.Set("x-tif-signature", signature)
  7922. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  7923. request.Header.Set("x-tif-nonce", nonce)
  7924. client := http.Client{}
  7925. resp, err := client.Do(request)
  7926. if err != nil {
  7927. fmt.Println(err.Error())
  7928. return err.Error(), ""
  7929. }
  7930. respBytes, err := ioutil.ReadAll(resp.Body)
  7931. if err != nil {
  7932. fmt.Println(err.Error())
  7933. return err.Error(), ""
  7934. }
  7935. str := string(respBytes)
  7936. fmt.Println(str)
  7937. return str, string(bytesData)
  7938. }
  7939. func Gzyb3508(struct3508 models.Struct3508, secret_key string) (string, string) {
  7940. // 生成签名
  7941. nonce := GetRandomString(32)
  7942. timestamp := time.Now().Unix()
  7943. signature := setSignature(timestamp, nonce, secret_key)
  7944. // 生成输入报文
  7945. //inputMessage := SetGdInputMessage(timestamp, struct3508.OrgName, struct3508.Opter, struct3508.FixmedinsCode, struct3508.InsuplcAdmdvs, struct3508.MdtrtareaAdmvs, struct3508.Cainfo)
  7946. sign := GetSignInInfo(struct3508.FixmedinsCode)
  7947. inputMessage := SetGZInputMessage(nonce, timestamp, struct3508.OrgName, struct3508.Opter, struct3508.FixmedinsCode, struct3508.InsuplcAdmdvs, struct3508.MdtrtareaAdmvs, sign)
  7948. input := make(map[string]interface{})
  7949. inputData := make(map[string]interface{})
  7950. inputMessage["infno"] = "3508"
  7951. inputData["fixmedins_code"] = struct3508.FixmedinsCode
  7952. inputData["medins_list_codg"] = struct3508.MedListCodg
  7953. inputData["fixmedins_bchno"] = ""
  7954. inputData["begndate"] = struct3508.Begndate
  7955. inputData["enddate"] = struct3508.Enddate
  7956. inputData["medins_prod_inv_no"] = ""
  7957. inputData["medins_list_name"] = ""
  7958. inputData["rx_flag"] = ""
  7959. inputData["list_sp_item_flag"] = ""
  7960. inputData["trdn_flag"] = ""
  7961. inputData["invdate"] = ""
  7962. inputData["manu_lotnum"] = ""
  7963. inputData["manu_date"] = ""
  7964. inputData["expy_end"] = ""
  7965. inputData["memo"] = ""
  7966. inputData["vali_flag"] = ""
  7967. inputData["rid"] = ""
  7968. inputData["crter_id"] = ""
  7969. inputData["crter_name"] = ""
  7970. inputData["crte_optins_no"] = ""
  7971. inputData["opter_id"] = ""
  7972. inputData["opter_name"] = ""
  7973. inputData["optins_no"] = ""
  7974. inputData["poolarea_no"] = ""
  7975. inputData["fixmedins_bchno"] = ""
  7976. inputData["inv_data_type"] = ""
  7977. input["data"] = inputData
  7978. inputMessage["input"] = input //交易输入
  7979. bytesData, err := json.Marshal(inputMessage)
  7980. fmt.Println(string(bytesData))
  7981. if err != nil {
  7982. fmt.Println(err.Error())
  7983. return err.Error(), ""
  7984. }
  7985. reader := bytes.NewReader(bytesData)
  7986. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7987. gdyb_url := beego.AppConfig.String("gdyb_url")
  7988. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7989. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7990. url := gdyb_url + "3508"
  7991. request, err := http.NewRequest("POST", url, reader)
  7992. if err != nil {
  7993. fmt.Println(err.Error())
  7994. return err.Error(), ""
  7995. }
  7996. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  7997. request.Header.Set("x-tif-paasid", gdyb_paasid)
  7998. request.Header.Set("x-tif-signature", signature)
  7999. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  8000. request.Header.Set("x-tif-nonce", nonce)
  8001. client := http.Client{}
  8002. resp, err := client.Do(request)
  8003. if err != nil {
  8004. fmt.Println(err.Error())
  8005. return err.Error(), ""
  8006. }
  8007. respBytes, err := ioutil.ReadAll(resp.Body)
  8008. if err != nil {
  8009. fmt.Println(err.Error())
  8010. return err.Error(), ""
  8011. }
  8012. str := string(respBytes)
  8013. fmt.Println(str)
  8014. return str, string(bytesData)
  8015. }
  8016. func Gzyb3509(struct3509 models.Struct3509, secret_key string) (string, string) {
  8017. // 生成签名
  8018. nonce := GetRandomString(32)
  8019. timestamp := time.Now().Unix()
  8020. signature := setSignature(timestamp, nonce, secret_key)
  8021. // 生成输入报文
  8022. //inputMessage := SetGdInputMessage(timestamp, struct3509.OrgName, struct3509.Opter, struct3509.FixmedinsCode, struct3509.InsuplcAdmdvs, struct3509.MdtrtareaAdmvs, struct3509.Cainfo)
  8023. sign := GetSignInInfo(struct3509.FixmedinsCode)
  8024. inputMessage := SetGZInputMessage(nonce, timestamp, struct3509.OrgName, struct3509.Opter, struct3509.FixmedinsCode, struct3509.InsuplcAdmdvs, struct3509.MdtrtareaAdmvs, sign)
  8025. input := make(map[string]interface{})
  8026. inputData := make(map[string]interface{})
  8027. inputMessage["infno"] = "3509"
  8028. inputData["fixmedins_code"] = struct3509.FixmedinsCode
  8029. //inputData["med_list_codg"] = struct3509.MedinsListCodg
  8030. inputData["medins_list_codg"] = struct3509.MedListCodg
  8031. inputData["fixmedins_bchno"] = ""
  8032. inputData["begndate"] = struct3509.Begndate
  8033. inputData["enddate"] = struct3509.Enddate
  8034. inputData["medins_prod_inv_no"] = ""
  8035. inputData["medins_list_name"] = ""
  8036. inputData["rx_flag"] = ""
  8037. inputData["list_sp_item_flag"] = ""
  8038. inputData["trdn_flag"] = ""
  8039. inputData["invdate"] = ""
  8040. inputData["manu_lotnum"] = ""
  8041. inputData["manu_date"] = ""
  8042. inputData["expy_end"] = ""
  8043. inputData["memo"] = ""
  8044. inputData["vali_flag"] = ""
  8045. inputData["rid"] = ""
  8046. inputData["crter_id"] = ""
  8047. inputData["crter_name"] = ""
  8048. inputData["crte_optins_no"] = ""
  8049. inputData["opter_id"] = ""
  8050. inputData["opter_name"] = ""
  8051. inputData["optins_no"] = ""
  8052. inputData["poolarea_no"] = ""
  8053. inputData["fixmedins_bchno"] = ""
  8054. inputData["inv_data_type"] = ""
  8055. input["data"] = inputData
  8056. inputMessage["input"] = input //交易输入
  8057. bytesData, err := json.Marshal(inputMessage)
  8058. fmt.Println(string(bytesData))
  8059. if err != nil {
  8060. fmt.Println(err.Error())
  8061. return err.Error(), ""
  8062. }
  8063. reader := bytes.NewReader(bytesData)
  8064. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  8065. gdyb_url := beego.AppConfig.String("gdyb_url")
  8066. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  8067. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  8068. url := gdyb_url + "3509"
  8069. request, err := http.NewRequest("POST", url, reader)
  8070. if err != nil {
  8071. fmt.Println(err.Error())
  8072. return err.Error(), ""
  8073. }
  8074. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  8075. request.Header.Set("x-tif-paasid", gdyb_paasid)
  8076. request.Header.Set("x-tif-signature", signature)
  8077. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  8078. request.Header.Set("x-tif-nonce", nonce)
  8079. client := http.Client{}
  8080. resp, err := client.Do(request)
  8081. if err != nil {
  8082. fmt.Println(err.Error())
  8083. return err.Error(), ""
  8084. }
  8085. respBytes, err := ioutil.ReadAll(resp.Body)
  8086. if err != nil {
  8087. fmt.Println(err.Error())
  8088. return err.Error(), ""
  8089. }
  8090. str := string(respBytes)
  8091. fmt.Println(str)
  8092. return str, string(bytesData)
  8093. }
  8094. func Gzyb3510(struct3510 models.Struct3510, secret_key string) (string, string) {
  8095. // 生成签名
  8096. nonce := GetRandomString(32)
  8097. timestamp := time.Now().Unix()
  8098. signature := setSignature(timestamp, nonce, secret_key)
  8099. // 生成输入报文
  8100. //inputMessage := SetGdInputMessage(timestamp, struct3510.OrgName, struct3510.Opter, struct3510.FixmedinsCode, struct3510.InsuplcAdmdvs, struct3510.MdtrtareaAdmvs, struct3510.Cainfo)
  8101. sign := GetSignInInfo(struct3510.FixmedinsCode)
  8102. inputMessage := SetGZInputMessage(nonce, timestamp, struct3510.OrgName, struct3510.Opter, struct3510.FixmedinsCode, struct3510.InsuplcAdmdvs, struct3510.MdtrtareaAdmvs, sign)
  8103. input := make(map[string]interface{})
  8104. inputData := make(map[string]interface{})
  8105. inputMessage["infno"] = "3510"
  8106. inputData["fixmedins_code"] = struct3510.FixmedinsCode
  8107. //inputData["medins_list_codg"] = struct3510.MedinsListCodg
  8108. inputData["medins_list_codg"] = struct3510.MedListCodg
  8109. inputData["fixmedins_bchno"] = ""
  8110. inputData["begndate"] = struct3510.Begndate
  8111. inputData["enddate"] = struct3510.Enddate
  8112. inputData["medins_prod_inv_no"] = ""
  8113. inputData["medins_list_name"] = ""
  8114. inputData["rx_flag"] = ""
  8115. inputData["list_sp_item_flag"] = ""
  8116. inputData["trdn_flag"] = ""
  8117. inputData["invdate"] = ""
  8118. inputData["manu_lotnum"] = ""
  8119. inputData["manu_date"] = ""
  8120. inputData["expy_end"] = ""
  8121. inputData["memo"] = ""
  8122. inputData["vali_flag"] = ""
  8123. inputData["rid"] = ""
  8124. inputData["crter_id"] = ""
  8125. inputData["crter_name"] = ""
  8126. inputData["crte_optins_no"] = ""
  8127. inputData["opter_id"] = ""
  8128. inputData["opter_name"] = ""
  8129. inputData["optins_no"] = ""
  8130. inputData["poolarea_no"] = ""
  8131. inputData["fixmedins_bchno"] = ""
  8132. inputData["inv_data_type"] = ""
  8133. input["data"] = inputData
  8134. inputMessage["input"] = input //交易输入
  8135. bytesData, err := json.Marshal(inputMessage)
  8136. fmt.Println(string(bytesData))
  8137. if err != nil {
  8138. fmt.Println(err.Error())
  8139. return err.Error(), ""
  8140. }
  8141. reader := bytes.NewReader(bytesData)
  8142. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  8143. gdyb_url := beego.AppConfig.String("gdyb_url")
  8144. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  8145. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  8146. url := gdyb_url + "3510"
  8147. request, err := http.NewRequest("POST", url, reader)
  8148. if err != nil {
  8149. fmt.Println(err.Error())
  8150. return err.Error(), ""
  8151. }
  8152. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  8153. request.Header.Set("x-tif-paasid", gdyb_paasid)
  8154. request.Header.Set("x-tif-signature", signature)
  8155. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  8156. request.Header.Set("x-tif-nonce", nonce)
  8157. client := http.Client{}
  8158. resp, err := client.Do(request)
  8159. if err != nil {
  8160. fmt.Println(err.Error())
  8161. return err.Error(), ""
  8162. }
  8163. respBytes, err := ioutil.ReadAll(resp.Body)
  8164. if err != nil {
  8165. fmt.Println(err.Error())
  8166. return err.Error(), ""
  8167. }
  8168. str := string(respBytes)
  8169. fmt.Println(str)
  8170. return str, string(bytesData)
  8171. }
  8172. func Gzyb3511(struct3511 models.Struct3511, secret_key string) (string, string) {
  8173. // 生成签名
  8174. nonce := GetRandomString(32)
  8175. timestamp := time.Now().Unix()
  8176. signature := setSignature(timestamp, nonce, secret_key)
  8177. // 生成输入报文
  8178. //inputMessage := SetGdInputMessage(timestamp, struct3511.OrgName, struct3511.Opter, struct3511.FixmedinsCode, struct3511.InsuplcAdmdvs, struct3511.MdtrtareaAdmvs, struct3511.Cainfo)
  8179. sign := GetSignInInfo(struct3511.FixmedinsCode)
  8180. inputMessage := SetGZInputMessage(nonce, timestamp, struct3511.OrgName, struct3511.Opter, struct3511.FixmedinsCode, struct3511.InsuplcAdmdvs, struct3511.MdtrtareaAdmvs, sign)
  8181. input := make(map[string]interface{})
  8182. inputData := make(map[string]interface{})
  8183. inputMessage["infno"] = "3511"
  8184. inputData["fixmedins_code"] = struct3511.FixmedinsCode
  8185. //inputData["medins_list_codg"] = struct3511.MedinsListCodg
  8186. inputData["medins_list_codg"] = struct3511.MedListCodg
  8187. inputData["fixmedins_bchno"] = ""
  8188. inputData["begndate"] = struct3511.Begndate
  8189. inputData["enddate"] = struct3511.Enddate
  8190. inputData["medins_prod_inv_no"] = ""
  8191. inputData["medins_list_name"] = ""
  8192. inputData["rx_flag"] = ""
  8193. inputData["list_sp_item_flag"] = ""
  8194. inputData["trdn_flag"] = ""
  8195. inputData["invdate"] = ""
  8196. inputData["manu_lotnum"] = ""
  8197. inputData["manu_date"] = ""
  8198. inputData["expy_end"] = ""
  8199. inputData["memo"] = ""
  8200. inputData["vali_flag"] = ""
  8201. inputData["rid"] = ""
  8202. inputData["crter_id"] = ""
  8203. inputData["crter_name"] = ""
  8204. inputData["crte_optins_no"] = ""
  8205. inputData["opter_id"] = ""
  8206. inputData["opter_name"] = ""
  8207. inputData["optins_no"] = ""
  8208. inputData["poolarea_no"] = ""
  8209. inputData["fixmedins_bchno"] = ""
  8210. inputData["inv_data_type"] = ""
  8211. input["data"] = inputData
  8212. inputMessage["input"] = input //交易输入
  8213. bytesData, err := json.Marshal(inputMessage)
  8214. fmt.Println(string(bytesData))
  8215. if err != nil {
  8216. fmt.Println(err.Error())
  8217. return err.Error(), ""
  8218. }
  8219. reader := bytes.NewReader(bytesData)
  8220. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  8221. gdyb_url := beego.AppConfig.String("gdyb_url")
  8222. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  8223. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  8224. url := gdyb_url + "3511"
  8225. request, err := http.NewRequest("POST", url, reader)
  8226. if err != nil {
  8227. fmt.Println(err.Error())
  8228. return err.Error(), ""
  8229. }
  8230. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  8231. request.Header.Set("x-tif-paasid", gdyb_paasid)
  8232. request.Header.Set("x-tif-signature", signature)
  8233. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  8234. request.Header.Set("x-tif-nonce", nonce)
  8235. client := http.Client{}
  8236. resp, err := client.Do(request)
  8237. if err != nil {
  8238. fmt.Println(err.Error())
  8239. return err.Error(), ""
  8240. }
  8241. respBytes, err := ioutil.ReadAll(resp.Body)
  8242. if err != nil {
  8243. fmt.Println(err.Error())
  8244. return err.Error(), ""
  8245. }
  8246. str := string(respBytes)
  8247. fmt.Println(str)
  8248. return str, string(bytesData)
  8249. }
  8250. func Gzyb3512(struct3512 models.Struct3512, secret_key string) (string, string) {
  8251. // 生成签名
  8252. nonce := GetRandomString(32)
  8253. timestamp := time.Now().Unix()
  8254. signature := setSignature(timestamp, nonce, secret_key)
  8255. // 生成输入报文
  8256. //inputMessage := SetGdInputMessage(timestamp, struct3512.OrgName, struct3512.Opter, struct3512.FixmedinsCode, struct3512.InsuplcAdmdvs, struct3512.MdtrtareaAdmvs, struct3512.Cainfo)
  8257. sign := GetSignInInfo(struct3512.FixmedinsCode)
  8258. inputMessage := SetGZInputMessage(nonce, timestamp, struct3512.OrgName, struct3512.Opter, struct3512.FixmedinsCode, struct3512.InsuplcAdmdvs, struct3512.MdtrtareaAdmvs, sign)
  8259. input := make(map[string]interface{})
  8260. inputData := make(map[string]interface{})
  8261. inputMessage["infno"] = "3512"
  8262. inputData["fixmedins_code"] = struct3512.FixmedinsCode
  8263. //inputData["medins_list_codg"] = struct3512.MedinsListCodg
  8264. inputData["medins_list_codg"] = struct3512.MedListCodg
  8265. inputData["fixmedins_bchno"] = ""
  8266. inputData["begndate"] = struct3512.Begndate
  8267. inputData["enddate"] = struct3512.Enddate
  8268. inputData["medins_prod_inv_no"] = ""
  8269. inputData["medins_list_name"] = ""
  8270. inputData["rx_flag"] = ""
  8271. inputData["list_sp_item_flag"] = ""
  8272. inputData["trdn_flag"] = ""
  8273. inputData["invdate"] = ""
  8274. inputData["manu_lotnum"] = ""
  8275. inputData["manu_date"] = ""
  8276. inputData["expy_end"] = ""
  8277. inputData["memo"] = ""
  8278. inputData["vali_flag"] = ""
  8279. inputData["rid"] = ""
  8280. inputData["crter_id"] = ""
  8281. inputData["crter_name"] = ""
  8282. inputData["crte_optins_no"] = ""
  8283. inputData["opter_id"] = ""
  8284. inputData["opter_name"] = ""
  8285. inputData["optins_no"] = ""
  8286. inputData["poolarea_no"] = ""
  8287. inputData["fixmedins_bchno"] = ""
  8288. inputData["inv_data_type"] = ""
  8289. input["data"] = inputData
  8290. inputMessage["input"] = input //交易输入
  8291. bytesData, err := json.Marshal(inputMessage)
  8292. fmt.Println(string(bytesData))
  8293. if err != nil {
  8294. fmt.Println(err.Error())
  8295. return err.Error(), ""
  8296. }
  8297. reader := bytes.NewReader(bytesData)
  8298. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  8299. gdyb_url := beego.AppConfig.String("gdyb_url")
  8300. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  8301. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  8302. url := gdyb_url + "3512"
  8303. request, err := http.NewRequest("POST", url, reader)
  8304. if err != nil {
  8305. fmt.Println(err.Error())
  8306. return err.Error(), ""
  8307. }
  8308. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  8309. request.Header.Set("x-tif-paasid", gdyb_paasid)
  8310. request.Header.Set("x-tif-signature", signature)
  8311. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  8312. request.Header.Set("x-tif-nonce", nonce)
  8313. client := http.Client{}
  8314. resp, err := client.Do(request)
  8315. if err != nil {
  8316. fmt.Println(err.Error())
  8317. return err.Error(), ""
  8318. }
  8319. respBytes, err := ioutil.ReadAll(resp.Body)
  8320. if err != nil {
  8321. fmt.Println(err.Error())
  8322. return err.Error(), ""
  8323. }
  8324. str := string(respBytes)
  8325. fmt.Println(str)
  8326. return str, string(bytesData)
  8327. }
  8328. func Gzyb3513(struct3513 models.Struct3513, secret_key string) (string, string) {
  8329. // 生成签名
  8330. nonce := GetRandomString(32)
  8331. timestamp := time.Now().Unix()
  8332. signature := setSignature(timestamp, nonce, secret_key)
  8333. // 生成输入报文
  8334. //inputMessage := SetGdInputMessage(timestamp, struct3513.OrgName, struct3513.Opter, struct3513.FixmedinsCode, struct3513.InsuplcAdmdvs, struct3513.MdtrtareaAdmvs, struct3513.Cainfo)
  8335. sign := GetSignInInfo(struct3513.FixmedinsCode)
  8336. inputMessage := SetGZInputMessage(nonce, timestamp, struct3513.OrgName, struct3513.Opter, struct3513.FixmedinsCode, struct3513.InsuplcAdmdvs, struct3513.MdtrtareaAdmvs, sign)
  8337. input := make(map[string]interface{})
  8338. inputData := make(map[string]interface{})
  8339. inputMessage["infno"] = "3513"
  8340. inputData["fixmedins_code"] = struct3513.FixmedinsCode
  8341. //inputData["medins_list_codg"] = struct3513.MedinsListCodg
  8342. inputData["medins_list_codg"] = struct3513.MedListCodg
  8343. inputData["fixmedins_bchno"] = ""
  8344. inputData["begndate"] = struct3513.Begndate
  8345. inputData["enddate"] = struct3513.Enddate
  8346. inputData["medins_prod_inv_no"] = ""
  8347. inputData["med_list_codg"] = ""
  8348. inputData["medins_list_name"] = ""
  8349. inputData["rx_flag"] = ""
  8350. inputData["list_sp_item_flag"] = ""
  8351. inputData["trdn_flag"] = ""
  8352. inputData["invdate"] = ""
  8353. inputData["manu_lotnum"] = ""
  8354. inputData["manu_date"] = ""
  8355. inputData["expy_end"] = ""
  8356. inputData["memo"] = ""
  8357. inputData["vali_flag"] = ""
  8358. inputData["rid"] = ""
  8359. inputData["crter_id"] = ""
  8360. inputData["crter_name"] = ""
  8361. inputData["crte_optins_no"] = ""
  8362. inputData["opter_id"] = ""
  8363. inputData["opter_name"] = ""
  8364. inputData["optins_no"] = ""
  8365. inputData["poolarea_no"] = ""
  8366. inputData["fixmedins_bchno"] = ""
  8367. inputData["inv_data_type"] = ""
  8368. input["data"] = inputData
  8369. inputMessage["input"] = input //交易输入
  8370. bytesData, err := json.Marshal(inputMessage)
  8371. fmt.Println(string(bytesData))
  8372. if err != nil {
  8373. fmt.Println(err.Error())
  8374. return err.Error(), ""
  8375. }
  8376. reader := bytes.NewReader(bytesData)
  8377. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  8378. gdyb_url := beego.AppConfig.String("gdyb_url")
  8379. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  8380. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  8381. url := gdyb_url + "3513"
  8382. request, err := http.NewRequest("POST", url, reader)
  8383. if err != nil {
  8384. fmt.Println(err.Error())
  8385. return err.Error(), ""
  8386. }
  8387. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  8388. request.Header.Set("x-tif-paasid", gdyb_paasid)
  8389. request.Header.Set("x-tif-signature", signature)
  8390. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  8391. request.Header.Set("x-tif-nonce", nonce)
  8392. client := http.Client{}
  8393. resp, err := client.Do(request)
  8394. if err != nil {
  8395. fmt.Println(err.Error())
  8396. return err.Error(), ""
  8397. }
  8398. respBytes, err := ioutil.ReadAll(resp.Body)
  8399. if err != nil {
  8400. fmt.Println(err.Error())
  8401. return err.Error(), ""
  8402. }
  8403. str := string(respBytes)
  8404. fmt.Println(str)
  8405. return str, string(bytesData)
  8406. }
  8407. // 生成基础报文
  8408. 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{} {
  8409. // 生成签名
  8410. tempTime := time.Unix(timestamp, 0)
  8411. //timeFormat := tempTime.Format("20060102150405")
  8412. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  8413. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  8414. month := time.Unix(1557042972, 0).Format("1")
  8415. year := time.Now().Format("2006")
  8416. month = time.Now().Format("01")
  8417. day := time.Now().Format("02")
  8418. hour := time.Now().Format("15")
  8419. min := time.Now().Format("04")
  8420. sec := time.Now().Format("05")
  8421. msec := time.Now().Format("000")
  8422. // 生成输入报文
  8423. inputMessage := make(map[string]interface{})
  8424. inputMessage["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  8425. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  8426. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  8427. inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  8428. inputMessage["dev_no"] = "" // 设备编号
  8429. inputMessage["dev_safe_info"] = "" // 设备安全信息
  8430. inputMessage["cainfo"] = "" // 数字签名信息
  8431. inputMessage["signtype"] = "SM3" // 签名类型
  8432. inputMessage["infver"] = "V1.0" // 接收方系统代码
  8433. inputMessage["opter_type"] = "1" // 经办人类别
  8434. inputMessage["opter"] = doctor // 经办人
  8435. inputMessage["opter_name"] = doctor // 经办人姓名
  8436. inputMessage["inf_time"] = timeFormatOne // 交易时间
  8437. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  8438. inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  8439. inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号
  8440. //inputMessage["sign_no"] = "GZYBCS4101A20220202"
  8441. return inputMessage
  8442. }