gdyb_service.go 368KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314
  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. {
  198. request, err := http.NewRequest("POST", url, reader)
  199. if err != nil {
  200. fmt.Println(err.Error())
  201. return err.Error()
  202. }
  203. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  204. request.Header.Set("x-tif-paasid", gdyb_paasid)
  205. request.Header.Set("x-tif-signature", signature)
  206. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  207. request.Header.Set("x-tif-nonce", nonce)
  208. client := http.Client{}
  209. resp, err := client.Do(request)
  210. if err != nil {
  211. fmt.Println(err.Error())
  212. return err.Error()
  213. }
  214. respBytes, err := ioutil.ReadAll(resp.Body)
  215. if err != nil {
  216. fmt.Println(err.Error())
  217. return err.Error()
  218. }
  219. fmt.Println(string(respBytes))
  220. str := string(respBytes)
  221. return str
  222. }
  223. }
  224. // 门诊挂号
  225. 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) {
  226. fmt.Println(opera)
  227. // 生成签名
  228. nonce := GetRandomString(32)
  229. timestamp := time.Now().Unix()
  230. signature := setSignature(timestamp, nonce, secret_key)
  231. tempTime := time.Unix(timestamp, 0)
  232. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  233. // 生成输入报文
  234. inputMessage := SetInputMessagenosign(nonce, timestamp, org_name, opera, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  235. input := make(map[string]interface{})
  236. inputData := make(map[string]interface{})
  237. inputMessage["infno"] = "2201" // 交易编码
  238. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  239. inputData["insutype"] = insutype // 险种类型(来自1101接口返回)
  240. inputData["begntime"] = timeFormatOne // 开始时间
  241. if id_card_type == 1 {
  242. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  243. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  244. } else {
  245. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  246. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  247. }
  248. inputData["ipt_otp_no"] = ipt_otp_no // 住院/门诊号
  249. inputData["atddr_no"] = doctor_id // 医师编码
  250. inputData["dr_name"] = doctor_name // 医师姓名
  251. inputData["dept_code"] = dept_code // 科室编码
  252. inputData["dept_name"] = dept // 科室名称
  253. inputData["caty"] = "A03.06" // 科别
  254. input["data"] = inputData
  255. inputMessage["input"] = input //交易输入
  256. var requestLog string
  257. bytesData, err := json.Marshal(inputMessage)
  258. requestLog = string(bytesData)
  259. fmt.Println(string(bytesData))
  260. if err != nil {
  261. fmt.Println(err.Error())
  262. return err.Error(), ""
  263. }
  264. reader := bytes.NewReader(bytesData)
  265. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2201"
  266. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2201"
  267. gdyb_url := beego.AppConfig.String("gdyb_url")
  268. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  269. var url string
  270. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  271. url = gdyb_url
  272. } else {
  273. url = gdyb_url + "2201"
  274. }
  275. {
  276. request, err := http.NewRequest("POST", url, reader)
  277. if err != nil {
  278. fmt.Println(err.Error())
  279. return err.Error(), ""
  280. }
  281. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  282. request.Header.Set("x-tif-paasid", gdyb_paasid)
  283. request.Header.Set("x-tif-signature", signature)
  284. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  285. request.Header.Set("x-tif-nonce", nonce)
  286. client := http.Client{}
  287. resp, err := client.Do(request)
  288. if err != nil {
  289. fmt.Println(err.Error())
  290. return err.Error(), ""
  291. }
  292. respBytes, err := ioutil.ReadAll(resp.Body)
  293. if err != nil {
  294. fmt.Println(err.Error())
  295. return err.Error(), ""
  296. }
  297. str := string(respBytes)
  298. fmt.Println(str)
  299. return str, requestLog
  300. }
  301. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2201"
  302. }
  303. 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) {
  304. fmt.Println(opera)
  305. // 生成签名
  306. nonce := GetRandomString(32)
  307. timestamp := time.Now().Unix()
  308. signature := setSignature(timestamp, nonce, secret_key)
  309. //tempTime := time.Unix(timestamp, 0)
  310. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  311. inputMessage := make(map[string]interface{})
  312. //tempTime := time.Unix(timestamp, 0)
  313. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  314. // 生成输入报文
  315. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  316. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, opera)
  317. } else {
  318. inputMessage = SetInputMessage(nonce, timestamp, org_name, opera, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  319. }
  320. // 生成输入报文
  321. //inputMessage := SetInputMessagenosign(nonce, timestamp, org_name, opera, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  322. input := make(map[string]interface{})
  323. inputData := make(map[string]interface{})
  324. inputMessage["infno"] = "2201" // 交易编码
  325. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  326. inputData["insutype"] = insutype // 险种类型(来自1101接口返回)
  327. inputData["begntime"] = record_time // 开始时间
  328. if id_card_type == 1 {
  329. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  330. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  331. } else if id_card_type == 4 {
  332. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  333. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  334. } else {
  335. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  336. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  337. }
  338. inputData["ipt_otp_no"] = ipt_otp_no // 住院/门诊号
  339. inputData["atddr_no"] = doctor_id // 医师编码
  340. inputData["dr_name"] = doctor_name // 医师姓名
  341. inputData["dept_code"] = dept_code // 科室编码
  342. inputData["dept_name"] = dept // 科室名称
  343. inputData["caty"] = "A03.06" // 科别
  344. input["data"] = inputData
  345. inputMessage["input"] = input //交易输入
  346. var requestLog string
  347. bytesData, err := json.Marshal(inputMessage)
  348. requestLog = string(bytesData)
  349. fmt.Println(string(bytesData))
  350. if err != nil {
  351. fmt.Println(err.Error())
  352. return err.Error(), ""
  353. }
  354. reader := bytes.NewReader(bytesData)
  355. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2201"
  356. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2201"
  357. gdyb_url := beego.AppConfig.String("gdyb_url")
  358. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  359. var url string
  360. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  361. url = gdyb_url
  362. } else {
  363. url = gdyb_url + "2201"
  364. }
  365. {
  366. fmt.Println(url)
  367. fmt.Println(gdyb_paasid)
  368. fmt.Println(secret_key)
  369. request, err := http.NewRequest("POST", url, reader)
  370. if err != nil {
  371. fmt.Println(err.Error())
  372. return err.Error(), ""
  373. }
  374. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  375. request.Header.Set("x-tif-paasid", gdyb_paasid)
  376. request.Header.Set("x-tif-signature", signature)
  377. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  378. request.Header.Set("x-tif-nonce", nonce)
  379. client := http.Client{}
  380. resp, err := client.Do(request)
  381. if err != nil {
  382. fmt.Println(err.Error())
  383. return err.Error(), ""
  384. }
  385. respBytes, err := ioutil.ReadAll(resp.Body)
  386. if err != nil {
  387. fmt.Println(err.Error())
  388. return err.Error(), ""
  389. }
  390. str := string(respBytes)
  391. fmt.Println(str)
  392. return str, requestLog
  393. }
  394. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2201"
  395. }
  396. // 门诊挂号撤销
  397. 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) {
  398. // 生成签名
  399. nonce := GetRandomString(32)
  400. timestamp := time.Now().Unix()
  401. signature := setSignature(timestamp, nonce, secret_key)
  402. // 生成输入报文
  403. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  404. inputMessage := make(map[string]interface{})
  405. //tempTime := time.Unix(timestamp, 0)
  406. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  407. // 生成输入报文
  408. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  409. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  410. } else {
  411. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  412. }
  413. input := make(map[string]interface{})
  414. inputData := make(map[string]interface{})
  415. inputMessage["infno"] = "2202" // 交易编码
  416. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  417. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  418. inputData["ipt_otp_no"] = ipt_otp_no // 住院/门诊号
  419. input["data"] = inputData
  420. inputMessage["input"] = input //交易输入
  421. var requestLog string
  422. bytesData, err := json.Marshal(inputMessage)
  423. fmt.Println(string(bytesData))
  424. requestLog = string(bytesData)
  425. if err != nil {
  426. fmt.Println(err.Error())
  427. return err.Error(), ""
  428. }
  429. reader := bytes.NewReader(bytesData)
  430. gdyb_url := beego.AppConfig.String("gdyb_url")
  431. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  432. var url string
  433. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  434. url = gdyb_url
  435. } else {
  436. url = gdyb_url + "2202"
  437. }
  438. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2202"
  439. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2202"
  440. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2202"
  441. {
  442. request, err := http.NewRequest("POST", url, reader)
  443. if err != nil {
  444. fmt.Println(err.Error())
  445. return err.Error(), ""
  446. }
  447. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  448. request.Header.Set("x-tif-paasid", gdyb_paasid)
  449. request.Header.Set("x-tif-signature", signature)
  450. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  451. request.Header.Set("x-tif-nonce", nonce)
  452. client := http.Client{}
  453. resp, err := client.Do(request)
  454. if err != nil {
  455. fmt.Println(err.Error())
  456. return err.Error(), ""
  457. }
  458. respBytes, err := ioutil.ReadAll(resp.Body)
  459. if err != nil {
  460. fmt.Println(err.Error())
  461. return err.Error(), ""
  462. }
  463. str := string(respBytes)
  464. fmt.Println(str)
  465. return str, requestLog
  466. }
  467. }
  468. // 门诊就诊信息上传
  469. 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) {
  470. // 生成签名
  471. nonce := GetRandomString(32)
  472. timestamp := time.Now().Unix()
  473. signature := setSignature(timestamp, nonce, secret_key)
  474. inputMessage := make(map[string]interface{})
  475. //tempTime := time.Unix(timestamp, 0)
  476. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  477. // 生成输入报文
  478. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  479. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, op_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, op_name)
  480. } else {
  481. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  482. }
  483. //inputMessage := SetInputMessage1111(nonce, timestamp, org_name, op_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs,op_name)
  484. input := make(map[string]interface{})
  485. inputData := make(map[string]interface{})
  486. diseinfo := make([]map[string]interface{}, 0)
  487. if med_type == "1111" || med_type == "1112" {
  488. med_type = "11"
  489. }
  490. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  491. inputMessage["infno"] = "2203" // 交易编码
  492. } else {
  493. inputMessage["infno"] = "2203" // 交易编码
  494. }
  495. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  496. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  497. inputData["med_type"] = med_type // 医疗类别 16门诊特殊病
  498. inputData["begntime"] = begin_time // 开始时间
  499. //inputData["begntime"] = // 开始时间
  500. inputData["main_cond_dscr"] = "" // 主要病情描述
  501. inputData["dise_codg"] = sick_code // 病种编码
  502. inputData["dise_name"] = sick_name // 病种名称
  503. if med_type == "12" {
  504. inputData["dise_codg"] = "" // 病种编码
  505. inputData["dise_name"] = "" // 病种名称
  506. }
  507. inputData["birctrl_type"] = "" // 计划生育手术类别
  508. inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
  509. for index, item := range config {
  510. diseinfo_sun := make(map[string]interface{})
  511. diseinfo_sun["diag_type"] = "1" // 诊断类别
  512. diseinfo_sun["diag_srt_no"] = index + 1 // 诊断排序号
  513. diseinfo_sun["diag_code"] = item.CountryCode // 诊断代码
  514. diseinfo_sun["diag_name"] = item.ClassName // 诊断名称
  515. diseinfo_sun["diag_dept"] = department // 诊断科室
  516. diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
  517. diseinfo_sun["dise_dor_name"] = doctor_name // 诊断医生姓名
  518. diseinfo_sun["diag_time"] = begin_time // 诊断时间
  519. diseinfo_sun["vali_flag"] = "1" // 有效标志
  520. diseinfo = append(diseinfo, diseinfo_sun)
  521. }
  522. input["diseinfo"] = diseinfo
  523. input["mdtrtinfo"] = inputData
  524. inputMessage["input"] = input //交易输入
  525. var requestLog string
  526. bytesData, err := json.Marshal(inputMessage)
  527. fmt.Println(string(bytesData))
  528. requestLog = string(bytesData)
  529. if err != nil {
  530. fmt.Println(err.Error())
  531. return err.Error(), ""
  532. }
  533. reader := bytes.NewReader(bytesData)
  534. gdyb_url := beego.AppConfig.String("gdyb_url")
  535. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  536. var url string
  537. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  538. url = gdyb_url
  539. } else {
  540. url = gdyb_url + "2203"
  541. }
  542. {
  543. request, err := http.NewRequest("POST", url, reader)
  544. if err != nil {
  545. fmt.Println(err.Error())
  546. return err.Error(), ""
  547. }
  548. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  549. request.Header.Set("x-tif-paasid", gdyb_paasid)
  550. request.Header.Set("x-tif-signature", signature)
  551. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  552. request.Header.Set("x-tif-nonce", nonce)
  553. client := http.Client{}
  554. resp, err := client.Do(request)
  555. if err != nil {
  556. fmt.Println(err.Error())
  557. return err.Error(), ""
  558. }
  559. respBytes, err := ioutil.ReadAll(resp.Body)
  560. if err != nil {
  561. fmt.Println(err.Error())
  562. return err.Error(), ""
  563. }
  564. str := string(respBytes)
  565. fmt.Println(str)
  566. return str, requestLog
  567. }
  568. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2203"
  569. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  570. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  571. }
  572. 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) {
  573. // 生成签名
  574. nonce := GetRandomString(32)
  575. timestamp := time.Now().Unix()
  576. signature := setSignature(timestamp, nonce, secret_key)
  577. //tempTime := time.Unix(timestamp, 0)
  578. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  579. // 生成输入报文
  580. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  581. input := make(map[string]interface{})
  582. inputData := make(map[string]interface{})
  583. diseinfo := make([]map[string]interface{}, 0)
  584. if med_type == "1111" || med_type == "1112" {
  585. med_type = "11"
  586. }
  587. inputMessage["infno"] = "2203" // 交易编码
  588. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  589. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  590. inputData["med_type"] = med_type // 医疗类别 16门诊特殊病
  591. inputData["begntime"] = begin_time // 开始时间
  592. //inputData["begntime"] = // 开始时间
  593. inputData["main_cond_dscr"] = "" // 主要病情描述
  594. inputData["dise_codg"] = sick_code // 病种编码
  595. inputData["dise_name"] = sick_name // 病种名称
  596. if med_type == "12" {
  597. inputData["dise_codg"] = "" // 病种编码
  598. inputData["dise_name"] = "" // 病种名称
  599. }
  600. inputData["birctrl_type"] = "" // 计划生育手术类别
  601. inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
  602. for index, item := range config {
  603. diseinfo_sun := make(map[string]interface{})
  604. diseinfo_sun["diag_type"] = "1" // 诊断类别
  605. diseinfo_sun["diag_srt_no"] = index // 诊断排序号
  606. diseinfo_sun["diag_code"] = item.CountryCode // 诊断代码
  607. diseinfo_sun["diag_name"] = item.ClassName // 诊断名称
  608. diseinfo_sun["diag_dept"] = department // 诊断科室
  609. diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
  610. diseinfo_sun["dise_dor_name"] = doctor_name // 诊断医生姓名
  611. diseinfo_sun["diag_time"] = begin_time // 诊断时间
  612. diseinfo_sun["vali_flag"] = "1" // 有效标志
  613. diseinfo = append(diseinfo, diseinfo_sun)
  614. }
  615. input["diseinfo"] = diseinfo
  616. input["mdtrtinfo"] = inputData
  617. inputMessage["input"] = input //交易输入
  618. var requestLog string
  619. bytesData, err := json.Marshal(inputMessage)
  620. fmt.Println(string(bytesData))
  621. requestLog = string(bytesData)
  622. if err != nil {
  623. fmt.Println(err.Error())
  624. return err.Error(), ""
  625. }
  626. reader := bytes.NewReader(bytesData)
  627. gdyb_url := beego.AppConfig.String("gdyb_url")
  628. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  629. var url string
  630. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  631. url = gdyb_url
  632. } else {
  633. url = gdyb_url + "2203"
  634. }
  635. {
  636. request, err := http.NewRequest("POST", url, reader)
  637. if err != nil {
  638. fmt.Println(err.Error())
  639. return err.Error(), ""
  640. }
  641. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  642. request.Header.Set("x-tif-paasid", gdyb_paasid)
  643. request.Header.Set("x-tif-signature", signature)
  644. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  645. request.Header.Set("x-tif-nonce", nonce)
  646. client := http.Client{}
  647. resp, err := client.Do(request)
  648. if err != nil {
  649. fmt.Println(err.Error())
  650. return err.Error(), ""
  651. }
  652. respBytes, err := ioutil.ReadAll(resp.Body)
  653. if err != nil {
  654. fmt.Println(err.Error())
  655. return err.Error(), ""
  656. }
  657. str := string(respBytes)
  658. fmt.Println(str)
  659. return str, requestLog
  660. }
  661. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2203"
  662. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  663. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  664. }
  665. // 门诊就诊信息上传
  666. 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) {
  667. // 生成签名
  668. nonce := GetRandomString(32)
  669. timestamp := time.Now().Unix()
  670. signature := setSignature(timestamp, nonce, secret_key)
  671. tempTime := time.Unix(timestamp, 0)
  672. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  673. // 生成输入报文
  674. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  675. input := make(map[string]interface{})
  676. inputData := make(map[string]interface{})
  677. diseinfo := make([]map[string]interface{}, 0)
  678. if med_type == "1111" || med_type == "1112" {
  679. med_type = "11"
  680. }
  681. inputMessage["infno"] = "2203A" // 交易编码
  682. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  683. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  684. inputData["med_type"] = med_type // 医疗类别 16门诊特殊病
  685. inputData["begntime"] = begin_time // 开始时间
  686. inputData["main_cond_dscr"] = "" // 主要病情描述
  687. inputData["dise_codg"] = sick_code // 病种编码
  688. inputData["dise_name"] = sick_name // 病种名称
  689. inputData["birctrl_type"] = "" // 计划生育手术类别
  690. inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
  691. inputData["matn_type"] = "" // 生育类别
  692. inputData["geso_val"] = "" // 孕周数
  693. for index, item := range config {
  694. diseinfo_sun := make(map[string]interface{})
  695. diseinfo_sun["diag_type"] = "1" // 诊断类别
  696. diseinfo_sun["diag_srt_no"] = index // 诊断排序号
  697. diseinfo_sun["diag_code"] = item.CountryCode // 诊断代码
  698. diseinfo_sun["diag_name"] = item.ClassName // 诊断名称
  699. diseinfo_sun["diag_dept"] = department // 诊断科室
  700. diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
  701. diseinfo_sun["dise_dor_name"] = doctor // 诊断医生姓名
  702. diseinfo_sun["diag_time"] = timeFormatOne // 诊断时间
  703. diseinfo_sun["vali_flag"] = "1" // 有效标志
  704. diseinfo = append(diseinfo, diseinfo_sun)
  705. }
  706. input["diseinfo"] = diseinfo
  707. input["mdtrtinfo"] = inputData
  708. inputMessage["input"] = input //交易输入
  709. var requestLog string
  710. bytesData, err := json.Marshal(inputMessage)
  711. fmt.Println(string(bytesData))
  712. requestLog = string(bytesData)
  713. if err != nil {
  714. fmt.Println(err.Error())
  715. return err.Error(), ""
  716. }
  717. reader := bytes.NewReader(bytesData)
  718. gdyb_url := beego.AppConfig.String("gdyb_url")
  719. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  720. var url string
  721. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  722. url = gdyb_url
  723. } else {
  724. url = gdyb_url + "2203"
  725. }
  726. {
  727. request, err := http.NewRequest("POST", url, reader)
  728. if err != nil {
  729. fmt.Println(err.Error())
  730. return err.Error(), ""
  731. }
  732. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  733. request.Header.Set("x-tif-paasid", gdyb_paasid)
  734. request.Header.Set("x-tif-signature", signature)
  735. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  736. request.Header.Set("x-tif-nonce", nonce)
  737. client := http.Client{}
  738. resp, err := client.Do(request)
  739. if err != nil {
  740. fmt.Println(err.Error())
  741. return err.Error(), ""
  742. }
  743. respBytes, err := ioutil.ReadAll(resp.Body)
  744. if err != nil {
  745. fmt.Println(err.Error())
  746. return err.Error(), ""
  747. }
  748. str := string(respBytes)
  749. fmt.Println(str)
  750. return str, requestLog
  751. }
  752. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2203A"
  753. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  754. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  755. }
  756. 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) {
  757. // 生成签名
  758. nonce := GetRandomString(32)
  759. timestamp := time.Now().Unix()
  760. signature := setSignature(timestamp, nonce, secret_key)
  761. tempTime := time.Unix(timestamp, 0)
  762. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  763. // 生成输入报文
  764. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  765. input := make(map[string]interface{})
  766. inputData := make(map[string]interface{})
  767. diseinfo := make([]map[string]interface{}, 0)
  768. inputMessage["infno"] = "2203" // 交易编码
  769. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  770. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  771. inputData["med_type"] = "14" // 医疗类别 16门诊特殊病
  772. inputData["begntime"] = begin_time // 开始时间
  773. inputData["main_cond_dscr"] = "" // 主要病情描述
  774. inputData["dise_codg"] = sick_code // 病种编码
  775. inputData["dise_name"] = sick_name // 病种名称
  776. inputData["birctrl_type"] = "" // 计划生育手术类别
  777. inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
  778. inputData["matn_type"] = "" // 生育类别
  779. inputData["geso_val"] = "" // 孕周数
  780. for index, item := range config {
  781. diseinfo_sun := make(map[string]interface{})
  782. diseinfo_sun["diag_type"] = "1" // 诊断类别
  783. diseinfo_sun["diag_srt_no"] = index // 诊断排序号
  784. diseinfo_sun["diag_code"] = item.CountryCode // 诊断代码
  785. diseinfo_sun["diag_name"] = item.ClassName // 诊断名称
  786. diseinfo_sun["diag_dept"] = department // 诊断科室
  787. diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
  788. diseinfo_sun["dise_dor_name"] = doctor // 诊断医生姓名
  789. diseinfo_sun["diag_time"] = timeFormatOne // 诊断时间
  790. diseinfo_sun["vali_flag"] = "1" // 有效标志
  791. diseinfo = append(diseinfo, diseinfo_sun)
  792. }
  793. input["diseinfo"] = diseinfo
  794. input["mdtrtinfo"] = inputData
  795. inputMessage["input"] = input //交易输入
  796. var requestLog string
  797. bytesData, err := json.Marshal(inputMessage)
  798. fmt.Println(string(bytesData))
  799. requestLog = string(bytesData)
  800. if err != nil {
  801. fmt.Println(err.Error())
  802. return err.Error(), ""
  803. }
  804. reader := bytes.NewReader(bytesData)
  805. gdyb_url := beego.AppConfig.String("gdyb_url")
  806. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  807. var url string
  808. url = gdyb_url + "2203"
  809. {
  810. request, err := http.NewRequest("POST", url, reader)
  811. if err != nil {
  812. fmt.Println(err.Error())
  813. return err.Error(), ""
  814. }
  815. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  816. request.Header.Set("x-tif-paasid", gdyb_paasid)
  817. request.Header.Set("x-tif-signature", signature)
  818. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  819. request.Header.Set("x-tif-nonce", nonce)
  820. client := http.Client{}
  821. resp, err := client.Do(request)
  822. if err != nil {
  823. fmt.Println(err.Error())
  824. return err.Error(), ""
  825. }
  826. respBytes, err := ioutil.ReadAll(resp.Body)
  827. if err != nil {
  828. fmt.Println(err.Error())
  829. return err.Error(), ""
  830. }
  831. str := string(respBytes)
  832. fmt.Println(str)
  833. return str, requestLog
  834. }
  835. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2203A"
  836. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  837. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  838. }
  839. type Custom struct {
  840. DetItemFeeSumamt string
  841. Cut string
  842. FeedetlSn string
  843. Price string
  844. MedListCodg string
  845. LmtUsedFlag int64
  846. HospApprFlag int64
  847. DoctorNumber string
  848. DoctorName string
  849. ProvinceDrugMedListCodg string
  850. ProvinceGoodMedListCodg string
  851. IsUser int64
  852. FeeOcurTime string
  853. Unit string
  854. }
  855. type RequestResult struct {
  856. Output Output `json:"output" form:"output"`
  857. Infcode int64 `gorm:"column:infcode" json:"infcode" form:"infcode"`
  858. WarnMsg string `gorm:"column:warn_msg" json:"warn_msg" form:"warn_msg"`
  859. Cainfo string `gorm:"column:cainfo" json:"cainfo" form:"cainfo"`
  860. ErrMsg string `gorm:"column:err_msg" json:"err_msg" form:"err_msg"`
  861. RespondTime string `gorm:"column:respond_time" json:"respond_time" form:"respond_time"`
  862. InfRefmsgid string `gorm:"column:inf_refmsgid" json:"inf_refmsgid" form:"inf_refmsgid"`
  863. }
  864. type Output struct {
  865. Result Result `json:"result" form:"result"`
  866. }
  867. type Result struct {
  868. BasMednFlag string `json:"bas_medn_flag" form:"bas_medn_flag"`
  869. MedChrgitmType string `json:"med_chrgitm_type" form:"med_chrgitm_type"`
  870. DetItemFeeSumamt int64 `json:"det_item_fee_sumamt" form:"det_item_fee_sumamt"`
  871. HiNegoDrugFlag string `json:"hi_nego_drug_flag" form:"hi_nego_drug_flag"`
  872. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
  873. FeedtlSn int64 `json:"feedtl_sn" form:"feedtl_sn"`
  874. UploadDate int64 `json:"upload_date" form:"upload_date"`
  875. AdviceId int64 `json:"advice_id" form:"advice_id"`
  876. Cnt int64 `json:"cnt" form:"cnt"`
  877. Pric float64 `json:"pric" form:"pric"`
  878. PatientId int64 `json:"patient_id" form:"patient_id"`
  879. PricUplmtAmt float64 `json:"pric_uplmt_amt" form:"pric_uplmt_amt"`
  880. SelfpayProp float64 `json:"selfpay_prop" form:"selfpay_prop"`
  881. OverlmtAmt float64 `json:"overlmt_amt" form:"overlmt_amt"`
  882. PreselfpayAmt float64 `json:"preselfpay_amt" form:"preselfpay_amt"`
  883. Status int64 `json:"status" form:"status"`
  884. Memo string `json:"memo" form:"memo"`
  885. FeedetlSn string `json:"feedetl_sn" form:"feedetl_sn"`
  886. Mtime int64 `json:"mtime" form:"mtime"`
  887. InscpScpAmt float64 `json:"inscp_scp_amt" form:"inscp_scp_amt"`
  888. DrtReimFlag string `json:"drt_reim_flag" form:"drt_reim_flag"`
  889. Ctime int64 `json:"ctime" form:"ctime"`
  890. ListSpItemFlag string `json:"list_sp_item_flag" form:"list_sp_item_flag"`
  891. ChldMedcFlag string `json:"chld_medc_flag" form:"chld_medc_flag"`
  892. LmtUsedFlag string `json:"lmt_used_flag" form:"lmt_used_flag"`
  893. ChrgitmLv string `json:"chrgitm_lv" form:"chrgitm_lv"`
  894. UserOrgId int64 `json:"user_org_id" form:"user_org_id"`
  895. HisPatientId int64 `json:"his_patient_id" form:"his_patient_id"`
  896. OrderId int64 `json:"order_id" form:"order_id"`
  897. }
  898. // 门诊费用明细信息上传
  899. 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) {
  900. // 生成签名
  901. nonce := GetRandomString(32)
  902. timestamp := time.Now().Unix()
  903. signature := setSignature(timestamp, nonce, secret_key)
  904. //tempTime := time.Unix(timestamp, 0)
  905. //timeFormat := tempTime.Format("20060102150405")
  906. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  907. //chrgBchno := rand.Intn(100000) + 10000
  908. var customs []*Custom
  909. inputMessage := make(map[string]interface{})
  910. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  911. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  912. } else {
  913. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  914. }
  915. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  916. for _, item := range hisPrescription {
  917. role, _ := GetAdminUserInfoByID(item.UserOrgId, new_doctor_id)
  918. tm := time.Unix(item.PreTime, 0)
  919. if item.Type == 1 { //药品
  920. for _, subItem := range item.HisDoctorAdviceInfo {
  921. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 && subItem.BaseDrugLib.IsUser != 1 {
  922. //var randNum int
  923. //randNum = rand.Intn(10000) + 1000
  924. role, _ := GetAdminUserInfoByID(item.UserOrgId, new_doctor_id)
  925. cus := &Custom{
  926. DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  927. Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  928. FeedetlSn: subItem.FeedetlSn,
  929. Price: fmt.Sprintf("%.2f", subItem.Price),
  930. MedListCodg: subItem.BaseDrugLib.MedicalInsuranceNumber,
  931. HospApprFlag: subItem.HospApprFlag,
  932. DoctorNumber: role.DoctorNumber,
  933. DoctorName: role.UserName,
  934. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  935. }
  936. customs = append(customs, cus)
  937. }
  938. }
  939. }
  940. if item.Type == 2 { //项目
  941. for _, subItem := range item.HisPrescriptionProject {
  942. //var randNum int
  943. //randNum = rand.Intn(10000) + 1000
  944. if subItem.Type == 2 {
  945. if len(subItem.HisProject.MedicalCode) > 0 {
  946. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  947. cus := &Custom{
  948. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  949. Cut: fmt.Sprintf("%.4f", cnt),
  950. FeedetlSn: subItem.FeedetlSn,
  951. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  952. MedListCodg: subItem.HisProject.MedicalCode,
  953. DoctorNumber: role.DoctorNumber,
  954. DoctorName: role.UserName,
  955. HospApprFlag: -1,
  956. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  957. }
  958. customs = append(customs, cus)
  959. }
  960. } else if subItem.Type == 3 {
  961. if len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  962. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  963. cus := &Custom{
  964. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  965. Cut: fmt.Sprintf("%.4f", cnt),
  966. FeedetlSn: subItem.FeedetlSn,
  967. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  968. MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
  969. HospApprFlag: -1,
  970. DoctorNumber: role.DoctorNumber,
  971. DoctorName: role.UserName,
  972. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  973. }
  974. customs = append(customs, cus)
  975. }
  976. }
  977. }
  978. }
  979. for _, subItem := range item.HisAdditionalCharge {
  980. if len(subItem.XtHisAddtionConfig.Code) > 0 {
  981. cus := &Custom{
  982. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*float64(subItem.Count)),
  983. Cut: fmt.Sprintf("%.4f", float64(subItem.Count)),
  984. FeedetlSn: subItem.FeedetlSn,
  985. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  986. MedListCodg: subItem.XtHisAddtionConfig.Code,
  987. HospApprFlag: -1,
  988. DoctorNumber: role.DoctorNumber,
  989. DoctorName: role.UserName,
  990. }
  991. customs = append(customs, cus)
  992. }
  993. }
  994. }
  995. // 生成输入报文
  996. input := make(map[string]interface{})
  997. feedetail := make([]map[string]interface{}, 0)
  998. inputMessage["infno"] = "2204" // 交易编码
  999. //chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  1000. for _, item := range customs {
  1001. feedetailInfo := make(map[string]interface{})
  1002. feedetailInfo["feedetl_sn"] = item.FeedetlSn
  1003. feedetailInfo["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1004. feedetailInfo["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1005. feedetailInfo["chrg_bchno"] = chrg_bchno // 收费批次号
  1006. feedetailInfo["dise_codg"] = diag_code // 病种编码
  1007. feedetailInfo["rxno"] = "" // 处方号
  1008. feedetailInfo["rx_circ_flag"] = "0" // 外购处方标志
  1009. feedetailInfo["fee_ocur_time"] = item.FeeOcurTime // 费用发生时间
  1010. feedetailInfo["med_list_codg"] = item.MedListCodg // 医疗目录编码
  1011. feedetailInfo["medins_list_codg"] = item.MedListCodg // 医药机构目录编码
  1012. feedetailInfo["det_item_fee_sumamt"] = item.DetItemFeeSumamt // 明细项目费用总额
  1013. feedetailInfo["cnt"] = item.Cut // 数量
  1014. feedetailInfo["pric"] = item.Price // 单价
  1015. feedetailInfo["sin_dos_dscr"] = "1" // 单次剂量描述
  1016. feedetailInfo["used_frqu_dscr"] = "" // 使用频次描述
  1017. feedetailInfo["prd_days"] = "0" // 周期天数
  1018. feedetailInfo["medc_way_dscr"] = "" // 用药途径描述
  1019. feedetailInfo["bilg_dept_codg"] = dept_code // 开单科室编码
  1020. feedetailInfo["bilg_dept_name"] = dept // 开单科室名称
  1021. feedetailInfo["bilg_dr_codg"] = item.DoctorNumber // 开单医生编码
  1022. feedetailInfo["bilg_dr_name"] = item.DoctorName // 开单医师姓名
  1023. feedetailInfo["acord_dept_codg"] = "" // 受单科室编码
  1024. feedetailInfo["acord_dept_name"] = "" // 受单科室名称
  1025. feedetailInfo["orders_dr_code"] = item.DoctorNumber // 受单医生编码
  1026. feedetailInfo["orders_dr_name"] = item.DoctorName // 受单医生姓名
  1027. if balance_accounts_type == "8" {
  1028. feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
  1029. } else {
  1030. if item.HospApprFlag != -1 {
  1031. if item.HospApprFlag == 1 {
  1032. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  1033. } else if item.HospApprFlag == 2 {
  1034. feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
  1035. } else if item.HospApprFlag == 3 {
  1036. feedetailInfo["hosp_appr_flag"] = "0" // 医院审批标志
  1037. } else {
  1038. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  1039. }
  1040. } else {
  1041. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  1042. }
  1043. }
  1044. //feedetailInfo["tcmdrug_used_way"] = "" // 中药使用方式
  1045. feedetailInfo["etip_flag"] = "0" // 外检标志
  1046. feedetailInfo["etip_hosp_code"] = "" // 外检医院编码
  1047. feedetailInfo["dscg_tkdrug_flag"] = "" // 出院带药标志
  1048. feedetailInfo["matn_fee_flag"] = "" // 生育费用标志
  1049. feedetail = append(feedetail, feedetailInfo)
  1050. }
  1051. input["feedetail"] = feedetail
  1052. inputMessage["input"] = input //交易输入
  1053. var requestLog string
  1054. bytesData, err := json.Marshal(inputMessage)
  1055. fmt.Println("----------")
  1056. fmt.Println(string(bytesData))
  1057. fmt.Println("----------")
  1058. requestLog = string(bytesData)
  1059. if err != nil {
  1060. fmt.Println(err.Error())
  1061. return "", ""
  1062. }
  1063. reader := bytes.NewReader(bytesData)
  1064. gdyb_url := beego.AppConfig.String("gdyb_url")
  1065. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1066. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1067. var url string
  1068. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  1069. url = gdyb_url
  1070. } else {
  1071. url = gdyb_url + "2204"
  1072. }
  1073. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2204"
  1074. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2204"
  1075. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2204"
  1076. {
  1077. request, err := http.NewRequest("POST", url, reader)
  1078. if err != nil {
  1079. fmt.Println(err.Error())
  1080. return "", ""
  1081. }
  1082. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1083. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1084. request.Header.Set("x-tif-signature", signature)
  1085. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1086. request.Header.Set("x-tif-nonce", nonce)
  1087. client := http.Client{}
  1088. resp, err := client.Do(request)
  1089. if err != nil {
  1090. fmt.Println(err.Error())
  1091. return "", ""
  1092. }
  1093. respBytes, err := ioutil.ReadAll(resp.Body)
  1094. if err != nil {
  1095. fmt.Println(err.Error())
  1096. return "", ""
  1097. }
  1098. return string(respBytes), requestLog
  1099. }
  1100. //var result RequestResult
  1101. //json.Unmarshal(respBytes, &result)
  1102. //return &result
  1103. }
  1104. 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) {
  1105. // 生成签名
  1106. nonce := GetRandomString(32)
  1107. timestamp := time.Now().Unix()
  1108. signature := setSignature(timestamp, nonce, secret_key)
  1109. //tempTime := time.Unix(timestamp, 0)
  1110. //timeFormat := tempTime.Format("20060102150405")
  1111. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  1112. //chrgBchno := rand.Intn(100000) + 10000
  1113. var customs []*Custom
  1114. for _, item := range hisPrescription {
  1115. tm := time.Unix(item.PreTime, 0)
  1116. if item.Type == 1 { //药品
  1117. for _, subItem := range item.HisDoctorAdviceInfo {
  1118. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 && subItem.BaseDrugLib.IsUser != 1 {
  1119. //var randNum int
  1120. //randNum = rand.Intn(10000) + 1000
  1121. cus := &Custom{
  1122. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber),
  1123. Cut: fmt.Sprintf("%.4f", subItem.PrescribingNumber),
  1124. FeedetlSn: subItem.FeedetlSn,
  1125. Price: fmt.Sprintf("%.4f", subItem.Price),
  1126. MedListCodg: subItem.BaseDrugLib.MedicalInsuranceNumber,
  1127. HospApprFlag: subItem.HospApprFlag,
  1128. DoctorNumber: new_doctor_id,
  1129. DoctorName: new_doctor_name,
  1130. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  1131. }
  1132. customs = append(customs, cus)
  1133. }
  1134. }
  1135. }
  1136. if item.Type == 2 { //项目
  1137. for _, subItem := range item.HisPrescriptionProject {
  1138. //var randNum int
  1139. //randNum = rand.Intn(10000) + 1000
  1140. if subItem.Type == 2 {
  1141. if len(subItem.HisProject.MedicalCode) > 0 {
  1142. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1143. cus := &Custom{
  1144. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  1145. Cut: fmt.Sprintf("%.4f", cnt),
  1146. FeedetlSn: subItem.FeedetlSn,
  1147. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  1148. MedListCodg: subItem.HisProject.MedicalCode,
  1149. DoctorNumber: new_doctor_id,
  1150. DoctorName: new_doctor_name,
  1151. HospApprFlag: -1,
  1152. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  1153. }
  1154. customs = append(customs, cus)
  1155. }
  1156. } else if subItem.Type == 3 {
  1157. if len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  1158. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1159. cus := &Custom{
  1160. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  1161. Cut: fmt.Sprintf("%.4f", cnt),
  1162. FeedetlSn: subItem.FeedetlSn,
  1163. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  1164. MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
  1165. HospApprFlag: -1,
  1166. DoctorNumber: new_doctor_id,
  1167. DoctorName: new_doctor_name,
  1168. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  1169. }
  1170. customs = append(customs, cus)
  1171. }
  1172. }
  1173. }
  1174. }
  1175. for _, subItem := range item.HisAdditionalCharge {
  1176. if len(subItem.XtHisAddtionConfig.Code) > 0 {
  1177. cus := &Custom{
  1178. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*float64(subItem.Count)),
  1179. Cut: fmt.Sprintf("%.4f", float64(subItem.Count)),
  1180. FeedetlSn: subItem.FeedetlSn,
  1181. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  1182. MedListCodg: subItem.XtHisAddtionConfig.Code,
  1183. HospApprFlag: -1,
  1184. DoctorNumber: new_doctor_id,
  1185. DoctorName: new_doctor_name,
  1186. }
  1187. customs = append(customs, cus)
  1188. }
  1189. }
  1190. }
  1191. // 生成输入报文
  1192. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1193. input := make(map[string]interface{})
  1194. feedetail := make([]map[string]interface{}, 0)
  1195. inputMessage["infno"] = "2204" // 交易编码
  1196. //chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  1197. for _, item := range customs {
  1198. feedetailInfo := make(map[string]interface{})
  1199. feedetailInfo["feedetl_sn"] = item.FeedetlSn
  1200. feedetailInfo["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1201. feedetailInfo["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1202. feedetailInfo["chrg_bchno"] = chrg_bchno // 收费批次号
  1203. feedetailInfo["dise_codg"] = diag_code // 病种编码
  1204. feedetailInfo["rxno"] = "" // 处方号
  1205. feedetailInfo["rx_circ_flag"] = "0" // 外购处方标志
  1206. feedetailInfo["fee_ocur_time"] = item.FeeOcurTime // 费用发生时间
  1207. feedetailInfo["med_list_codg"] = item.MedListCodg // 医疗目录编码
  1208. feedetailInfo["medins_list_codg"] = fixmedins_code // 医药机构目录编码
  1209. feedetailInfo["det_item_fee_sumamt"] = item.DetItemFeeSumamt // 明细项目费用总额
  1210. feedetailInfo["cnt"] = item.Cut // 数量
  1211. feedetailInfo["pric"] = item.Price // 单价
  1212. feedetailInfo["sin_dos_dscr"] = "" // 单次剂量描述
  1213. feedetailInfo["used_frqu_dscr"] = "" // 使用频次描述
  1214. feedetailInfo["prd_days"] = "0" // 周期天数
  1215. feedetailInfo["medc_way_dscr"] = "" // 用药途径描述
  1216. feedetailInfo["bilg_dept_codg"] = dept_code // 开单科室编码
  1217. feedetailInfo["bilg_dept_name"] = dept // 开单科室名称
  1218. feedetailInfo["bilg_dr_codg"] = item.DoctorNumber // 开单医生编码
  1219. feedetailInfo["bilg_dr_name"] = item.DoctorName // 开单医师姓名
  1220. feedetailInfo["acord_dept_codg"] = "" // 受单科室编码
  1221. feedetailInfo["acord_dept_name"] = "" // 受单科室名称
  1222. feedetailInfo["orders_dr_code"] = item.DoctorNumber // 受单医生编码
  1223. feedetailInfo["orders_dr_name"] = item.DoctorName // 受单医生姓名
  1224. if balance_accounts_type == "8" {
  1225. feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
  1226. } else {
  1227. if item.HospApprFlag != -1 {
  1228. if item.HospApprFlag == 1 {
  1229. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  1230. } else if item.HospApprFlag == 2 {
  1231. feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
  1232. } else if item.HospApprFlag == 3 {
  1233. feedetailInfo["hosp_appr_flag"] = "0" // 医院审批标志
  1234. } else {
  1235. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  1236. }
  1237. } else {
  1238. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  1239. }
  1240. }
  1241. //feedetailInfo["tcmdrug_used_way"] = "" // 中药使用方式
  1242. feedetailInfo["etip_flag"] = "" // 外检标志
  1243. feedetailInfo["etip_hosp_code"] = "" // 外检医院编码
  1244. feedetailInfo["dscg_tkdrug_flag"] = "" // 出院带药标志
  1245. feedetailInfo["matn_fee_flag"] = "" // 生育费用标志
  1246. feedetail = append(feedetail, feedetailInfo)
  1247. }
  1248. input["feedetail"] = feedetail
  1249. inputMessage["input"] = input //交易输入
  1250. var requestLog string
  1251. bytesData, err := json.Marshal(inputMessage)
  1252. fmt.Println("----------")
  1253. fmt.Println(string(bytesData))
  1254. fmt.Println("----------")
  1255. requestLog = string(bytesData)
  1256. if err != nil {
  1257. fmt.Println(err.Error())
  1258. return "", ""
  1259. }
  1260. reader := bytes.NewReader(bytesData)
  1261. gdyb_url := beego.AppConfig.String("gdyb_url")
  1262. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1263. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1264. var url string
  1265. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  1266. url = gdyb_url
  1267. } else {
  1268. url = gdyb_url + "2204"
  1269. }
  1270. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2204"
  1271. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2204"
  1272. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2204"
  1273. {
  1274. request, err := http.NewRequest("POST", url, reader)
  1275. if err != nil {
  1276. fmt.Println(err.Error())
  1277. return "", ""
  1278. }
  1279. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1280. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1281. request.Header.Set("x-tif-signature", signature)
  1282. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1283. request.Header.Set("x-tif-nonce", nonce)
  1284. client := http.Client{}
  1285. resp, err := client.Do(request)
  1286. if err != nil {
  1287. fmt.Println(err.Error())
  1288. return "", ""
  1289. }
  1290. respBytes, err := ioutil.ReadAll(resp.Body)
  1291. if err != nil {
  1292. fmt.Println(err.Error())
  1293. return "", ""
  1294. }
  1295. return string(respBytes), requestLog
  1296. }
  1297. //var result RequestResult
  1298. //json.Unmarshal(respBytes, &result)
  1299. //return &result
  1300. }
  1301. // 门诊费用明细信息撤销
  1302. 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) {
  1303. // 生成签名
  1304. nonce := GetRandomString(32)
  1305. timestamp := time.Now().Unix()
  1306. signature := setSignature(timestamp, nonce, secret_key)
  1307. inputMessage := make(map[string]interface{})
  1308. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  1309. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  1310. } else {
  1311. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1312. }
  1313. // 生成输入报文
  1314. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1315. input := make(map[string]interface{})
  1316. inputData := make(map[string]interface{})
  1317. inputMessage["infno"] = "2205" // 交易编码
  1318. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1319. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  1320. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1321. input["data"] = inputData
  1322. inputMessage["input"] = input //交易输入
  1323. bytesData, err := json.Marshal(inputMessage)
  1324. fmt.Println(string(bytesData))
  1325. var requestLog string
  1326. requestLog = string(bytesData)
  1327. if err != nil {
  1328. fmt.Println(err.Error())
  1329. return err.Error(), ""
  1330. }
  1331. reader := bytes.NewReader(bytesData)
  1332. gdyb_url := beego.AppConfig.String("gdyb_url")
  1333. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1334. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1335. //url := gdyb_url + "2205"
  1336. var url string
  1337. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  1338. url = gdyb_url
  1339. } else {
  1340. url = gdyb_url + "2205"
  1341. }
  1342. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2205"
  1343. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2205"
  1344. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2205"
  1345. {
  1346. request, err := http.NewRequest("POST", url, reader)
  1347. fmt.Println(err)
  1348. fmt.Println(request)
  1349. if err != nil {
  1350. fmt.Println(err.Error())
  1351. return err.Error(), ""
  1352. }
  1353. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1354. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1355. request.Header.Set("x-tif-signature", signature)
  1356. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1357. request.Header.Set("x-tif-nonce", nonce)
  1358. client := http.Client{}
  1359. resp, err := client.Do(request)
  1360. if err != nil {
  1361. fmt.Println(err.Error())
  1362. return err.Error(), ""
  1363. }
  1364. respBytes, err := ioutil.ReadAll(resp.Body)
  1365. if err != nil {
  1366. fmt.Println(err.Error())
  1367. return err.Error(), ""
  1368. }
  1369. str := string(respBytes)
  1370. fmt.Println(str)
  1371. return str, requestLog
  1372. }
  1373. }
  1374. // 门诊预结算
  1375. //
  1376. // func Gdyb2206(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string, total string, org_name string, doctor string, secret_key string) string {
  1377. 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) {
  1378. // 生成签名
  1379. nonce := GetRandomString(32)
  1380. timestamp := time.Now().Unix()
  1381. signature := setSignature(timestamp, nonce, secret_key)
  1382. inputMessage := make(map[string]interface{})
  1383. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  1384. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  1385. } else {
  1386. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1387. }
  1388. // 生成输入报文
  1389. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1390. input := make(map[string]interface{})
  1391. inputData := make(map[string]interface{})
  1392. inputMessage["infno"] = "2206" // 交易编码
  1393. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1394. if certificates == 3 {
  1395. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  1396. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1397. } else {
  1398. if id_card_type == 1 {
  1399. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  1400. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1401. } else if id_card_type == 4 {
  1402. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  1403. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1404. } else {
  1405. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  1406. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1407. }
  1408. }
  1409. {
  1410. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  1411. }
  1412. inputData["medfee_sumamt"] = total // 医疗费总额
  1413. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  1414. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1415. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  1416. inputData["acct_used_flag"] = "0" // 个人账户使用标志 0否 1是
  1417. inputData["insutype"] = insutype // 险种类型
  1418. inputData["invono"] = "" // 发票号
  1419. input["data"] = inputData
  1420. inputMessage["input"] = input //交易输入
  1421. var requestLog string
  1422. bytesData, err := json.Marshal(inputMessage)
  1423. requestLog = string(bytesData)
  1424. fmt.Println(string(bytesData))
  1425. if err != nil {
  1426. fmt.Println(err.Error())
  1427. return err.Error(), ""
  1428. }
  1429. reader := bytes.NewReader(bytesData)
  1430. gdyb_url := beego.AppConfig.String("gdyb_url")
  1431. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1432. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1433. //url := gdyb_url + "2206"
  1434. var url string
  1435. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  1436. url = gdyb_url
  1437. } else {
  1438. url = gdyb_url + "2206"
  1439. }
  1440. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2206"
  1441. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2206"
  1442. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2206"
  1443. {
  1444. request, err := http.NewRequest("POST", url, reader)
  1445. if err != nil {
  1446. fmt.Println(err.Error())
  1447. return err.Error(), ""
  1448. }
  1449. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1450. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1451. request.Header.Set("x-tif-signature", signature)
  1452. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1453. request.Header.Set("x-tif-nonce", nonce)
  1454. client := http.Client{}
  1455. resp, err := client.Do(request)
  1456. if err != nil {
  1457. fmt.Println(err.Error())
  1458. return err.Error(), ""
  1459. }
  1460. respBytes, err := ioutil.ReadAll(resp.Body)
  1461. if err != nil {
  1462. fmt.Println(err.Error())
  1463. return err.Error(), ""
  1464. }
  1465. str := string(respBytes)
  1466. fmt.Println(str)
  1467. return str, requestLog
  1468. }
  1469. }
  1470. // 门诊结算
  1471. 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) {
  1472. // 生成签名
  1473. nonce := GetRandomString(32)
  1474. timestamp := time.Now().Unix()
  1475. signature := setSignature(timestamp, nonce, secret_key)
  1476. // 生成输入报文
  1477. inputMessage := make(map[string]interface{})
  1478. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  1479. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  1480. } else {
  1481. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1482. }
  1483. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1484. input := make(map[string]interface{})
  1485. inputData := make(map[string]interface{})
  1486. inputMessage["infno"] = "2207" // 交易编码
  1487. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1488. if certificates == 3 {
  1489. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  1490. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1491. } else {
  1492. if id_card_type == 1 {
  1493. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  1494. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1495. } else if id_card_type == 4 {
  1496. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  1497. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  1498. } else {
  1499. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  1500. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1501. }
  1502. }
  1503. if med_type == "1111" || med_type == "1112" {
  1504. med_type = "11"
  1505. }
  1506. {
  1507. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  1508. }
  1509. inputData["medfee_sumamt"] = total // 医疗费总额
  1510. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  1511. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1512. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  1513. inputData["acct_used_flag"] = acct_used_flag // 个人账户使用标志 0否 1是
  1514. inputData["insutype"] = insutype // 险种类型
  1515. inputData["invono"] = "" // 发票号
  1516. inputData["fulamt_ownpay_amt"] = fulamt_ownpay_amt //
  1517. inputData["overlmt_selfpay"] = overlmt_selfpay //
  1518. inputData["preselfpay_amt"] = preselfpay_amt //
  1519. inputData["inscp_scp_amt"] = inscp_scp_amt //
  1520. input["data"] = inputData
  1521. inputMessage["input"] = input //交易输入
  1522. bytesData, err := json.Marshal(inputMessage)
  1523. fmt.Println(string(bytesData))
  1524. if err != nil {
  1525. fmt.Println(err.Error())
  1526. return err.Error(), ""
  1527. }
  1528. reader := bytes.NewReader(bytesData)
  1529. gdyb_url := beego.AppConfig.String("gdyb_url")
  1530. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1531. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1532. //url := gdyb_url + "2207"
  1533. var url string
  1534. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  1535. url = gdyb_url
  1536. } else {
  1537. url = gdyb_url + "2207"
  1538. }
  1539. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2207"
  1540. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  1541. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  1542. {
  1543. request, err := http.NewRequest("POST", url, reader)
  1544. if err != nil {
  1545. fmt.Println(err.Error())
  1546. return err.Error(), ""
  1547. }
  1548. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1549. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1550. request.Header.Set("x-tif-signature", signature)
  1551. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1552. request.Header.Set("x-tif-nonce", nonce)
  1553. client := http.Client{}
  1554. resp, err := client.Do(request)
  1555. if err != nil {
  1556. fmt.Println(err.Error())
  1557. return err.Error(), ""
  1558. }
  1559. respBytes, err := ioutil.ReadAll(resp.Body)
  1560. if err != nil {
  1561. fmt.Println(err.Error())
  1562. return err.Error(), ""
  1563. }
  1564. str := string(respBytes)
  1565. fmt.Println(str)
  1566. mjson, _ := json.Marshal(inputMessage)
  1567. str2 := string(mjson)
  1568. return str, str2
  1569. }
  1570. }
  1571. 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) {
  1572. // 生成签名
  1573. nonce := GetRandomString(32)
  1574. timestamp := time.Now().Unix()
  1575. signature := setSignature(timestamp, nonce, secret_key)
  1576. // 生成输入报文
  1577. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1578. input := make(map[string]interface{})
  1579. inputData := make(map[string]interface{})
  1580. inputMessage["infno"] = "2207A" // 交易编码
  1581. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1582. if certificates == 3 {
  1583. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  1584. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1585. } else {
  1586. if id_card_type == 1 {
  1587. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  1588. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1589. } else {
  1590. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  1591. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1592. }
  1593. }
  1594. if med_type == "1111" || med_type == "1112" {
  1595. med_type = "11"
  1596. }
  1597. {
  1598. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  1599. }
  1600. inputData["medfee_sumamt"] = total // 医疗费总额
  1601. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  1602. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1603. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  1604. inputData["acct_used_flag"] = acct_used_flag // 个人账户使用标志 0否 1是
  1605. inputData["insutype"] = insutype // 险种类型
  1606. inputData["invono"] = "" // 发票号
  1607. inputData["fulamt_ownpay_amt"] = fulamt_ownpay_amt //
  1608. inputData["overlmt_selfpay"] = overlmt_selfpay //
  1609. inputData["preselfpay_amt"] = preselfpay_amt //
  1610. inputData["inscp_scp_amt"] = inscp_scp_amt //
  1611. input["data"] = inputData
  1612. inputMessage["input"] = input //交易输入
  1613. bytesData, err := json.Marshal(inputMessage)
  1614. fmt.Println(string(bytesData))
  1615. if err != nil {
  1616. fmt.Println(err.Error())
  1617. return err.Error(), ""
  1618. }
  1619. reader := bytes.NewReader(bytesData)
  1620. gdyb_url := beego.AppConfig.String("gdyb_url")
  1621. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1622. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1623. //url := gdyb_url + "2207"
  1624. var url string
  1625. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  1626. url = gdyb_url
  1627. } else {
  1628. url = gdyb_url + "2207"
  1629. }
  1630. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2207"
  1631. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  1632. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  1633. {
  1634. request, err := http.NewRequest("POST", url, reader)
  1635. if err != nil {
  1636. fmt.Println(err.Error())
  1637. return err.Error(), ""
  1638. }
  1639. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1640. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1641. request.Header.Set("x-tif-signature", signature)
  1642. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1643. request.Header.Set("x-tif-nonce", nonce)
  1644. client := http.Client{}
  1645. resp, err := client.Do(request)
  1646. if err != nil {
  1647. fmt.Println(err.Error())
  1648. return err.Error(), ""
  1649. }
  1650. respBytes, err := ioutil.ReadAll(resp.Body)
  1651. if err != nil {
  1652. fmt.Println(err.Error())
  1653. return err.Error(), ""
  1654. }
  1655. str := string(respBytes)
  1656. fmt.Println(str)
  1657. mjson, _ := json.Marshal(inputMessage)
  1658. str2 := string(mjson)
  1659. return str, str2
  1660. }
  1661. }
  1662. // 门诊结算撤销
  1663. 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) {
  1664. // 生成签名
  1665. nonce := GetRandomString(32)
  1666. timestamp := time.Now().Unix()
  1667. signature := setSignature(timestamp, nonce, secret_key)
  1668. inputMessage := make(map[string]interface{})
  1669. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  1670. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  1671. } else {
  1672. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1673. }
  1674. // 生成输入报文
  1675. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1676. input := make(map[string]interface{})
  1677. inputData := make(map[string]interface{})
  1678. inputMessage["infno"] = "2208" // 交易编码
  1679. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1680. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1681. inputData["setl_id"] = setlId // 结算 ID
  1682. input["data"] = inputData
  1683. inputMessage["input"] = input //交易输入
  1684. bytesData, err := json.Marshal(inputMessage)
  1685. fmt.Println(string(bytesData))
  1686. if err != nil {
  1687. fmt.Println(err.Error())
  1688. return err.Error(), ""
  1689. }
  1690. reader := bytes.NewReader(bytesData)
  1691. gdyb_url := beego.AppConfig.String("gdyb_url")
  1692. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1693. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1694. //url := gdyb_url + "2208"
  1695. var url string
  1696. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  1697. url = gdyb_url
  1698. } else {
  1699. url = gdyb_url + "2208"
  1700. }
  1701. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2208"
  1702. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2208"
  1703. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2208"
  1704. {
  1705. request, err := http.NewRequest("POST", url, reader)
  1706. if err != nil {
  1707. fmt.Println(err.Error())
  1708. return err.Error(), ""
  1709. }
  1710. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1711. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1712. request.Header.Set("x-tif-signature", signature)
  1713. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1714. request.Header.Set("x-tif-nonce", nonce)
  1715. client := http.Client{}
  1716. resp, err := client.Do(request)
  1717. if err != nil {
  1718. fmt.Println(err.Error())
  1719. return err.Error(), ""
  1720. }
  1721. respBytes, err := ioutil.ReadAll(resp.Body)
  1722. if err != nil {
  1723. fmt.Println(err.Error())
  1724. return err.Error(), ""
  1725. }
  1726. str := string(respBytes)
  1727. fmt.Println(str)
  1728. mjson, _ := json.Marshal(inputMessage)
  1729. str2 := string(mjson)
  1730. return str, str2
  1731. }
  1732. }
  1733. // 确认订单
  1734. func Gdyb6201(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, order models.HisOrder) string {
  1735. // 生成签名
  1736. nonce := GetRandomString(32)
  1737. timestamp := time.Now().Unix()
  1738. signature := setSignature(timestamp, nonce, secret_key)
  1739. // 生成输入报文
  1740. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1741. input := make(map[string]interface{})
  1742. inputData := make(map[string]interface{})
  1743. inputMessage["infno"] = "6201" // 交易编码
  1744. inputData["mdtrt_id"] = order.MdtrtId
  1745. inputData["chrg_bchno"] = order.Number
  1746. inputData["psn_no"] = order.PsnNo
  1747. inputData["psn_name"] = order.PsnName
  1748. inputData["psn_cert_type"] = order.PsnCertType
  1749. inputData["certno"] = order.Certno
  1750. inputData["insutype"] = order.Insutype
  1751. inputData["med_type"] = order.MedType
  1752. inputData["medfee_sumamt"] = order.MedfeeSumamt
  1753. inputData["fulamt_ownpay_amt"] = order.FulamtOwnpayAmt
  1754. inputData["overlmt_selfpay"] = order.OverlmtSelfPay
  1755. inputData["preselfpay_amt"] = order.PreselfpayAmt
  1756. inputData["inscp_scp_amt"] = order.InscpScpAmt
  1757. inputData["act_pay_dedc"] = order.ActPayDedc
  1758. inputData["hifp_pay"] = order.HifpPay
  1759. inputData["pool_prop_selfpay"] = order.PoolPropSelfpay
  1760. inputData["cvlserv_pay"] = order.CvlservPay
  1761. inputData["hifes_pay"] = order.HifesPay
  1762. inputData["hifmi_pay"] = order.HifmiPay
  1763. inputData["hifob_pay"] = order.HifobPay
  1764. inputData["maf_pay"] = order.MafPay
  1765. inputData["oth_pay"] = order.OthPay
  1766. inputData["fund_pay_sumamt"] = order.FundPaySumamt
  1767. inputData["psn_part_amt"] = order.PsnPartAmt
  1768. inputData["acct_pay"] = order.AcctPay
  1769. inputData["psn_cash_pay"] = order.PsnCashPay
  1770. inputData["hosp_part_amt"] = order.HospPartAmt
  1771. inputData["acct_mulaid_pay"] = order.AcctMulaidPay
  1772. input["data"] = inputData
  1773. inputMessage["input"] = input //交易输入
  1774. bytesData, err := json.Marshal(inputMessage)
  1775. fmt.Println(string(bytesData))
  1776. if err != nil {
  1777. fmt.Println(err.Error())
  1778. return err.Error()
  1779. }
  1780. reader := bytes.NewReader(bytesData)
  1781. gdyb_url := beego.AppConfig.String("gdyb_url")
  1782. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1783. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1784. url := gdyb_url + "6201"
  1785. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/6201"
  1786. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/6201"
  1787. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  1788. request, err := http.NewRequest("POST", url, reader)
  1789. if err != nil {
  1790. fmt.Println(err.Error())
  1791. return err.Error()
  1792. }
  1793. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1794. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1795. request.Header.Set("x-tif-signature", signature)
  1796. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1797. request.Header.Set("x-tif-nonce", nonce)
  1798. client := http.Client{}
  1799. resp, err := client.Do(request)
  1800. if err != nil {
  1801. fmt.Println(err.Error())
  1802. return err.Error()
  1803. }
  1804. respBytes, err := ioutil.ReadAll(resp.Body)
  1805. if err != nil {
  1806. fmt.Println(err.Error())
  1807. return err.Error()
  1808. }
  1809. str := string(respBytes)
  1810. fmt.Println(str)
  1811. return str
  1812. }
  1813. // 医药机构费用结算对总账 func Gdyb3201( org_name string, doctor string, secret_key string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) string {
  1814. func Gdyb3201(baseParams models.BaseParams, businessParams models.BusinessParams, admin_user_id int64) string {
  1815. fmt.Println("11222333-----")
  1816. fmt.Println(baseParams)
  1817. fmt.Println(businessParams)
  1818. // 生成签名
  1819. nonce := GetRandomString(32)
  1820. timestamp := time.Now().Unix()
  1821. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1822. inputMessage := make(map[string]interface{})
  1823. if baseParams.MdtrtareaAdmvs == "450721" || baseParams.MdtrtareaAdmvs == "450127" {
  1824. inputMessage = SetInputMessage1111(nonce, timestamp, baseParams.OrgName, admin_user_id, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.Doctor)
  1825. } else {
  1826. inputMessage = SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1827. //inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1828. }
  1829. // 生成输入报文
  1830. input := make(map[string]interface{})
  1831. inputData := make(map[string]interface{})
  1832. inputMessage["infno"] = "3201" // 交易编码
  1833. inputData["insutype"] = businessParams.Insutype // 险种
  1834. if baseParams.MdtrtareaAdmvs == "450721" {
  1835. if businessParams.Insutype == "390" {
  1836. inputData["clr_type"] = "99971" // 就诊 ID(来自2201接口返回)
  1837. } else {
  1838. inputData["clr_type"] = "99970" // 就诊 ID(来自2201接口返回)
  1839. }
  1840. } else {
  1841. inputData["clr_type"] = businessParams.ClrType // 就诊 ID(来自2201接口返回)
  1842. }
  1843. inputData["setl_optins"] = businessParams.SetlOptins // 结算经办机构
  1844. inputData["stmt_begndate"] = businessParams.StmtBegndate // 对帐开始时间
  1845. inputData["stmt_enddate"] = businessParams.StmtEnddate //对帐结束时间
  1846. inputData["medfee_sumamt"] = businessParams.MedfeeSumamt //医疗费总额
  1847. inputData["fund_pay_sumamt"] = businessParams.FundPaySumamt //基金支付总额
  1848. inputData["acct_pay"] = businessParams.AcctPay //个人账户支付金额
  1849. inputData["fixmedins_setl_cnt"] = businessParams.FixmedinsSetlCnt //定点医药机构结算笔数
  1850. inputData["refd_setl_flag"] = 0 // 就诊 ID(来自2201接口返回)
  1851. input["data"] = inputData
  1852. inputMessage["input"] = input //交易输入
  1853. bytesData, err := json.Marshal(inputMessage)
  1854. fmt.Println(string(bytesData))
  1855. if err != nil {
  1856. fmt.Println(err.Error())
  1857. return err.Error()
  1858. }
  1859. reader := bytes.NewReader(bytesData)
  1860. gdyb_url := beego.AppConfig.String("gdyb_url")
  1861. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1862. var url string
  1863. if baseParams.MdtrtareaAdmvs == "150499" || baseParams.MdtrtareaAdmvs == "450721" {
  1864. url = gdyb_url
  1865. } else {
  1866. url = gdyb_url + "3201"
  1867. }
  1868. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1869. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3201"
  1870. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3201"
  1871. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3201"
  1872. request, err := http.NewRequest("POST", url, reader)
  1873. if err != nil {
  1874. fmt.Println(err.Error())
  1875. return err.Error()
  1876. }
  1877. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1878. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1879. request.Header.Set("x-tif-signature", signature)
  1880. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1881. request.Header.Set("x-tif-nonce", nonce)
  1882. client := http.Client{}
  1883. resp, err := client.Do(request)
  1884. if err != nil {
  1885. fmt.Println(err.Error())
  1886. return err.Error()
  1887. }
  1888. respBytes, err := ioutil.ReadAll(resp.Body)
  1889. if err != nil {
  1890. fmt.Println(err.Error())
  1891. return err.Error()
  1892. }
  1893. str := string(respBytes)
  1894. fmt.Println(str)
  1895. return str
  1896. }
  1897. type Params struct {
  1898. FileName string `json:"file_name"` //产品ID
  1899. In []byte `json:"in"` //
  1900. FixmedinsCode string `json:"fixmedins_code"` //调用环境生产为1 沙盒2
  1901. }
  1902. // 文件上传
  1903. func Gdyb9101(baseParams models.BaseParams, file_name string, file_byte []byte) string {
  1904. // 生成签名
  1905. nonce := GetRandomString(32)
  1906. timestamp := time.Now().Unix()
  1907. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1908. //buf := new(bytes.Buffer)
  1909. //buf.ReadFrom(strings.NewReader(string(file_byte)))
  1910. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1911. input := make(map[string]interface{})
  1912. inputData := make(map[string]interface{})
  1913. inputMessage["infno"] = "9101" // 交易编码
  1914. inputData["file_name"] = file_name //文件名
  1915. inputData["in"] = file_byte //文件数据
  1916. inputData["fixmedins_code"] = baseParams.FixmedinsCode //编码
  1917. input["fsUploadIn"] = inputData
  1918. inputMessage["input"] = input //交易输入
  1919. bytesData, err := json.Marshal(inputMessage)
  1920. fmt.Println(string(bytesData))
  1921. if err != nil {
  1922. fmt.Println(err.Error())
  1923. return err.Error()
  1924. }
  1925. reader := bytes.NewReader(bytesData)
  1926. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/9101"
  1927. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9101"
  1928. gdyb_url := beego.AppConfig.String("gdyb_url")
  1929. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1930. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1931. url := gdyb_url + "9101"
  1932. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9101"
  1933. request, err := http.NewRequest("POST", url, reader)
  1934. if err != nil {
  1935. fmt.Println(err.Error())
  1936. return err.Error()
  1937. }
  1938. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1939. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1940. request.Header.Set("x-tif-signature", signature)
  1941. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1942. request.Header.Set("x-tif-nonce", nonce)
  1943. client := http.Client{}
  1944. resp, err := client.Do(request)
  1945. if err != nil {
  1946. fmt.Println(err.Error())
  1947. return err.Error()
  1948. }
  1949. respBytes, err := ioutil.ReadAll(resp.Body)
  1950. if err != nil {
  1951. fmt.Println(err.Error())
  1952. return err.Error()
  1953. }
  1954. str := string(respBytes)
  1955. fmt.Println(str)
  1956. return str
  1957. }
  1958. func Gdyb9102(baseParams models.BaseParams, file_name string, file_qury_no string) string {
  1959. // 生成签名
  1960. nonce := GetRandomString(32)
  1961. timestamp := time.Now().Unix()
  1962. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1963. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1964. input := make(map[string]interface{})
  1965. inputData := make(map[string]interface{})
  1966. inputMessage["infno"] = "9102" // 交易编码
  1967. inputData["file_name"] = file_name //文件名
  1968. inputData["file_qury_no"] = file_qury_no //文件数据
  1969. inputData["fixmedins_code"] = baseParams.FixmedinsCode //编码
  1970. input["fsDownloadIn"] = inputData
  1971. inputMessage["input"] = input //交易输入
  1972. bytesData, err := json.Marshal(inputMessage)
  1973. fmt.Println(string(bytesData))
  1974. if err != nil {
  1975. fmt.Println(err.Error())
  1976. return err.Error()
  1977. }
  1978. reader := bytes.NewReader(bytesData)
  1979. gdyb_url := beego.AppConfig.String("gdyb_url")
  1980. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1981. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1982. url := gdyb_url + "9102"
  1983. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/9102"
  1984. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9102"
  1985. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9102"
  1986. request, err := http.NewRequest("POST", url, reader)
  1987. if err != nil {
  1988. fmt.Println(err.Error())
  1989. return err.Error()
  1990. }
  1991. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1992. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1993. request.Header.Set("x-tif-signature", signature)
  1994. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1995. request.Header.Set("x-tif-nonce", nonce)
  1996. client := http.Client{}
  1997. resp, err := client.Do(request)
  1998. if err != nil {
  1999. fmt.Println(err.Error())
  2000. return err.Error()
  2001. }
  2002. respBytes, err := ioutil.ReadAll(resp.Body)
  2003. if err != nil {
  2004. fmt.Println(err.Error())
  2005. return err.Error()
  2006. }
  2007. str := string(respBytes)
  2008. enc := mahonia.NewEncoder("gbk")
  2009. //output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  2010. fmt.Println(enc.ConvertString(str))
  2011. return str
  2012. }
  2013. func Gdyb3202(baseParams models.BaseParams, businessParams models.BusinessParams) string {
  2014. // 生成签名
  2015. nonce := GetRandomString(32)
  2016. timestamp := time.Now().Unix()
  2017. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  2018. // 生成输入报文
  2019. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  2020. input := make(map[string]interface{})
  2021. inputData := make(map[string]interface{})
  2022. inputMessage["infno"] = "3202" // 交易编码
  2023. inputData["file_qury_no"] = businessParams.FileQuryNo // 险种
  2024. inputData["setl_optins"] = baseParams.InsuplcAdmdvs // 结算经办机构
  2025. inputData["stmt_begndate"] = businessParams.StmtBegndate // 对帐开始时间
  2026. inputData["stmt_enddate"] = businessParams.StmtEnddate //对帐结束时间
  2027. inputData["medfee_sumamt"] = businessParams.MedfeeSumamt //医疗费总额
  2028. inputData["fund_pay_sumamt"] = businessParams.FundPaySumamt //基金支付总额
  2029. inputData["cash_payamt"] = businessParams.CashPayamt //现金支付金额
  2030. inputData["fixmedins_setl_cnt"] = businessParams.FixmedinsSetlCnt //定点医药机构结算笔数
  2031. inputData["clr_type"] = "11" // 就诊 ID(来自2201接口返回)
  2032. inputData["refd_setl_flag"] = 1 // 就诊 ID(来自2201接口返回)
  2033. input["data"] = inputData
  2034. inputMessage["input"] = input //交易输入
  2035. bytesData, err := json.Marshal(inputMessage)
  2036. fmt.Println(string(bytesData))
  2037. if err != nil {
  2038. fmt.Println(err.Error())
  2039. return err.Error()
  2040. }
  2041. reader := bytes.NewReader(bytesData)
  2042. gdyb_url := beego.AppConfig.String("gdyb_url")
  2043. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2044. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2045. url := gdyb_url + "3202"
  2046. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3202"
  2047. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3202"
  2048. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3202"
  2049. request, err := http.NewRequest("POST", url, reader)
  2050. if err != nil {
  2051. fmt.Println(err.Error())
  2052. return err.Error()
  2053. }
  2054. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2055. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2056. request.Header.Set("x-tif-signature", signature)
  2057. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2058. request.Header.Set("x-tif-nonce", nonce)
  2059. client := http.Client{}
  2060. resp, err := client.Do(request)
  2061. if err != nil {
  2062. fmt.Println(err.Error())
  2063. return err.Error()
  2064. }
  2065. respBytes, err := ioutil.ReadAll(resp.Body)
  2066. if err != nil {
  2067. fmt.Println(err.Error())
  2068. return err.Error()
  2069. }
  2070. str := string(respBytes)
  2071. fmt.Println(str)
  2072. return str
  2073. }
  2074. func Gdyb5203(baseParams models.BaseParams, businessParams models.BusinessParams) string {
  2075. fmt.Println("~~~~~~1")
  2076. fmt.Println(baseParams)
  2077. fmt.Println(businessParams)
  2078. // 生成签名
  2079. nonce := GetRandomString(32)
  2080. timestamp := time.Now().Unix()
  2081. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  2082. fmt.Println("~~~~~~2")
  2083. // 生成输入报文
  2084. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  2085. input := make(map[string]interface{})
  2086. inputData := make(map[string]interface{})
  2087. inputMessage["infno"] = "5203" // 交易编码
  2088. inputData["psn_no"] = businessParams.PsnNo
  2089. inputData["setl_id"] = businessParams.SetlId
  2090. inputData["mdtrt_id"] = businessParams.MdtrtId
  2091. input["data"] = inputData
  2092. inputMessage["input"] = input //交易输入
  2093. bytesData, err := json.Marshal(inputMessage)
  2094. fmt.Println(string(bytesData))
  2095. fmt.Println("~~~~~~")
  2096. fmt.Println("~~~~~~")
  2097. fmt.Println(string(bytesData))
  2098. if err != nil {
  2099. fmt.Println(err.Error())
  2100. return err.Error()
  2101. }
  2102. reader := bytes.NewReader(bytesData)
  2103. gdyb_url := beego.AppConfig.String("gdyb_url")
  2104. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2105. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2106. //url := gdyb_url + "5203"
  2107. var url string
  2108. if baseParams.FixmedinsCode == "H15049901371" || baseParams.MdtrtareaAdmvs == "450127" || baseParams.MdtrtareaAdmvs == "450721" {
  2109. url = gdyb_url
  2110. } else {
  2111. url = gdyb_url + "5203"
  2112. }
  2113. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5203"
  2114. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
  2115. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
  2116. request, err := http.NewRequest("POST", url, reader)
  2117. if err != nil {
  2118. fmt.Println(err.Error())
  2119. return err.Error()
  2120. }
  2121. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2122. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2123. request.Header.Set("x-tif-signature", signature)
  2124. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2125. request.Header.Set("x-tif-nonce", nonce)
  2126. client := http.Client{}
  2127. resp, err := client.Do(request)
  2128. if err != nil {
  2129. fmt.Println(err.Error())
  2130. return err.Error()
  2131. }
  2132. respBytes, err := ioutil.ReadAll(resp.Body)
  2133. if err != nil {
  2134. fmt.Println(err.Error())
  2135. return err.Error()
  2136. }
  2137. str := string(respBytes)
  2138. fmt.Println(str)
  2139. return str
  2140. }
  2141. func Gdyb5204(baseParams models.BaseParams, businessParams models.BusinessParams) string {
  2142. // 生成签名
  2143. nonce := GetRandomString(32)
  2144. timestamp := time.Now().Unix()
  2145. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  2146. // 生成输入报文
  2147. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  2148. input := make(map[string]interface{})
  2149. inputData := make(map[string]interface{})
  2150. inputMessage["infno"] = "5204" // 交易编码
  2151. inputData["psn_no"] = businessParams.PsnNo
  2152. inputData["setl_id"] = businessParams.SetlId
  2153. inputData["mdtrt_id"] = businessParams.MdtrtId
  2154. input["data"] = inputData
  2155. inputMessage["input"] = input //交易输入
  2156. bytesData, err := json.Marshal(inputMessage)
  2157. fmt.Println(string(bytesData))
  2158. if err != nil {
  2159. fmt.Println(err.Error())
  2160. return err.Error()
  2161. }
  2162. reader := bytes.NewReader(bytesData)
  2163. gdyb_url := beego.AppConfig.String("gdyb_url")
  2164. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2165. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2166. //url := gdyb_url + "5203"
  2167. var url string
  2168. if baseParams.FixmedinsCode == "H15049901371" || baseParams.MdtrtareaAdmvs == "450127" || baseParams.MdtrtareaAdmvs == "450721" {
  2169. url = gdyb_url
  2170. } else {
  2171. url = gdyb_url + "5204"
  2172. }
  2173. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5203"
  2174. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
  2175. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
  2176. request, err := http.NewRequest("POST", url, reader)
  2177. if err != nil {
  2178. fmt.Println(err.Error())
  2179. return err.Error()
  2180. }
  2181. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2182. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2183. request.Header.Set("x-tif-signature", signature)
  2184. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2185. request.Header.Set("x-tif-nonce", nonce)
  2186. client := http.Client{}
  2187. resp, err := client.Do(request)
  2188. if err != nil {
  2189. fmt.Println(err.Error())
  2190. return err.Error()
  2191. }
  2192. respBytes, err := ioutil.ReadAll(resp.Body)
  2193. if err != nil {
  2194. fmt.Println(err.Error())
  2195. return err.Error()
  2196. }
  2197. str := string(respBytes)
  2198. fmt.Println(str)
  2199. return str
  2200. }
  2201. func Gdyb2001(baseParams models.BaseParams, psn_no string, insutype string, med_type string) string {
  2202. if med_type == "1111" || med_type == "1112" {
  2203. med_type = "11"
  2204. }
  2205. // 生成签名
  2206. nonce := GetRandomString(32)
  2207. timestamp := time.Now().Unix()
  2208. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  2209. // 生成输入报文
  2210. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  2211. input := make(map[string]interface{})
  2212. inputData := make(map[string]interface{})
  2213. inputMessage["infno"] = "2001" // 交易编码
  2214. inputData["psn_no"] = psn_no
  2215. inputData["insutype"] = insutype
  2216. inputData["fixmedins_code"] = baseParams.FixmedinsCode
  2217. inputData["med_type"] = med_type
  2218. inputData["begntime"] = "2021-01-01 00:00:00"
  2219. input["data"] = inputData
  2220. inputMessage["input"] = input //交易输入
  2221. bytesData, err := json.Marshal(inputMessage)
  2222. fmt.Println(string(bytesData))
  2223. if err != nil {
  2224. fmt.Println(err.Error())
  2225. return err.Error()
  2226. }
  2227. reader := bytes.NewReader(bytesData)
  2228. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3301"
  2229. gdyb_url := beego.AppConfig.String("gdyb_url")
  2230. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2231. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2232. url := gdyb_url
  2233. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3301"
  2234. request, err := http.NewRequest("POST", url, reader)
  2235. if err != nil {
  2236. fmt.Println(err.Error())
  2237. return err.Error()
  2238. }
  2239. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2240. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2241. request.Header.Set("x-tif-signature", signature)
  2242. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2243. request.Header.Set("x-tif-nonce", nonce)
  2244. client := http.Client{}
  2245. resp, err := client.Do(request)
  2246. if err != nil {
  2247. fmt.Println(err.Error())
  2248. return err.Error()
  2249. }
  2250. respBytes, err := ioutil.ReadAll(resp.Body)
  2251. if err != nil {
  2252. fmt.Println(err.Error())
  2253. return err.Error()
  2254. }
  2255. str := string(respBytes)
  2256. fmt.Println(str)
  2257. return str
  2258. }
  2259. 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 {
  2260. // 生成签名
  2261. nonce := GetRandomString(32)
  2262. timestamp := time.Now().Unix()
  2263. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  2264. inputMessage := make(map[string]interface{})
  2265. if baseParams.MdtrtareaAdmvs == "450721" {
  2266. inputMessage = SetInputMessage1111(nonce, timestamp, baseParams.OrgName, admin_user_id, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.Doctor)
  2267. //inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs,doctor)
  2268. } else {
  2269. inputMessage = SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  2270. //inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2271. }
  2272. // 生成输入报文
  2273. input := make(map[string]interface{})
  2274. //input2 := make([]map[string]interface{})
  2275. feedetail := make([]map[string]interface{}, 0)
  2276. inputData := make(map[string]interface{})
  2277. inputMessage["infno"] = "3301A" // 交易编码
  2278. inputData["fixmedins_hilist_id"] = codg
  2279. inputData["fixmedins_hilist_name"] = name
  2280. inputData["list_type"] = list_type
  2281. inputData["med_list_codg"] = codg
  2282. inputData["begndate"] = start_time
  2283. inputData["enddate"] = ent_time
  2284. inputData["aprvno"] = ""
  2285. inputData["dosform"] = ""
  2286. inputData["exct_cont"] = ""
  2287. inputData["item_cont"] = ""
  2288. inputData["prcunt"] = ""
  2289. inputData["spec"] = ""
  2290. inputData["pacspec"] = ""
  2291. inputData["memo"] = ""
  2292. feedetail = append(feedetail, inputData)
  2293. input["data"] = feedetail
  2294. inputMessage["input"] = input //交易输入
  2295. bytesData, err := json.Marshal(inputMessage)
  2296. fmt.Println(string(bytesData))
  2297. if err != nil {
  2298. fmt.Println(err.Error())
  2299. return err.Error()
  2300. }
  2301. reader := bytes.NewReader(bytesData)
  2302. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3301"
  2303. //
  2304. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3301"
  2305. gdyb_url := beego.AppConfig.String("gdyb_url")
  2306. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2307. url := ""
  2308. if baseParams.MdtrtareaAdmvs == "450721" {
  2309. url = gdyb_url
  2310. } else {
  2311. url = gdyb_url + "3301"
  2312. }
  2313. request, err := http.NewRequest("POST", url, reader)
  2314. if err != nil {
  2315. fmt.Println(err.Error())
  2316. return err.Error()
  2317. }
  2318. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2319. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2320. request.Header.Set("x-tif-signature", signature)
  2321. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2322. request.Header.Set("x-tif-nonce", nonce)
  2323. client := http.Client{}
  2324. resp, err := client.Do(request)
  2325. if err != nil {
  2326. fmt.Println(err.Error())
  2327. return err.Error()
  2328. }
  2329. respBytes, err := ioutil.ReadAll(resp.Body)
  2330. if err != nil {
  2331. fmt.Println(err.Error())
  2332. return err.Error()
  2333. }
  2334. str := string(respBytes)
  2335. fmt.Println(str)
  2336. return str
  2337. }
  2338. func Gdyb3302(baseParams *models.BaseParams, name string, codg string, list_type_code string) string {
  2339. // 生成签名
  2340. nonce := GetRandomString(32)
  2341. timestamp := time.Now().Unix()
  2342. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  2343. // 生成输入报文
  2344. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  2345. input := make(map[string]interface{})
  2346. inputData := make(map[string]interface{})
  2347. inputMessage["infno"] = "3302" // 交易编码
  2348. inputData["fixmedins_code"] = baseParams.FixmedinsCode
  2349. inputData["fixmedins_hilist_id"] = codg
  2350. inputData["list_type"] = list_type_code
  2351. inputData["med_list_codg"] = codg
  2352. input["data"] = inputData
  2353. inputMessage["input"] = input //交易输入
  2354. bytesData, err := json.Marshal(inputMessage)
  2355. fmt.Println(string(bytesData))
  2356. if err != nil {
  2357. fmt.Println(err.Error())
  2358. return err.Error()
  2359. }
  2360. reader := bytes.NewReader(bytesData)
  2361. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3302"
  2362. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3302"
  2363. gdyb_url := beego.AppConfig.String("gdyb_url")
  2364. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2365. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2366. url := gdyb_url + "3302"
  2367. request, err := http.NewRequest("POST", url, reader)
  2368. if err != nil {
  2369. fmt.Println(err.Error())
  2370. return err.Error()
  2371. }
  2372. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2373. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2374. request.Header.Set("x-tif-signature", signature)
  2375. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2376. request.Header.Set("x-tif-nonce", nonce)
  2377. client := http.Client{}
  2378. resp, err := client.Do(request)
  2379. if err != nil {
  2380. fmt.Println(err.Error())
  2381. return err.Error()
  2382. }
  2383. respBytes, err := ioutil.ReadAll(resp.Body)
  2384. if err != nil {
  2385. fmt.Println(err.Error())
  2386. return err.Error()
  2387. }
  2388. str := string(respBytes)
  2389. fmt.Println(str)
  2390. return str
  2391. }
  2392. 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 {
  2393. // 生成签名
  2394. nonce := GetRandomString(32)
  2395. timestamp := time.Now().Unix()
  2396. signature := setSignature(timestamp, nonce, secret_key)
  2397. inputMessage := make(map[string]interface{})
  2398. //tempTime := time.Unix(timestamp, 0)
  2399. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2400. // 生成输入报文
  2401. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  2402. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  2403. } else {
  2404. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2405. }
  2406. // 生成输入报文
  2407. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2408. input := make(map[string]interface{})
  2409. inputData := make(map[string]interface{})
  2410. inputMessage["infno"] = "2505"
  2411. inputData["psn_no"] = psnNo
  2412. inputData["biz_appy_type"] = "01"
  2413. inputData["begndate"] = start_time
  2414. inputData["enddate"] = end_time
  2415. inputData["fixmedins_code"] = fixmedins_code
  2416. inputData["fixmedins_name"] = org_name
  2417. inputData["tel"] = ""
  2418. inputData["addr"] = ""
  2419. inputData["agnter_name"] = ""
  2420. inputData["agnter_cert_type"] = ""
  2421. inputData["agnter_certno"] = ""
  2422. inputData["agnter_tel"] = ""
  2423. inputData["agnter_addr"] = ""
  2424. inputData["agnter_rlts"] = ""
  2425. inputData["fix_srt_no"] = "1"
  2426. inputData["memo"] = ""
  2427. input["data"] = inputData
  2428. inputMessage["input"] = input //交易输入
  2429. bytesData, err := json.Marshal(inputMessage)
  2430. if err != nil {
  2431. fmt.Println(err.Error())
  2432. return err.Error()
  2433. }
  2434. reader := bytes.NewReader(bytesData)
  2435. //fmt.Println(String(bytesData))
  2436. fmt.Println(string(bytesData))
  2437. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2505"
  2438. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2505"
  2439. gdyb_url := beego.AppConfig.String("gdyb_url")
  2440. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2441. url := ""
  2442. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  2443. url = gdyb_url
  2444. } else {
  2445. url = gdyb_url + "2505"
  2446. }
  2447. request, err := http.NewRequest("POST", url, reader)
  2448. if err != nil {
  2449. fmt.Println(err.Error())
  2450. return err.Error()
  2451. }
  2452. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2453. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2454. request.Header.Set("x-tif-signature", signature)
  2455. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2456. request.Header.Set("x-tif-nonce", nonce)
  2457. client := http.Client{}
  2458. resp, err := client.Do(request)
  2459. if err != nil {
  2460. fmt.Println(err.Error())
  2461. return err.Error()
  2462. }
  2463. respBytes, err := ioutil.ReadAll(resp.Body)
  2464. if err != nil {
  2465. fmt.Println(err.Error())
  2466. return err.Error()
  2467. }
  2468. str := string(respBytes)
  2469. fmt.Println(str)
  2470. return str
  2471. }
  2472. 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 {
  2473. // 生成签名
  2474. nonce := GetRandomString(32)
  2475. timestamp := time.Now().Unix()
  2476. signature := setSignature(timestamp, nonce, secret_key)
  2477. // 生成输入报文
  2478. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2479. input := make(map[string]interface{})
  2480. inputData := make(map[string]interface{})
  2481. inputMessage["infno"] = "2506"
  2482. inputData["psn_no"] = psnNo
  2483. inputData["trt_dcla_detl_sn"] = trt_dcla_detl_sn
  2484. inputData["memo"] = ""
  2485. input["data"] = inputData
  2486. inputMessage["input"] = input //交易输入
  2487. bytesData, err := json.Marshal(inputMessage)
  2488. fmt.Println(string(bytesData))
  2489. if err != nil {
  2490. fmt.Println(err.Error())
  2491. return err.Error()
  2492. }
  2493. reader := bytes.NewReader(bytesData)
  2494. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2506"
  2495. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2506"
  2496. gdyb_url := beego.AppConfig.String("gdyb_url")
  2497. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2498. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2499. url := gdyb_url + "2506"
  2500. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  2501. request, err := http.NewRequest("POST", url, reader)
  2502. if err != nil {
  2503. fmt.Println(err.Error())
  2504. return err.Error()
  2505. }
  2506. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2507. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2508. request.Header.Set("x-tif-signature", signature)
  2509. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2510. request.Header.Set("x-tif-nonce", nonce)
  2511. client := http.Client{}
  2512. resp, err := client.Do(request)
  2513. if err != nil {
  2514. fmt.Println(err.Error())
  2515. return err.Error()
  2516. }
  2517. respBytes, err := ioutil.ReadAll(resp.Body)
  2518. if err != nil {
  2519. fmt.Println(err.Error())
  2520. return err.Error()
  2521. }
  2522. str := string(respBytes)
  2523. fmt.Println(str)
  2524. return str
  2525. }
  2526. 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 {
  2527. // 生成签名
  2528. nonce := GetRandomString(32)
  2529. timestamp := time.Now().Unix()
  2530. signature := setSignature(timestamp, nonce, secret_key)
  2531. //tempTime := time.Unix(timestamp, 0)
  2532. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2533. //timeFormatTwo := tempTime.Format("2006-01-02")
  2534. //t := time.Now()
  2535. //last := time.Date(t.Year(), time.December, 31, 0, 0, 0, 0, time.UTC)
  2536. //tm := time.Unix(last.Unix(), 0)
  2537. // 生成输入报文
  2538. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2539. input := make(map[string]interface{})
  2540. inputData := make(map[string]interface{})
  2541. inputMessage["infno"] = "2503" // 交易编码
  2542. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  2543. inputData["insutype"] = insutype // 险种类型(来自1101接口返回)
  2544. inputData["opsp_dise_code"] = sick_code // 险种类型(来自1101接口返回)
  2545. inputData["opsp_dise_name"] = sick_name // 险种类型(来自1101接口返回)
  2546. inputData["insu_optins"] = insuplc_admdvs // 险种类型(来自1101接口返回)
  2547. inputData["ide_fixmedins_no"] = hospital_code // 险种类型(来自1101接口返回)
  2548. inputData["ide_fixmedins_name"] = hospital_name // 险种类型(来自1101接口返回)
  2549. inputData["hosp_ide_date"] = check_time // 险种类型(来自1101接口返回)
  2550. inputData["diag_dr_codg"] = doctor_id // 开始时间
  2551. inputData["diag_dr_name"] = doctor // 开始时间
  2552. inputData["begndate"] = start_time // 医师编码
  2553. inputData["tel"] = "" // 医师编码
  2554. inputData["addr"] = "" // 医师编码
  2555. inputData["enddate"] = end_time // 医师编码
  2556. input["data"] = inputData
  2557. inputMessage["input"] = input //交易输入
  2558. bytesData, err := json.Marshal(inputMessage)
  2559. fmt.Println(string(bytesData))
  2560. if err != nil {
  2561. fmt.Println(err.Error())
  2562. return err.Error()
  2563. }
  2564. reader := bytes.NewReader(bytesData)
  2565. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2503"
  2566. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2503"
  2567. gdyb_url := beego.AppConfig.String("gdyb_url")
  2568. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2569. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2570. //url := gdyb_url + "2503"
  2571. var url string
  2572. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  2573. url = gdyb_url
  2574. } else {
  2575. url = gdyb_url + "2503"
  2576. }
  2577. request, err := http.NewRequest("POST", url, reader)
  2578. if err != nil {
  2579. fmt.Println(err.Error())
  2580. return err.Error()
  2581. }
  2582. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2583. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2584. request.Header.Set("x-tif-signature", signature)
  2585. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2586. request.Header.Set("x-tif-nonce", nonce)
  2587. client := http.Client{}
  2588. resp, err := client.Do(request)
  2589. if err != nil {
  2590. fmt.Println(err.Error())
  2591. return err.Error()
  2592. }
  2593. respBytes, err := ioutil.ReadAll(resp.Body)
  2594. if err != nil {
  2595. fmt.Println(err.Error())
  2596. return err.Error()
  2597. }
  2598. str := string(respBytes)
  2599. fmt.Println(str)
  2600. return str
  2601. }
  2602. 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 {
  2603. // 生成签名
  2604. nonce := GetRandomString(32)
  2605. timestamp := time.Now().Unix()
  2606. signature := setSignature(timestamp, nonce, secret_key)
  2607. // 生成输入报文
  2608. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2609. input := make(map[string]interface{})
  2610. inputData := make(map[string]interface{})
  2611. inputMessage["infno"] = "2504" // 交易编码
  2612. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  2613. inputData["trt_dcla_detl_sn"] = trt_dcla_detl_sn // 人员编号 (来自1101接口返回)
  2614. inputData["memo"] = "撤销备案" // 人员编号 (来自1101接口返回)
  2615. input["data"] = inputData
  2616. inputMessage["input"] = input //交易输入
  2617. bytesData, err := json.Marshal(inputMessage)
  2618. fmt.Println(string(bytesData))
  2619. if err != nil {
  2620. fmt.Println(err.Error())
  2621. return err.Error()
  2622. }
  2623. reader := bytes.NewReader(bytesData)
  2624. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2504"
  2625. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2504"
  2626. gdyb_url := beego.AppConfig.String("gdyb_url")
  2627. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2628. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2629. url := gdyb_url + "2504"
  2630. request, err := http.NewRequest("POST", url, reader)
  2631. if err != nil {
  2632. fmt.Println(err.Error())
  2633. return err.Error()
  2634. }
  2635. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2636. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2637. request.Header.Set("x-tif-signature", signature)
  2638. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2639. request.Header.Set("x-tif-nonce", nonce)
  2640. client := http.Client{}
  2641. resp, err := client.Do(request)
  2642. if err != nil {
  2643. fmt.Println(err.Error())
  2644. return err.Error()
  2645. }
  2646. respBytes, err := ioutil.ReadAll(resp.Body)
  2647. if err != nil {
  2648. fmt.Println(err.Error())
  2649. return err.Error()
  2650. }
  2651. str := string(respBytes)
  2652. fmt.Println(str)
  2653. return str
  2654. }
  2655. //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 {
  2656. // // 生成签名
  2657. // nonce := GetRandomString(32)
  2658. // timestamp := time.Now().Unix()
  2659. // signature := setSignature(timestamp, nonce, secret_key)
  2660. // tempTime := time.Unix(timestamp, 0)
  2661. // timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2662. //
  2663. // // 生成输入报文
  2664. // inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2665. // input := make(map[string]interface{})
  2666. // inputData := make(map[string]interface{})
  2667. // diseinfo := make([]map[string]interface{}, 0)
  2668. //
  2669. // inputMessage["infno"] = "2203" // 交易编码
  2670. // inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  2671. // inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  2672. // inputData["med_type"] = med_type // 医疗类别 16门诊特殊病
  2673. // inputData["begntime"] = timeFormatOne // 开始时间
  2674. // inputData["main_cond_dscr"] = "" // 主要病情描述
  2675. // inputData["dise_codg"] = sick_code // 病种编码
  2676. // inputData["dise_name"] = sick_name // 病种名称
  2677. // inputData["birctrl_type"] = "" // 计划生育手术类别
  2678. // inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
  2679. //
  2680. // diseinfo_sun := make(map[string]interface{})
  2681. // diseinfo_sun["diag_type"] = "1" // 诊断类别
  2682. // diseinfo_sun["diag_srt_no"] = "1" // 诊断排序号
  2683. // diseinfo_sun["diag_code"] = diag_code // 诊断代码
  2684. // diseinfo_sun["diag_name"] = diag // 诊断名称
  2685. // diseinfo_sun["diag_dept"] = department // 诊断科室
  2686. // diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
  2687. // diseinfo_sun["dise_dor_name"] = doctor // 诊断医生姓名
  2688. // diseinfo_sun["diag_time"] = timeFormatOne // 诊断时间
  2689. // diseinfo_sun["vali_flag"] = "1" // 有效标志
  2690. //
  2691. // diseinfo = append(diseinfo, diseinfo_sun)
  2692. // input["diseinfo"] = diseinfo
  2693. // input["mdtrtinfo"] = inputData
  2694. // inputMessage["input"] = input //交易输入
  2695. //
  2696. // bytesData, err := json.Marshal(inputMessage)
  2697. // fmt.Println(string(bytesData))
  2698. // if err != nil {
  2699. // fmt.Println(err.Error())
  2700. // return err.Error()
  2701. // }
  2702. // reader := bytes.NewReader(bytesData)
  2703. //
  2704. // url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2203"
  2705. //
  2706. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  2707. // request, err := http.NewRequest("POST", url, reader)
  2708. // if err != nil {
  2709. // fmt.Println(err.Error())
  2710. // return err.Error()
  2711. // }
  2712. //
  2713. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2714. // request.Header.Set("x-tif-paasid", "sg03_prd")
  2715. // request.Header.Set("x-tif-signature", signature)
  2716. // request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2717. // request.Header.Set("x-tif-nonce", nonce)
  2718. //
  2719. // client := http.Client{}
  2720. // resp, err := client.Do(request)
  2721. // if err != nil {
  2722. // fmt.Println(err.Error())
  2723. // return err.Error()
  2724. // }
  2725. // respBytes, err := ioutil.ReadAll(resp.Body)
  2726. // if err != nil {
  2727. // fmt.Println(err.Error())
  2728. // return err.Error()
  2729. // }
  2730. // str := string(respBytes)
  2731. // fmt.Println(str)
  2732. // return str
  2733. //}
  2734. 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 {
  2735. // 生成签名
  2736. nonce := GetRandomString(32)
  2737. timestamp := time.Now().Unix()
  2738. //timestamp := time.Now().UnixNano() / 1e6
  2739. signature := setSignature(timestamp, nonce, secret_key)
  2740. //tempTime := time.Unix(timestamp, 0)
  2741. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2742. //timeFormatTwo := tempTime.Format("2006-01-02")
  2743. inputMessage := make(map[string]interface{})
  2744. //tempTime := time.Unix(timestamp, 0)
  2745. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2746. // 生成输入报文
  2747. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  2748. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  2749. } else {
  2750. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2751. }
  2752. // 生成输入报文
  2753. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2754. input := make(map[string]interface{})
  2755. inputData := make(map[string]interface{})
  2756. inputMessage["infno"] = "5301" // 交易编码
  2757. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  2758. input["data"] = inputData
  2759. inputMessage["input"] = input //交易输入
  2760. bytesData, err := json.Marshal(inputMessage)
  2761. fmt.Println(string(bytesData))
  2762. if err != nil {
  2763. fmt.Println(err.Error())
  2764. return err.Error()
  2765. }
  2766. reader := bytes.NewReader(bytesData)
  2767. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  2768. gdyb_url := beego.AppConfig.String("gdyb_url")
  2769. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2770. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2771. var url string
  2772. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  2773. url = gdyb_url
  2774. } else {
  2775. url = gdyb_url + "5301"
  2776. }
  2777. request, err := http.NewRequest("POST", url, reader)
  2778. if err != nil {
  2779. fmt.Println(err.Error())
  2780. return err.Error()
  2781. }
  2782. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2783. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2784. request.Header.Set("x-tif-signature", signature)
  2785. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2786. request.Header.Set("x-tif-nonce", nonce)
  2787. client := http.Client{}
  2788. resp, err := client.Do(request)
  2789. if err != nil {
  2790. fmt.Println(err.Error())
  2791. return err.Error()
  2792. }
  2793. respBytes, err := ioutil.ReadAll(resp.Body)
  2794. if err != nil {
  2795. fmt.Println(err.Error())
  2796. return err.Error()
  2797. }
  2798. str := string(respBytes)
  2799. fmt.Println(str)
  2800. return str
  2801. }
  2802. func Gdyb5301Two(psnNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  2803. // 生成签名
  2804. nonce := GetRandomString(32)
  2805. timestamp := time.Now().Unix()
  2806. signature := setSignature(timestamp, nonce, secret_key)
  2807. //tempTime := time.Unix(timestamp, 0)
  2808. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2809. //timeFormatTwo := tempTime.Format("2006-01-02")
  2810. // 生成输入报文
  2811. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2812. input := make(map[string]interface{})
  2813. inputData := make(map[string]interface{})
  2814. inputMessage["infno"] = "5301" // 交易编码
  2815. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  2816. input["data"] = inputData
  2817. inputMessage["input"] = input //交易输入
  2818. bytesData, err := json.Marshal(inputMessage)
  2819. fmt.Println(string(bytesData))
  2820. if err != nil {
  2821. fmt.Println(err.Error())
  2822. return err.Error()
  2823. }
  2824. reader := bytes.NewReader(bytesData)
  2825. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  2826. gdyb_url := beego.AppConfig.String("gdyb_url")
  2827. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2828. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2829. url := gdyb_url
  2830. request, err := http.NewRequest("POST", url, reader)
  2831. if err != nil {
  2832. fmt.Println(err.Error())
  2833. return err.Error()
  2834. }
  2835. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2836. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2837. request.Header.Set("x-tif-signature", signature)
  2838. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2839. request.Header.Set("x-tif-nonce", nonce)
  2840. client := http.Client{}
  2841. resp, err := client.Do(request)
  2842. if err != nil {
  2843. fmt.Println(err.Error())
  2844. return err.Error()
  2845. }
  2846. respBytes, err := ioutil.ReadAll(resp.Body)
  2847. if err != nil {
  2848. fmt.Println(err.Error())
  2849. return err.Error()
  2850. }
  2851. str := string(respBytes)
  2852. fmt.Println(str)
  2853. return str
  2854. }
  2855. type CustomStruct struct {
  2856. FundPayType string
  2857. FundPayamt float64
  2858. }
  2859. type OpspdiseinfoStruct struct {
  2860. DiagName string
  2861. DiagCode string
  2862. OprnOprtName string
  2863. OprnOprtCode string
  2864. }
  2865. type DiaginfoStructTwo struct {
  2866. DiagType string
  2867. DiagCode string
  2868. DiagName string
  2869. MaindiagFlag string
  2870. }
  2871. type IteminfoStruct struct {
  2872. MedChrgitm string
  2873. Amt float64
  2874. ClaaSumfee float64
  2875. ClabAmt float64
  2876. FulamtOwnpayAmt float64
  2877. OthAmt float64
  2878. }
  2879. type Struct4101 struct {
  2880. PsnNo string
  2881. MdtrtId string
  2882. SetlId string
  2883. HiSetlLv string
  2884. PsnName string
  2885. Gend string
  2886. Brdy string
  2887. Ntly string
  2888. Naty string
  2889. PatnCertType string
  2890. Certno string
  2891. Prfs string
  2892. ConerName string
  2893. PatnRlts string
  2894. ConerAddr string
  2895. ConerTel string
  2896. HiType string
  2897. Insuplc string
  2898. AdmCaty string
  2899. DscgCaty string
  2900. MaindiagFlag string
  2901. BillCode string
  2902. BillNo string
  2903. BizSn string
  2904. SetlBegnDate string
  2905. SetlEndDate string
  2906. PsnSelfPay float64
  2907. PsnOwnPay float64
  2908. AcctPay float64
  2909. PsnCashpay float64
  2910. HiPaymtd string
  2911. Hsorg string
  2912. HsorgOpter string
  2913. MedinsFillDept string
  2914. MedinsFillPsn string
  2915. IptMedType string
  2916. Age int64
  2917. CustomStruct []CustomStruct
  2918. OpspdiseinfoStruct []OpspdiseinfoStruct
  2919. Diseinfo []DiaginfoStructTwo
  2920. IteminfoStruct []IteminfoStruct
  2921. AdmTime string
  2922. AdmEndTime string
  2923. HisNo string
  2924. DoctorName string
  2925. DoctorCode string
  2926. CurAddr string
  2927. }
  2928. 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) {
  2929. // 生成签名
  2930. nonce := GetRandomString(32)
  2931. timestamp := time.Now().Unix()
  2932. signature := setSignature(timestamp, nonce, secret_key)
  2933. inputMessage := make(map[string]interface{})
  2934. //tempTime := time.Unix(timestamp, 0)
  2935. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2936. // 生成输入报文
  2937. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  2938. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  2939. } else {
  2940. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2941. }
  2942. // 生成输入报文
  2943. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2944. input := make(map[string]interface{})
  2945. inputData := make(map[string]interface{})
  2946. if org_id == 10106 || org_id == 10215 || org_id == 10138 || org_id == 9504 {
  2947. inputMessage["infno"] = "4101A" // 交易编码
  2948. } else {
  2949. inputMessage["infno"] = "4101A" // 交易编码
  2950. }
  2951. year := time.Now().Format("2006")
  2952. month := time.Now().Format("01")
  2953. day := time.Now().Format("02")
  2954. inputData["mdtrt_id"] = struct4101.MdtrtId // 就诊 ID 必填(来自2201接口返回)
  2955. inputData["setl_id"] = struct4101.SetlId // 结算 ID 必填
  2956. inputData["psn_no"] = struct4101.PsnNo // 结算 ID 必填
  2957. inputData["fixmedins_name"] = org_name // 定点医药机构名称 必填
  2958. inputData["fixmedins_code"] = fixmedins_code // 定点医药机构编码 必填
  2959. inputData["hi_setl_lv"] = "" // 医保结算等级
  2960. inputData["hi_no"] = struct4101.PsnNo // 医保编号
  2961. inputData["medcasno"] = struct4101.PsnNo // 病案号 必填
  2962. inputData["dcla_time"] = year + "-" + month + "-" + day // 申报时间 必填
  2963. inputData["psn_name"] = struct4101.PsnName // 人员姓名 必填
  2964. inputData["gend"] = struct4101.Gend // 性别 必填
  2965. inputData["brdy"] = struct4101.Brdy // 出生日期 必填
  2966. inputData["age"] = struct4101.Age // 年龄 必填
  2967. inputData["ntly"] = "CHN" // 国籍 必填
  2968. inputData["nwb_age"] = "" // 年龄 必填
  2969. inputData["naty"] = struct4101.Naty // 民族 必填
  2970. inputData["dscg_way"] = "9" // 民族 必填
  2971. //inputData["resp_nurs_code"] = "N441623001432" // 民族 必填
  2972. inputData["patn_cert_type"] = struct4101.PatnCertType // 患者证件类别 必填
  2973. inputData["certno"] = struct4101.Certno // 证件号码 必填
  2974. inputData["prfs"] = struct4101.Prfs // 职业 必填
  2975. inputData["curr_addr"] = "" // 现住址 必填
  2976. inputData["emp_name"] = "" // 单位名称 必填
  2977. inputData["emp_addr"] = "" // 单位地址 必填
  2978. inputData["emp_tel"] = "" // 单位电话 必填
  2979. inputData["poscode"] = "" // 邮编 必填
  2980. inputData["coner_name"] = struct4101.ConerName // 联系人姓名 必填
  2981. inputData["patn_rlts"] = struct4101.PatnRlts // 与患者关系 必填
  2982. inputData["coner_addr"] = struct4101.ConerAddr // 联系人地址 必填
  2983. inputData["coner_tel"] = struct4101.ConerTel // 联系人电话 必填
  2984. inputData["hi_type"] = struct4101.HiType // 医保类型 必填
  2985. inputData["insuplc"] = struct4101.Insuplc // 参保地 必填
  2986. inputData["sp_psn_type"] = "" // 特殊人员类型 必填
  2987. inputData["nwb_adm_type"] = "" // 新生儿入院类型 必填
  2988. inputData["nwb_bir_wt"] = "" // 新生儿出生体重 必填
  2989. inputData["nwb_adm_wt"] = "" // 新生儿入院体重 必填
  2990. inputData["opsp_diag_caty"] = "" // 门诊慢特病诊断 必填
  2991. inputData["opsp_mdtrt_date"] = "" // 门诊慢特病就诊日期 必填
  2992. inputData["ipt_med_type"] = "" // 住院医疗类型 必填
  2993. inputData["adm_way"] = "2" // 入院途径 必填
  2994. inputData["trt_type"] = "1" // 治疗类别 必填
  2995. inputData["adm_time"] = struct4101.SetlEndDate // 入院时间 必填
  2996. inputData["adm_caty"] = "A03.06" // 入院科别 必填
  2997. inputData["refldept_dept"] = "" // 转科科别 必填
  2998. inputData["dscg_time"] = struct4101.SetlBegnDate // 出院时间 必填
  2999. inputData["dscg_caty"] = "A03.06" // 出院科别 必填
  3000. inputData["caty"] = "A03.06" // 出院科别 必填
  3001. inputData["act_ipt_days"] = "" // 实际住院天数 必填
  3002. inputData["otp_wm_dise"] = "" // 门(急) 诊西医诊断 必填
  3003. inputData["wm_dise_code"] = "" // 门(急) 诊中医诊断 必填
  3004. inputData["otp_tcm_dise"] = "" // 西医诊断疾病代码 必填
  3005. inputData["tcm_dise_code"] = "" // 中医诊断代码 必填
  3006. inputData["oprn_oprt_code_cnt"] = "" // 手术操作代码计数 必填
  3007. inputData["vent_used_dura"] = "" // 呼吸机使用时长 必填
  3008. inputData["pwcry_bfadm_coma_dura"] = "" // 颅脑损伤患者入院前昏迷时长 必填
  3009. inputData["pwcry_afadm_coma_dura"] = "" // 颅脑损伤患者入院后昏迷时长 必填
  3010. inputData["bld_cat"] = "" // 输血品种 必填
  3011. inputData["bld_amt"] = "" // 输血量 必填
  3012. inputData["bld_unt"] = "" // 输血计量单位 必填
  3013. inputData["spga_nurscare_days"] = "" // 特级护理天数 必填
  3014. inputData["lv1_nurscare_days"] = "" // 一级护理天数 必填
  3015. inputData["scd_nurscare_days"] = "" // 二级护理天数 必填
  3016. inputData["lv3_nurscare_days"] = "" // 三级护理天数 必填
  3017. inputData["acp_medins_name"] = "" // 拟接收机构名称 必填
  3018. inputData["acp_optins_code"] = "" // 拟接收机构代码 必填
  3019. inputData["bill_code"] = struct4101.BillCode // 票据代码 必填
  3020. inputData["bill_no"] = struct4101.BillNo // 票据号码 必填
  3021. inputData["biz_sn"] = struct4101.BizSn // 业务流水号 必填
  3022. inputData["days_rinp_flag_31"] = "1" // 出院 31 天内再住院计划标志 必填
  3023. inputData["days_rinp_pup_31"] = "1" // 出院 31 天内再住院目的 必填
  3024. inputData["chfpdr_name"] = struct4101.DoctorName // 主诊医师姓名 必填
  3025. inputData["chfpdr_code"] = struct4101.DoctorCode // 主诊医师代码 必填
  3026. inputData["setl_begn_date"] = struct4101.SetlBegnDate // 结算开始日期 必填
  3027. inputData["setl_end_date"] = struct4101.SetlEndDate // 结算结束日期 必填
  3028. inputData["psn_selfpay"] = struct4101.PsnSelfPay // 个人自付 必填
  3029. inputData["psn_ownpay"] = struct4101.PsnOwnPay // 个人自费 必填
  3030. inputData["acct_pay"] = struct4101.AcctPay // 个人账户支出 必填
  3031. inputData["hi_paymtd"] = struct4101.HiPaymtd // 医保支付方式 必填
  3032. inputData["hsorg"] = struct4101.Hsorg // 医保机构 必填
  3033. inputData["hsorg_opter"] = struct4101.HsorgOpter // 医保机构经办人 必填
  3034. inputData["medins_fill_dept"] = struct4101.MedinsFillDept // 医疗机构填报部门 必填
  3035. inputData["medins_fill_psn"] = struct4101.MedinsFillPsn // 医疗机构填报人 必填
  3036. inputData["psn_cashpay"] = struct4101.PsnCashpay // 医疗机构填报人 必填
  3037. inputData["resp_nurs_code"] = "N440307016120" // 民族 必填
  3038. payinfo := make([]map[string]interface{}, 0) // 基金支付信息
  3039. for _, item := range struct4101.CustomStruct {
  3040. payinfotemp := make(map[string]interface{})
  3041. 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" {
  3042. payinfotemp["fund_pay_type"] = item.FundPayType // 基金支付类型 必填
  3043. payinfotemp["fund_payamt"] = item.FundPayamt // 基金支付金额
  3044. payinfo = append(payinfo, payinfotemp)
  3045. }
  3046. }
  3047. opspdiseinfo := make([]map[string]interface{}, 0) // 门诊慢特病诊断信息
  3048. opspdiseinfotemp := make(map[string]interface{})
  3049. opspdiseinfotemp["diag_name"] = "慢性肾功能不全(血透治疗)" // 诊断名称 必填
  3050. opspdiseinfotemp["diag_code"] = "N18.904" // 诊断代码 必填
  3051. opspdiseinfotemp["oprn_oprt_name"] = "血液透析" // 手术操作名称 必填
  3052. opspdiseinfotemp["oprn_oprt_code"] = "39.9500" // 手术操作代码 必填
  3053. opspdiseinfo = append(opspdiseinfo, opspdiseinfotemp)
  3054. diseinfo := make([]map[string]interface{}, 0) // 住院诊断信息
  3055. for _, item := range struct4101.Diseinfo {
  3056. diseinfotemp := make(map[string]interface{})
  3057. diseinfotemp["maindiag_flag"] = item.MaindiagFlag // 手术操作代码 必填
  3058. diseinfotemp["diag_type"] = item.DiagType // 诊断类别 必填
  3059. diseinfotemp["diag_code"] = item.DiagCode // 诊断代码 必填
  3060. diseinfotemp["diag_name"] = item.DiagName // 诊断名称 必填
  3061. diseinfotemp["adm_cond_type"] = "3" // 入院病情类型 必填
  3062. diseinfo = append(diseinfo, diseinfotemp)
  3063. }
  3064. oprninfo := make([]map[string]interface{}, 0) // 手术操作信息
  3065. oprninfotemp := make(map[string]interface{})
  3066. oprninfotemp["oprn_oprt_type"] = "" // 手术操作类别 必填
  3067. oprninfotemp["oprn_oprt_name"] = "" // 手术操作名称 必填
  3068. oprninfotemp["oprn_oprt_code"] = "" // 手术操作代码 必填
  3069. oprninfotemp["oprn_oprt_date"] = "" // 手术操作日期 必填
  3070. oprninfotemp["anst_way"] = "" // 麻醉方式 必填
  3071. oprninfotemp["oper_dr_name"] = "" // 术者医师姓名 必填
  3072. oprninfotemp["oper_dr_code"] = "" // 术者医师代码 必填
  3073. oprninfotemp["anst_dr_name"] = "" // 麻醉医师姓名 必填
  3074. oprninfotemp["anst_dr_code"] = "" // 麻醉医师代码 必填
  3075. oprninfo = append(oprninfo, oprninfotemp)
  3076. icuinfo := make([]map[string]interface{}, 0) // 重症监护信息
  3077. icuinfotemp := make(map[string]interface{})
  3078. icuinfotemp["scs_cutd_ward_type"] = "" // 重症监护病房类型 必填
  3079. icuinfotemp["scs_cutd_inpool_time"] = "" // 重症监护进入时间 必填
  3080. icuinfotemp["scs_cutd_exit_time"] = "" // 重症监护退出时间 必填
  3081. icuinfotemp["scs_cutd_sum_dura"] = "" // 重症监护合计时长 必填
  3082. icuinfo = append(icuinfo, icuinfotemp)
  3083. input["setlinfo"] = inputData
  3084. input["payinfo"] = payinfo
  3085. //input["opspdiseinfo"] = opspdiseinfo
  3086. input["diseinfo"] = diseinfo
  3087. inputMessage["input"] = input //交易输入
  3088. bytesData, err := json.Marshal(inputMessage)
  3089. fmt.Println(string(bytesData))
  3090. if err != nil {
  3091. fmt.Println(err.Error())
  3092. return err.Error(), ""
  3093. }
  3094. reader := bytes.NewReader(bytesData)
  3095. gdyb_url := beego.AppConfig.String("gdyb_url")
  3096. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3097. //url := gdyb_url + "4101"
  3098. var url string
  3099. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  3100. url = gdyb_url
  3101. //inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs,doctor)
  3102. } else {
  3103. //inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3104. url = gdyb_url + "4101A"
  3105. }
  3106. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/4101"
  3107. request, err := http.NewRequest("POST", url, reader)
  3108. if err != nil {
  3109. fmt.Println(err.Error())
  3110. return err.Error(), ""
  3111. }
  3112. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3113. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3114. request.Header.Set("x-tif-signature", signature)
  3115. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3116. request.Header.Set("x-tif-nonce", nonce)
  3117. client := http.Client{}
  3118. resp, err := client.Do(request)
  3119. if err != nil {
  3120. fmt.Println(err.Error())
  3121. return err.Error(), ""
  3122. }
  3123. respBytes, err := ioutil.ReadAll(resp.Body)
  3124. if err != nil {
  3125. fmt.Println(err.Error())
  3126. return err.Error(), ""
  3127. }
  3128. str := string(respBytes)
  3129. fmt.Println(str)
  3130. return str, string(bytesData)
  3131. }
  3132. 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) {
  3133. // 生成签名
  3134. nonce := GetRandomString(32)
  3135. timestamp := time.Now().Unix()
  3136. signature := setSignature(timestamp, nonce, secret_key)
  3137. inputMessage := make(map[string]interface{})
  3138. //tempTime := time.Unix(timestamp, 0)
  3139. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  3140. // 生成输入报文
  3141. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  3142. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  3143. } else {
  3144. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3145. }
  3146. // 生成输入报文
  3147. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3148. input := make(map[string]interface{})
  3149. inputData := make(map[string]interface{})
  3150. if org_id == 10106 || org_id == 10215 || org_id == 10138 || org_id == 9504 {
  3151. inputMessage["infno"] = "4101A" // 交易编码
  3152. } else {
  3153. inputMessage["infno"] = "4101A" // 交易编码
  3154. }
  3155. year := time.Now().Format("2006")
  3156. month := time.Now().Format("01")
  3157. day := time.Now().Format("02")
  3158. inputData["mdtrt_id"] = struct4101.MdtrtId // 就诊 ID 必填(来自2201接口返回)
  3159. inputData["setl_id"] = struct4101.SetlId // 结算 ID 必填
  3160. inputData["psn_no"] = struct4101.PsnNo // 结算 ID 必填
  3161. inputData["fixmedins_name"] = org_name // 定点医药机构名称 必填
  3162. inputData["fixmedins_code"] = fixmedins_code // 定点医药机构编码 必填
  3163. inputData["hi_setl_lv"] = "" // 医保结算等级
  3164. inputData["hi_no"] = struct4101.PsnNo // 医保编号
  3165. inputData["medcasno"] = struct4101.PsnNo // 病案号 必填
  3166. inputData["dcla_time"] = year + "-" + month + "-" + day // 申报时间 必填
  3167. inputData["psn_name"] = struct4101.PsnName // 人员姓名 必填
  3168. inputData["gend"] = struct4101.Gend // 性别 必填
  3169. inputData["brdy"] = struct4101.Brdy // 出生日期 必填
  3170. inputData["age"] = struct4101.Age // 年龄 必填
  3171. inputData["ntly"] = struct4101.Ntly // 国籍 必填
  3172. inputData["nwb_age"] = "" // 年龄 必填
  3173. inputData["naty"] = struct4101.Naty // 民族 必填
  3174. //inputData["dscg_way"] = "9" // 民族 必填
  3175. //inputData["resp_nurs_code"] = "N441623001432" // 民族 必填
  3176. inputData["patn_cert_type"] = struct4101.PatnCertType // 患者证件类别 必填
  3177. inputData["certno"] = struct4101.Certno // 证件号码 必填
  3178. inputData["prfs"] = struct4101.Prfs // 职业 必填
  3179. inputData["curr_addr"] = "" // 现住址 必填
  3180. inputData["emp_name"] = "" // 单位名称 必填
  3181. inputData["emp_addr"] = "" // 单位地址 必填
  3182. inputData["emp_tel"] = "" // 单位电话 必填
  3183. inputData["poscode"] = "" // 邮编 必填
  3184. inputData["coner_name"] = struct4101.ConerName // 联系人姓名 必填
  3185. inputData["patn_rlts"] = struct4101.PatnRlts // 与患者关系 必填
  3186. inputData["coner_addr"] = struct4101.ConerAddr // 联系人地址 必填
  3187. inputData["coner_tel"] = struct4101.ConerTel // 联系人电话 必填
  3188. inputData["hi_type"] = struct4101.HiType // 医保类型 必填
  3189. inputData["insuplc"] = struct4101.Insuplc // 参保地 必填
  3190. inputData["sp_psn_type"] = "" // 特殊人员类型 必填
  3191. inputData["nwb_adm_type"] = "" // 新生儿入院类型 必填
  3192. inputData["nwb_bir_wt"] = "" // 新生儿出生体重 必填
  3193. inputData["nwb_adm_wt"] = "" // 新生儿入院体重 必填
  3194. inputData["opsp_diag_caty"] = "" // 门诊慢特病诊断 必填
  3195. inputData["opsp_mdtrt_date"] = "" // 门诊慢特病就诊日期 必填
  3196. inputData["ipt_med_type"] = "" // 住院医疗类型 必填
  3197. inputData["adm_way"] = "" // 入院途径 必填
  3198. inputData["trt_type"] = "10" // 治疗类别 必填
  3199. inputData["adm_time"] = "" // 入院时间 必填
  3200. inputData["adm_caty"] = "A03.06" // 入院科别 必填
  3201. inputData["refldept_dept"] = "" // 转科科别 必填
  3202. inputData["dscg_time"] = "" // 出院时间 必填
  3203. inputData["dscg_caty"] = "A03.06" // 出院科别 必填
  3204. inputData["caty"] = "A03.06" // 出院科别 必填
  3205. inputData["act_ipt_days"] = "" // 实际住院天数 必填
  3206. inputData["otp_wm_dise"] = "" // 门(急) 诊西医诊断 必填
  3207. inputData["wm_dise_code"] = "" // 门(急) 诊中医诊断 必填
  3208. inputData["otp_tcm_dise"] = "" // 西医诊断疾病代码 必填
  3209. inputData["tcm_dise_code"] = "" // 中医诊断代码 必填
  3210. inputData["oprn_oprt_code_cnt"] = "" // 手术操作代码计数 必填
  3211. inputData["vent_used_dura"] = "" // 呼吸机使用时长 必填
  3212. inputData["pwcry_bfadm_coma_dura"] = "" // 颅脑损伤患者入院前昏迷时长 必填
  3213. inputData["pwcry_afadm_coma_dura"] = "" // 颅脑损伤患者入院后昏迷时长 必填
  3214. inputData["bld_cat"] = "" // 输血品种 必填
  3215. inputData["bld_amt"] = "" // 输血量 必填
  3216. inputData["bld_unt"] = "" // 输血计量单位 必填
  3217. inputData["spga_nurscare_days"] = "" // 特级护理天数 必填
  3218. inputData["lv1_nurscare_days"] = "" // 一级护理天数 必填
  3219. inputData["scd_nurscare_days"] = "" // 二级护理天数 必填
  3220. inputData["lv3_nurscare_days"] = "" // 三级护理天数 必填
  3221. inputData["acp_medins_name"] = "" // 拟接收机构名称 必填
  3222. inputData["acp_optins_code"] = "" // 拟接收机构代码 必填
  3223. inputData["bill_code"] = struct4101.BillCode // 票据代码 必填
  3224. inputData["bill_no"] = struct4101.BillNo // 票据号码 必填
  3225. inputData["biz_sn"] = struct4101.BizSn // 业务流水号 必填
  3226. inputData["days_rinp_flag_31"] = "" // 出院 31 天内再住院计划标志 必填
  3227. inputData["days_rinp_pup_31"] = "" // 出院 31 天内再住院目的 必填
  3228. inputData["chfpdr_name"] = struct4101.DoctorName // 主诊医师姓名 必填
  3229. inputData["chfpdr_code"] = struct4101.DoctorCode // 主诊医师代码 必填
  3230. inputData["setl_begn_date"] = struct4101.SetlBegnDate // 结算开始日期 必填
  3231. inputData["setl_end_date"] = struct4101.SetlEndDate // 结算结束日期 必填
  3232. inputData["psn_selfpay"] = struct4101.PsnSelfPay // 个人自付 必填
  3233. inputData["psn_ownpay"] = struct4101.PsnOwnPay // 个人自费 必填
  3234. inputData["acct_pay"] = struct4101.AcctPay // 个人账户支出 必填
  3235. inputData["hi_paymtd"] = struct4101.HiPaymtd // 医保支付方式 必填
  3236. inputData["hsorg"] = struct4101.Hsorg // 医保机构 必填
  3237. inputData["hsorg_opter"] = struct4101.HsorgOpter // 医保机构经办人 必填
  3238. inputData["medins_fill_dept"] = struct4101.MedinsFillDept // 医疗机构填报部门 必填
  3239. inputData["medins_fill_psn"] = struct4101.MedinsFillPsn // 医疗机构填报人 必填
  3240. inputData["psn_cashpay"] = struct4101.PsnCashpay // 医疗机构填报人 必填
  3241. inputData["dscg_way"] = "1" // 医疗机构填报人 必填
  3242. payinfo := make([]map[string]interface{}, 0) // 基金支付信息
  3243. for _, item := range struct4101.CustomStruct {
  3244. payinfotemp := make(map[string]interface{})
  3245. 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" {
  3246. payinfotemp["fund_pay_type"] = item.FundPayType // 基金支付类型 必填
  3247. payinfotemp["fund_payamt"] = item.FundPayamt // 基金支付金额
  3248. payinfo = append(payinfo, payinfotemp)
  3249. }
  3250. }
  3251. opspdiseinfo := make([]map[string]interface{}, 0) // 门诊慢特病诊断信息
  3252. opspdiseinfotemp := make(map[string]interface{})
  3253. opspdiseinfotemp["diag_name"] = "慢性肾功能不全(血透治疗)" // 诊断名称 必填
  3254. opspdiseinfotemp["diag_code"] = "N18.904" // 诊断代码 必填
  3255. opspdiseinfotemp["oprn_oprt_name"] = "血液透析" // 手术操作名称 必填
  3256. opspdiseinfotemp["oprn_oprt_code"] = "39.9500" // 手术操作代码 必填
  3257. opspdiseinfo = append(opspdiseinfo, opspdiseinfotemp)
  3258. diseinfo := make([]map[string]interface{}, 0) // 住院诊断信息
  3259. for _, item := range struct4101.Diseinfo {
  3260. diseinfotemp := make(map[string]interface{})
  3261. diseinfotemp["maindiag_flag"] = item.MaindiagFlag // 手术操作代码 必填
  3262. diseinfotemp["diag_type"] = item.DiagType // 诊断类别 必填
  3263. diseinfotemp["diag_code"] = item.DiagCode // 诊断代码 必填
  3264. diseinfotemp["diag_name"] = item.DiagName // 诊断名称 必填
  3265. diseinfotemp["adm_cond_type"] = "3" // 入院病情类型 必填
  3266. diseinfo = append(diseinfo, diseinfotemp)
  3267. }
  3268. oprninfo := make([]map[string]interface{}, 0) // 手术操作信息
  3269. oprninfotemp := make(map[string]interface{})
  3270. oprninfotemp["oprn_oprt_type"] = "" // 手术操作类别 必填
  3271. oprninfotemp["oprn_oprt_name"] = "" // 手术操作名称 必填
  3272. oprninfotemp["oprn_oprt_code"] = "" // 手术操作代码 必填
  3273. oprninfotemp["oprn_oprt_date"] = "" // 手术操作日期 必填
  3274. oprninfotemp["anst_way"] = "" // 麻醉方式 必填
  3275. oprninfotemp["oper_dr_name"] = "" // 术者医师姓名 必填
  3276. oprninfotemp["oper_dr_code"] = "" // 术者医师代码 必填
  3277. oprninfotemp["anst_dr_name"] = "" // 麻醉医师姓名 必填
  3278. oprninfotemp["anst_dr_code"] = "" // 麻醉医师代码 必填
  3279. oprninfo = append(oprninfo, oprninfotemp)
  3280. icuinfo := make([]map[string]interface{}, 0) // 重症监护信息
  3281. icuinfotemp := make(map[string]interface{})
  3282. icuinfotemp["scs_cutd_ward_type"] = "" // 重症监护病房类型 必填
  3283. icuinfotemp["scs_cutd_inpool_time"] = "" // 重症监护进入时间 必填
  3284. icuinfotemp["scs_cutd_exit_time"] = "" // 重症监护退出时间 必填
  3285. icuinfotemp["scs_cutd_sum_dura"] = "" // 重症监护合计时长 必填
  3286. icuinfo = append(icuinfo, icuinfotemp)
  3287. input["setlinfo"] = inputData
  3288. input["payinfo"] = payinfo
  3289. input["opspdiseinfo"] = opspdiseinfo
  3290. input["diseinfo"] = diseinfo
  3291. inputMessage["input"] = input //交易输入
  3292. bytesData, err := json.Marshal(inputMessage)
  3293. fmt.Println(string(bytesData))
  3294. if err != nil {
  3295. fmt.Println(err.Error())
  3296. return err.Error(), ""
  3297. }
  3298. reader := bytes.NewReader(bytesData)
  3299. gdyb_url := beego.AppConfig.String("gdyb_url")
  3300. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3301. //url := gdyb_url + "4101"
  3302. var url string
  3303. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  3304. url = gdyb_url
  3305. //inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs,doctor)
  3306. } else {
  3307. //inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3308. url = gdyb_url
  3309. }
  3310. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/4101"
  3311. request, err := http.NewRequest("POST", url, reader)
  3312. if err != nil {
  3313. fmt.Println(err.Error())
  3314. return err.Error(), ""
  3315. }
  3316. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3317. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3318. request.Header.Set("x-tif-signature", signature)
  3319. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3320. request.Header.Set("x-tif-nonce", nonce)
  3321. client := http.Client{}
  3322. resp, err := client.Do(request)
  3323. if err != nil {
  3324. fmt.Println(err.Error())
  3325. return err.Error(), ""
  3326. }
  3327. respBytes, err := ioutil.ReadAll(resp.Body)
  3328. if err != nil {
  3329. fmt.Println(err.Error())
  3330. return err.Error(), ""
  3331. }
  3332. str := string(respBytes)
  3333. fmt.Println(str)
  3334. return str, string(bytesData)
  3335. }
  3336. 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) {
  3337. // 生成签名
  3338. nonce := GetRandomString(32)
  3339. timestamp := time.Now().Unix()
  3340. signature := setSignature(timestamp, nonce, secret_key)
  3341. // 生成输入报文
  3342. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3343. input := make(map[string]interface{})
  3344. inputData := make(map[string]interface{})
  3345. inputMessage["infno"] = "4101A" // 交易编码
  3346. year := time.Now().Format("2006")
  3347. month := time.Now().Format("01")
  3348. day := time.Now().Format("02")
  3349. inputData["mdtrt_id"] = struct4101.MdtrtId // 就诊 ID 必填(来自2201接口返回)
  3350. inputData["setl_id"] = struct4101.SetlId // 结算 ID 必填
  3351. inputData["psn_no"] = struct4101.PsnNo // 结算 ID 必填
  3352. inputData["fixmedins_name"] = org_name // 定点医药机构名称 必填
  3353. inputData["fixmedins_code"] = fixmedins_code // 定点医药机构编码 必填
  3354. inputData["hi_setl_lv"] = "" // 医保结算等级
  3355. inputData["hi_no"] = struct4101.PsnNo // 医保编号
  3356. inputData["medcasno"] = struct4101.PsnNo // 病案号 必填
  3357. inputData["dcla_time"] = year + "-" + month + "-" + day // 申报时间 必填
  3358. inputData["psn_name"] = struct4101.PsnName // 人员姓名 必填
  3359. inputData["gend"] = struct4101.Gend // 性别 必填
  3360. inputData["brdy"] = struct4101.Brdy // 出生日期 必填
  3361. inputData["age"] = struct4101.Age // 年龄 必填
  3362. inputData["ntly"] = struct4101.Ntly // 国籍 必填
  3363. inputData["nwb_age"] = "" // 年龄 必填
  3364. inputData["naty"] = struct4101.Naty // 民族 必填
  3365. inputData["patn_cert_type"] = struct4101.PatnCertType // 患者证件类别 必填
  3366. inputData["certno"] = struct4101.Certno // 证件号码 必填
  3367. inputData["prfs"] = struct4101.Prfs // 职业 必填
  3368. inputData["curr_addr"] = "" // 现住址 必填
  3369. inputData["emp_name"] = "" // 单位名称 必填
  3370. inputData["emp_addr"] = "" // 单位地址 必填
  3371. inputData["emp_tel"] = "" // 单位电话 必填
  3372. inputData["poscode"] = "" // 邮编 必填
  3373. inputData["coner_name"] = struct4101.ConerName // 联系人姓名 必填
  3374. inputData["patn_rlts"] = struct4101.PatnRlts // 与患者关系 必填
  3375. inputData["coner_addr"] = struct4101.ConerAddr // 联系人地址 必填
  3376. inputData["coner_tel"] = struct4101.ConerTel // 联系人电话 必填
  3377. inputData["hi_type"] = struct4101.HiType // 医保类型 必填
  3378. inputData["insuplc"] = struct4101.Insuplc // 参保地 必填
  3379. inputData["sp_psn_type"] = "" // 特殊人员类型 必填
  3380. inputData["nwb_adm_type"] = "" // 新生儿入院类型 必填
  3381. inputData["nwb_bir_wt"] = "" // 新生儿出生体重 必填
  3382. inputData["nwb_adm_wt"] = "" // 新生儿入院体重 必填
  3383. inputData["opsp_diag_caty"] = "" // 门诊慢特病诊断 必填
  3384. inputData["opsp_mdtrt_date"] = "" // 门诊慢特病就诊日期 必填
  3385. inputData["ipt_med_type"] = "" // 住院医疗类型 必填
  3386. inputData["adm_way"] = "" // 入院途径 必填
  3387. inputData["trt_type"] = "10" // 治疗类别 必填
  3388. inputData["adm_time"] = struct4101.AdmTime // 入院时间 必填
  3389. inputData["adm_caty"] = struct4101.AdmCaty // 入院科别 必填
  3390. inputData["refldept_dept"] = "" // 转科科别 必填
  3391. inputData["dscg_time"] = struct4101.AdmEndTime // 出院时间 必填
  3392. inputData["dscg_caty"] = struct4101.DscgCaty // 出院科别 必填
  3393. inputData["act_ipt_days"] = "" // 实际住院天数 必填
  3394. inputData["otp_wm_dise"] = "" // 门(急) 诊西医诊断 必填
  3395. inputData["wm_dise_code"] = "" // 门(急) 诊中医诊断 必填
  3396. inputData["otp_tcm_dise"] = "" // 西医诊断疾病代码 必填
  3397. inputData["tcm_dise_code"] = "" // 中医诊断代码 必填
  3398. inputData["oprn_oprt_code_cnt"] = "" // 手术操作代码计数 必填
  3399. inputData["vent_used_dura"] = "" // 呼吸机使用时长 必填
  3400. inputData["pwcry_bfadm_coma_dura"] = "" // 颅脑损伤患者入院前昏迷时长 必填
  3401. inputData["pwcry_afadm_coma_dura"] = "" // 颅脑损伤患者入院后昏迷时长 必填
  3402. inputData["bld_cat"] = "" // 输血品种 必填
  3403. inputData["bld_amt"] = "" // 输血量 必填
  3404. inputData["bld_unt"] = "" // 输血计量单位 必填
  3405. inputData["spga_nurscare_days"] = "" // 特级护理天数 必填
  3406. inputData["lv1_nurscare_days"] = "" // 一级护理天数 必填
  3407. inputData["scd_nurscare_days"] = "" // 二级护理天数 必填
  3408. inputData["lv3_nurscare_days"] = "" // 三级护理天数 必填
  3409. inputData["acp_medins_name"] = "" // 拟接收机构名称 必填
  3410. inputData["acp_optins_code"] = "" // 拟接收机构代码 必填
  3411. inputData["bill_code"] = struct4101.BillCode // 票据代码 必填
  3412. inputData["bill_no"] = struct4101.BillNo // 票据号码 必填
  3413. inputData["biz_sn"] = struct4101.BizSn // 业务流水号 必填
  3414. inputData["days_rinp_flag_31"] = "" // 出院 31 天内再住院计划标志 必填
  3415. inputData["days_rinp_pup_31"] = "" // 出院 31 天内再住院目的 必填
  3416. inputData["chfpdr_name"] = struct4101.DoctorName // 主诊医师姓名 必填
  3417. inputData["chfpdr_code"] = struct4101.DoctorCode // 主诊医师代码 必填
  3418. inputData["setl_begn_date"] = struct4101.SetlBegnDate // 结算开始日期 必填
  3419. inputData["setl_end_date"] = struct4101.SetlEndDate // 结算结束日期 必填
  3420. inputData["psn_selfpay"] = struct4101.PsnSelfPay // 个人自付 必填
  3421. inputData["psn_ownpay"] = struct4101.PsnOwnPay // 个人自费 必填
  3422. inputData["acct_pay"] = struct4101.AcctPay // 个人账户支出 必填
  3423. inputData["hi_paymtd"] = struct4101.HiPaymtd // 医保支付方式 必填
  3424. inputData["hsorg"] = struct4101.Hsorg // 医保机构 必填
  3425. inputData["hsorg_opter"] = struct4101.HsorgOpter // 医保机构经办人 必填
  3426. inputData["medins_fill_dept"] = struct4101.MedinsFillDept // 医疗机构填报部门 必填
  3427. inputData["medins_fill_psn"] = struct4101.MedinsFillPsn // 医疗机构填报人 必填
  3428. inputData["psn_cashpay"] = struct4101.PsnCashpay // 医疗机构填报人 必填
  3429. payinfo := make([]map[string]interface{}, 0) // 基金支付信息
  3430. for _, item := range struct4101.CustomStruct {
  3431. payinfotemp := make(map[string]interface{})
  3432. 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" {
  3433. payinfotemp["fund_pay_type"] = item.FundPayType // 基金支付类型 必填
  3434. payinfotemp["fund_payamt"] = item.FundPayamt // 基金支付金额
  3435. payinfo = append(payinfo, payinfotemp)
  3436. }
  3437. }
  3438. opspdiseinfo := make([]map[string]interface{}, 0) // 门诊慢特病诊断信息
  3439. opspdiseinfotemp := make(map[string]interface{})
  3440. opspdiseinfotemp["diag_name"] = struct4101.Diseinfo[len(struct4101.Diseinfo)-1].DiagName // 诊断名称 必填
  3441. opspdiseinfotemp["diag_code"] = struct4101.Diseinfo[len(struct4101.Diseinfo)-1].DiagCode // 诊断代码 必填
  3442. opspdiseinfotemp["oprn_oprt_name"] = "血液透析" // 手术操作名称 必填
  3443. opspdiseinfotemp["oprn_oprt_code"] = "39.9500" // 手术操作代码 必填
  3444. opspdiseinfo = append(opspdiseinfo, opspdiseinfotemp)
  3445. diseinfo := make([]map[string]interface{}, 0) // 住院诊断信息
  3446. for _, item := range struct4101.Diseinfo {
  3447. diseinfotemp := make(map[string]interface{})
  3448. diseinfotemp["maindiag_flag"] = item.MaindiagFlag // 手术操作代码 必填
  3449. diseinfotemp["diag_type"] = item.DiagType // 诊断类别 必填
  3450. diseinfotemp["diag_code"] = item.DiagCode // 诊断代码 必填
  3451. diseinfotemp["diag_name"] = item.DiagName // 诊断名称 必填
  3452. diseinfotemp["adm_cond_type"] = "3" // 入院病情类型 必填
  3453. diseinfo = append(diseinfo, diseinfotemp)
  3454. }
  3455. iteminfo := make([]map[string]interface{}, 0)
  3456. for _, item := range struct4101.IteminfoStruct {
  3457. iteminfotemp := make(map[string]interface{})
  3458. iteminfotemp["med_chrgitm"] = item.MedChrgitm // 医疗收费项目 必填
  3459. iteminfotemp["amt"] = item.Amt // 金额 必填
  3460. iteminfotemp["claa_sumfee"] = item.ClaaSumfee // 甲类费用合计 必填
  3461. iteminfotemp["clab_amt"] = item.ClabAmt // 乙类金额 必填
  3462. iteminfotemp["fulamt_ownpay_amt"] = item.FulamtOwnpayAmt // 全自费金额 必填
  3463. iteminfotemp["oth_amt"] = item.OthAmt // 其他金额 必填
  3464. iteminfo = append(iteminfo, iteminfotemp)
  3465. }
  3466. oprninfo := make([]map[string]interface{}, 0) // 手术操作信息
  3467. oprninfotemp := make(map[string]interface{})
  3468. oprninfotemp["oprn_oprt_type"] = "" // 手术操作类别 必填
  3469. oprninfotemp["oprn_oprt_name"] = "" // 手术操作名称 必填
  3470. oprninfotemp["oprn_oprt_code"] = "" // 手术操作代码 必填
  3471. oprninfotemp["oprn_oprt_date"] = "" // 手术操作日期 必填
  3472. oprninfotemp["anst_way"] = "" // 麻醉方式 必填
  3473. oprninfotemp["oper_dr_name"] = "" // 术者医师姓名 必填
  3474. oprninfotemp["oper_dr_code"] = "" // 术者医师代码 必填
  3475. oprninfotemp["anst_dr_name"] = "" // 麻醉医师姓名 必填
  3476. oprninfotemp["anst_dr_code"] = "" // 麻醉医师代码 必填
  3477. oprninfo = append(oprninfo, oprninfotemp)
  3478. icuinfo := make([]map[string]interface{}, 0) // 重症监护信息
  3479. icuinfotemp := make(map[string]interface{})
  3480. icuinfotemp["scs_cutd_ward_type"] = "" // 重症监护病房类型 必填
  3481. icuinfotemp["scs_cutd_inpool_time"] = "" // 重症监护进入时间 必填
  3482. icuinfotemp["scs_cutd_exit_time"] = "" // 重症监护退出时间 必填
  3483. icuinfotemp["scs_cutd_sum_dura"] = "" // 重症监护合计时长 必填
  3484. icuinfo = append(icuinfo, icuinfotemp)
  3485. input["setlinfo"] = inputData
  3486. input["payinfo"] = payinfo
  3487. input["opspdiseinfo"] = opspdiseinfo
  3488. input["diseinfo"] = diseinfo
  3489. input["iteminfo"] = iteminfo
  3490. inputMessage["input"] = input //交易输入
  3491. bytesData, err := json.Marshal(inputMessage)
  3492. fmt.Println(string(bytesData))
  3493. if err != nil {
  3494. fmt.Println(err.Error())
  3495. return err.Error(), ""
  3496. }
  3497. reader := bytes.NewReader(bytesData)
  3498. gdyb_url := beego.AppConfig.String("gdyb_url")
  3499. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3500. //url := gdyb_url + "4101"
  3501. var url string
  3502. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  3503. url = gdyb_url
  3504. } else {
  3505. url = gdyb_url + "4101A"
  3506. }
  3507. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/4101"
  3508. request, err := http.NewRequest("POST", url, reader)
  3509. if err != nil {
  3510. fmt.Println(err.Error())
  3511. return err.Error(), ""
  3512. }
  3513. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3514. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3515. request.Header.Set("x-tif-signature", signature)
  3516. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3517. request.Header.Set("x-tif-nonce", nonce)
  3518. client := http.Client{}
  3519. resp, err := client.Do(request)
  3520. if err != nil {
  3521. fmt.Println(err.Error())
  3522. return err.Error(), ""
  3523. }
  3524. respBytes, err := ioutil.ReadAll(resp.Body)
  3525. if err != nil {
  3526. fmt.Println(err.Error())
  3527. return err.Error(), ""
  3528. }
  3529. str := string(respBytes)
  3530. fmt.Println(str)
  3531. return str, string(bytesData)
  3532. }
  3533. 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) {
  3534. // 生成签名
  3535. nonce := GetRandomString(32)
  3536. timestamp := time.Now().Unix()
  3537. signature := setSignature(timestamp, nonce, secret_key)
  3538. // 生成输入报文
  3539. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3540. input := make(map[string]interface{})
  3541. inputData := make(map[string]interface{})
  3542. inputMessage["infno"] = "4101A" // 交易编码
  3543. year := time.Now().Format("2006")
  3544. month := time.Now().Format("01")
  3545. day := time.Now().Format("02")
  3546. inputData["psn_no"] = struct4101.PsnNo // 结算 ID 必填
  3547. inputData["mdtrt_id"] = struct4101.MdtrtId // 就诊 ID 必填(来自2201接口返回)
  3548. inputData["setl_id"] = struct4101.SetlId // 结算 ID 必填
  3549. inputData["hi_no"] = struct4101.PsnNo // 医保编号
  3550. inputData["medcasno"] = struct4101.PsnNo // 病案号 必填
  3551. inputData["dcla_time"] = year + "-" + month + "-" + day // 申报时间 必填
  3552. inputData["ntly"] = struct4101.Ntly // 国籍 必填
  3553. inputData["prfs"] = struct4101.Prfs // 职业 必填
  3554. inputData["curr_addr"] = struct4101.CurAddr // 现住址 必填
  3555. inputData["emp_name"] = "" // 单位名称 必填
  3556. inputData["emp_addr"] = "" // 单位地址 必填
  3557. inputData["emp_tel"] = ""
  3558. inputData["poscode"] = "" // 邮编 必填
  3559. inputData["coner_name"] = "" // 联系人姓名 必填
  3560. inputData["patn_rlts"] = "" // 与患者关系 必填
  3561. inputData["coner_addr"] = "" // 联系人地址 必填
  3562. inputData["coner_tel"] = ""
  3563. inputData["nwb_adm_type"] = "" // 新生儿入院类型 必填
  3564. inputData["nwb_bir_wt"] = "" // 新生儿出生体重 必填
  3565. inputData["nwb_adm_wt"] = "" // 新生儿入院体重 必填
  3566. inputData["mul_nwb_bir_wt"] = "" // 新生儿入院体重 必填
  3567. inputData["mul_nwb_adm_wt"] = "" // 新生儿入院体重 必填
  3568. inputData["opsp_diag_caty"] = "" // 门诊慢特病诊断 必填
  3569. inputData["opsp_mdtrt_date"] = "" // 门诊慢特病就诊日期 必填
  3570. inputData["adm_way"] = "" // 入院途径 必填
  3571. inputData["trt_type"] = "" // 治疗类别 必填
  3572. inputData["adm_time"] = "" // 入院时间 必填
  3573. inputData["refldept_dept"] = "" // 转科科别 必填
  3574. inputData["dscg_time"] = "" // 出院时间 必填
  3575. inputData["dscg_caty"] = "" // 出院科别 必填
  3576. inputData["otp_wm_dise"] = "" // 门(急) 诊西医诊断 必填
  3577. inputData["wm_dise_code"] = "" // 门(急) 诊中医诊断 必填
  3578. inputData["otp_tcm_dise"] = "" // 西医诊断疾病代码 必填
  3579. inputData["tcm_dise_code"] = "" // 中医诊断代码 必填
  3580. inputData["vent_used_dura"] = "" // 呼吸机使用时长 必填
  3581. inputData["pwcry_bfadm_coma_dura"] = "" // 颅脑损伤患者入院前昏迷时长 必填
  3582. inputData["pwcry_afadm_coma_dura"] = "" // 颅脑损伤患者入院后昏迷时长 必填
  3583. inputData["spga_nurscare_days"] = "" // 特级护理天数 必填
  3584. inputData["lv1_nurscare_days"] = "" // 一级护理天数 必填
  3585. inputData["scd_nurscare_days"] = "" // 二级护理天数 必填
  3586. inputData["lv3_nurscare_days"] = "" // 三级护理天数 必填
  3587. inputData["acp_medins_name"] = "" // 拟接收机构名称 必填
  3588. inputData["acp_optins_code"] = "" // 拟接收机构代码 必填
  3589. inputData["bill_code"] = struct4101.BillCode // 票据代码 必填
  3590. inputData["bill_no"] = struct4101.BillNo // 票据号码 必填
  3591. inputData["biz_sn"] = struct4101.BizSn // 业务流水号 必填
  3592. inputData["hi_paymtd"] = "1" // 业务流水号 必填
  3593. inputData["days_rinp_flag_31"] = "" // 出院 31 天内再住院计划标志 必填
  3594. inputData["days_rinp_pup_31"] = "" // 出院 31 天内再住院目的 必填
  3595. //inputData["chfpdr_name"] = struct4101.DoctorName // 主诊医师姓名 必填
  3596. //inputData["chfpdr_code"] = struct4101.DoctorCode // 主诊医师代码 必填
  3597. inputData["setl_begn_date"] = struct4101.SetlBegnDate // 结算开始日期 必填
  3598. inputData["setl_end_date"] = struct4101.SetlEndDate // 结算结束日期 必填
  3599. inputData["medins_fill_dept"] = struct4101.MedinsFillDept // 医疗机构填报部门 必填
  3600. inputData["medins_fill_psn"] = struct4101.MedinsFillPsn // 医疗机构填报人 必填
  3601. //payinfo := make([]map[string]interface{}, 0) // 基金支付信息
  3602. //for _, item := range struct4101.CustomStruct {
  3603. // payinfotemp := make(map[string]interface{})
  3604. // 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" {
  3605. // payinfotemp["fund_pay_type"] = item.FundPayType // 基金支付类型 必填
  3606. // payinfotemp["fund_payamt"] = item.FundPayamt // 基金支付金额
  3607. // payinfo = append(payinfo, payinfotemp)
  3608. // }
  3609. //}
  3610. opspdiseinfo := make([]map[string]interface{}, 0) // 门诊慢特病诊断信息
  3611. opspdiseinfotemp := make(map[string]interface{})
  3612. opspdiseinfotemp["diag_name"] = "慢性肾脏病5期" // 诊断名称 必填
  3613. opspdiseinfotemp["diag_code"] = "N18.500" // 诊断代码 必填
  3614. opspdiseinfotemp["oprn_oprt_name"] = "血液透析" // 手术操作名称 必填
  3615. opspdiseinfotemp["oprn_oprt_code"] = "39.9500" // 手术操作代码 必填
  3616. opspdiseinfo = append(opspdiseinfo, opspdiseinfotemp)
  3617. diseinfo := make([]map[string]interface{}, 0) // 住院诊断信息
  3618. for _, item := range struct4101.Diseinfo {
  3619. diseinfotemp := make(map[string]interface{})
  3620. diseinfotemp["maindiag_flag"] = item.MaindiagFlag // 手术操作代码 必填
  3621. diseinfotemp["diag_type"] = item.DiagType // 诊断类别 必填
  3622. diseinfotemp["diag_code"] = item.DiagCode // 诊断代码 必填
  3623. diseinfotemp["diag_name"] = item.DiagName // 诊断名称 必填
  3624. diseinfotemp["adm_cond_type"] = "3" // 入院病情类型 必填
  3625. diseinfo = append(diseinfo, diseinfotemp)
  3626. }
  3627. //iteminfo := make([]map[string]interface{}, 0)
  3628. //for _, item := range struct4101.IteminfoStruct {
  3629. // iteminfotemp := make(map[string]interface{})
  3630. // iteminfotemp["med_chrgitm"] = item.MedChrgitm // 医疗收费项目 必填
  3631. // iteminfotemp["amt"] = item.Amt // 金额 必填
  3632. // iteminfotemp["claa_sumfee"] = item.ClaaSumfee // 甲类费用合计 必填
  3633. // iteminfotemp["clab_amt"] = item.ClabAmt // 乙类金额 必填
  3634. // iteminfotemp["fulamt_ownpay_amt"] = item.FulamtOwnpayAmt // 全自费金额 必填
  3635. // iteminfotemp["oth_amt"] = item.OthAmt // 其他金额 必填
  3636. // iteminfo = append(iteminfo, iteminfotemp)
  3637. //}
  3638. oprninfo := make([]map[string]interface{}, 0) // 手术操作信息
  3639. oprninfotemp := make(map[string]interface{})
  3640. oprninfotemp["oprn_oprt_type"] = "" // 手术操作类别 必填
  3641. oprninfotemp["oprn_oprt_name"] = "" // 手术操作名称 必填
  3642. oprninfotemp["oprn_oprt_code"] = "" // 手术操作代码 必填
  3643. oprninfotemp["oprn_oprt_date"] = "" // 手术操作日期 必填
  3644. oprninfotemp["anst_way"] = "" // 麻醉方式 必填
  3645. oprninfotemp["oper_dr_name"] = "" // 术者医师姓名 必填
  3646. oprninfotemp["oper_dr_code"] = "" // 术者医师代码 必填
  3647. oprninfotemp["anst_dr_name"] = "" // 麻醉医师姓名 必填
  3648. oprninfotemp["anst_dr_code"] = "" // 麻醉医师代码 必填
  3649. oprninfo = append(oprninfo, oprninfotemp)
  3650. icuinfo := make([]map[string]interface{}, 0) // 重症监护信息
  3651. icuinfotemp := make(map[string]interface{})
  3652. icuinfotemp["scs_cutd_ward_type"] = "" // 重症监护病房类型 必填
  3653. icuinfotemp["scs_cutd_inpool_time"] = "" // 重症监护进入时间 必填
  3654. icuinfotemp["scs_cutd_exit_time"] = "" // 重症监护退出时间 必填
  3655. icuinfotemp["scs_cutd_sum_dura"] = "" // 重症监护合计时长 必填
  3656. icuinfo = append(icuinfo, icuinfotemp)
  3657. input["setlinfo"] = inputData
  3658. input["opspdiseinfo"] = opspdiseinfo
  3659. //input["diseinfo"] = diseinfo
  3660. //input["oprninfo"] = payinfo
  3661. //input["icuinfo"] = payinfo
  3662. //input["bldinfo"] = payinfo
  3663. inputMessage["input"] = input //交易输入
  3664. bytesData, err := json.Marshal(inputMessage)
  3665. fmt.Println(string(bytesData))
  3666. if err != nil {
  3667. fmt.Println(err.Error())
  3668. return err.Error(), ""
  3669. }
  3670. reader := bytes.NewReader(bytesData)
  3671. gdyb_url := beego.AppConfig.String("gdyb_url")
  3672. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3673. //url := gdyb_url + "4101"
  3674. var url string
  3675. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  3676. url = gdyb_url
  3677. } else {
  3678. url = gdyb_url + "4101A"
  3679. }
  3680. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/4101"
  3681. request, err := http.NewRequest("POST", url, reader)
  3682. if err != nil {
  3683. fmt.Println(err.Error())
  3684. return err.Error(), ""
  3685. }
  3686. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3687. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3688. request.Header.Set("x-tif-signature", signature)
  3689. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3690. request.Header.Set("x-tif-nonce", nonce)
  3691. client := http.Client{}
  3692. resp, err := client.Do(request)
  3693. if err != nil {
  3694. fmt.Println(err.Error())
  3695. return err.Error(), ""
  3696. }
  3697. respBytes, err := ioutil.ReadAll(resp.Body)
  3698. if err != nil {
  3699. fmt.Println(err.Error())
  3700. return err.Error(), ""
  3701. }
  3702. str := string(respBytes)
  3703. fmt.Println(str)
  3704. return str, string(bytesData)
  3705. }
  3706. //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 {
  3707. // // 生成签名
  3708. // nonce := GetRandomString(32)
  3709. // timestamp := time.Now().Unix()
  3710. // signature := setSignature(timestamp, nonce, secret_key)
  3711. // tempTime := time.Unix(timestamp, 0)
  3712. // //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  3713. //
  3714. // timeFormatTwo := tempTime.Format("2006-01-02")
  3715. //
  3716. // t := time.Now()
  3717. // last := time.Date(t.Year(), time.December, 31, 0, 0, 0, 0, time.UTC)
  3718. // tm := time.Unix(last.Unix(), 0)
  3719. //
  3720. // // 生成输入报文
  3721. // inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3722. // input := make(map[string]interface{})
  3723. // inputData := make(map[string]interface{})
  3724. //
  3725. // inputData2 := make(map[string]interface{})
  3726. //
  3727. // inputMessage["infno"] = "7101" // 交易编码
  3728. // inputData["hosp_rxno"] = psnNo // 人员编号 (来自1101接口返回)
  3729. // inputData["init_rxno"] = insutype // 险种类型(来自1101接口返回)
  3730. // inputData["rx_type_code"] = sick_code // 险种类型(来自1101接口返回)
  3731. // inputData["prsc_time"] = sick_name // 险种类型(来自1101接口返回)
  3732. // inputData["rx_drug_nums"] = insuplc_admdvs // 险种类型(来自1101接口返回)
  3733. // inputData["rx_way_codg"] = fixmedins_code // 险种类型(来自1101接口返回)
  3734. // inputData["rx_way_name"] = org_name // 险种类型(来自1101接口返回)
  3735. // inputData["rx_freq_codg"] = timeFormatTwo // 险种类型(来自1101接口返回)
  3736. // inputData["rx_freq_name"] = doctor_id // 开始时间
  3737. // inputData["rx_dosunt"] = doctor // 开始时间
  3738. // inputData["rx_doscnt"] = timeFormatTwo // 医师编码
  3739. // inputData["rx_drord_dscr"] = "" // 医师编码
  3740. // inputData["valid_days"] = "" // 医师编码
  3741. // inputData["valid_end_time"] = tm.Format("2006-01-02") // 医师编码
  3742. // inputData["rept_flag"] = tm.Format("2006-01-02") // 医师编码
  3743. // inputData["max_rept_cnt"] = tm.Format("2006-01-02") // 医师编码
  3744. // inputData["reptd_cnt"] = tm.Format("2006-01-02") // 医师编码
  3745. // inputData["min_inrv_days"] = tm.Format("2006-01-02") // 医师编码
  3746. // inputData["dr_sign_info"] = tm.Format("2006-01-02") // 医师编码
  3747. // inputData["phar_sign_info"] = tm.Format("2006-01-02") // 医师编码
  3748. // inputData["fixmedins_sign_info"] = tm.Format("2006-01-02") // 医师编码
  3749. // inputData["rx_cotn_flag"] = tm.Format("2006-01-02") // 医师编码
  3750. // inputData["rx_file"] = tm.Format("2006-01-02") // 医师编码
  3751. // input["data"] = inputData
  3752. //
  3753. //
  3754. // inputData2["med_list_codg"] = psnNo // 人员编号 (来自1101接口返回)
  3755. // inputData2["fixmedins_hilist_id"] = insutype // 险种类型(来自1101接口返回)
  3756. // inputData["hosp_prep_flag"] = sick_code // 险种类型(来自1101接口返回)
  3757. // inputData["rx_item_type_code"] = sick_name // 险种类型(来自1101接口返回)
  3758. // inputData["rx_item_type_name"] = insuplc_admdvs // 险种类型(来自1101接口返回)
  3759. // inputData["tcmdrug_type_name"] = fixmedins_code // 险种类型(来自1101接口返回)
  3760. // inputData["tcmdrug_type_code"] = org_name // 险种类型(来自1101接口返回)
  3761. // inputData["tcmherb_foote"] = timeFormatTwo // 险种类型(来自1101接口返回)
  3762. // inputData["medn_type_code"] = doctor_id // 开始时间
  3763. // inputData["medn_type_name"] = doctor // 开始时间
  3764. // inputData["main_medc_flag"] = timeFormatTwo // 医师编码
  3765. // inputData["urgt_flag"] = "" // 医师编码
  3766. // inputData["bas_medn_flag"] = "" // 医师编码
  3767. // inputData["imp_drug_flag"] = tm.Format("2006-01-02") // 医师编码
  3768. // inputData["prod_barc"] = tm.Format("2006-01-02") // 医师编码
  3769. // inputData["drug_prodname"] = tm.Format("2006-01-02") // 医师编码
  3770. //
  3771. // inputData["genname_codg"] = tm.Format("2006-01-02") // 医师编码
  3772. // inputData["drug_genname"] = tm.Format("2006-01-02") // 医师编码
  3773. // inputData["chemname"] = tm.Format("2006-01-02") // 医师编码
  3774. //
  3775. // inputData["drugstdcode"] = tm.Format("2006-01-02") // 医师编码
  3776. // inputData["drug_dosform"] = tm.Format("2006-01-02") // 医师编码
  3777. //
  3778. //
  3779. // inputData["drug_spec"] = tm.Format("2006-01-02") // 医师编码
  3780. // inputData["prdr_name"] = tm.Format("2006-01-02") // 医师编码
  3781. //
  3782. //
  3783. // inputData["drug_pric"] = tm.Format("2006-01-02") // 医师编码
  3784. // inputData["drug_cnt"] = tm.Format("2006-01-02") // 医师编码
  3785. // inputData["drug_cnt_unit"] = tm.Format("2006-01-02") // 医师编码
  3786. // inputData["drug_sumamt"] = tm.Format("2006-01-02") // 医师编码
  3787. // inputData["medc_way_codg"] = tm.Format("2006-01-02") // 医师编码
  3788. // inputData["medc_way_dscr"] = tm.Format("2006-01-02") // 医师编码
  3789. // inputData["medc_starttime"] = tm.Format("2006-01-02") // 医师编码
  3790. //
  3791. // inputData["medc_endtime"] = tm.Format("2006-01-02") // 医师编码
  3792. //
  3793. //
  3794. // inputData["medc_days"] = tm.Format("2006-01-02") // 医师编码
  3795. // inputData["drug_dosunt"] = tm.Format("2006-01-02") // 医师编码
  3796. // inputData["sin_doscnt"] = tm.Format("2006-01-02") // 医师编码
  3797. // inputData["sin_dosunt"] = tm.Format("2006-01-02") // 医师编码
  3798. // inputData["used_frqu_codg"] = tm.Format("2006-01-02") // 医师编码
  3799. //
  3800. //
  3801. // inputData["used_frqu_name"] = tm.Format("2006-01-02") // 医师编码
  3802. // inputData["drug_totlnt"] = tm.Format("2006-01-02") // 医师编码
  3803. //
  3804. // inputData["drug_totlnt_emp"] = tm.Format("2006-01-02") // 医师编码
  3805. // inputData["dise_codg"] = tm.Format("2006-01-02") // 医师编码
  3806. // inputData["drug_res"] = tm.Format("2006-01-02") // 医师编码
  3807. // inputData["drug_limit"] = tm.Format("2006-01-02") // 医师编码
  3808. //
  3809. //
  3810. //
  3811. //
  3812. //
  3813. //
  3814. //
  3815. //
  3816. //
  3817. // input["rxdrugdetail"] = inputData2
  3818. //
  3819. //
  3820. //
  3821. //
  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. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2503"
  3831. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2503"
  3832. // gdyb_url := beego.AppConfig.String("gdyb_url")
  3833. // gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3834. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  3835. // url := gdyb_url + "2503"
  3836. //
  3837. // request, err := http.NewRequest("POST", url, reader)
  3838. // if err != nil {
  3839. // fmt.Println(err.Error())
  3840. // return err.Error()
  3841. // }
  3842. //
  3843. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3844. // request.Header.Set("x-tif-paasid", gdyb_paasid)
  3845. // request.Header.Set("x-tif-signature", signature)
  3846. // request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3847. // request.Header.Set("x-tif-nonce", nonce)
  3848. //
  3849. // client := http.Client{}
  3850. // resp, err := client.Do(request)
  3851. // if err != nil {
  3852. // fmt.Println(err.Error())
  3853. // return err.Error()
  3854. // }
  3855. // respBytes, err := ioutil.ReadAll(resp.Body)
  3856. // if err != nil {
  3857. // fmt.Println(err.Error())
  3858. // return err.Error()
  3859. // }
  3860. // str := string(respBytes)
  3861. // fmt.Println(str)
  3862. // return str
  3863. //}
  3864. // 生成签名
  3865. func setSignature(timestamp int64, nonce string, secret_key string) string {
  3866. fmt.Println(timestamp)
  3867. fmt.Println(nonce)
  3868. fmt.Println(secret_key)
  3869. fmt.Println(strconv.FormatInt(timestamp, 10))
  3870. fmt.Println(time.Now().UnixNano() / 1e6)
  3871. str := strconv.FormatInt(timestamp, 10) + secret_key + nonce + strconv.FormatInt(timestamp, 10)
  3872. hash := sha256.New()
  3873. //输入数据
  3874. hash.Write([]byte(str))
  3875. //计算哈希值
  3876. bytes := hash.Sum(nil)
  3877. //将字符串编码为16进制格式,返回字符串
  3878. hashCode := hex.EncodeToString(bytes)
  3879. //返回哈希值
  3880. return hashCode
  3881. }
  3882. const charset = "abcdefghijklmnopqrstuvwxyz" +
  3883. "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
  3884. var seededRand *rand.Rand = rand.New(
  3885. rand.NewSource(time.Now().UnixNano()))
  3886. // 生成随机字符串
  3887. func GetRandomString(l int) string {
  3888. //str := "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
  3889. //bytes := []byte(str)
  3890. //result := []byte{}
  3891. //r := rand.New(rand.NewSource(time.Now().UnixNano()))
  3892. //for i := 0; i < l; i++ {
  3893. // result = append(result, bytes[r.Intn(len(bytes))])
  3894. //}
  3895. return String(32)
  3896. }
  3897. func StringWithCharset(length int, charset string) string {
  3898. b := make([]byte, length)
  3899. for i := range b {
  3900. b[i] = charset[seededRand.Intn(len(charset))]
  3901. }
  3902. return string(b)
  3903. }
  3904. func String(length int) string {
  3905. return StringWithCharset(length, charset)
  3906. }
  3907. // 生成基础报文
  3908. 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{} {
  3909. // 生成签名
  3910. tempTime := time.Unix(timestamp, 0)
  3911. //timeFormat := tempTime.Format("20060102150405")
  3912. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  3913. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  3914. month := time.Unix(1557042972, 0).Format("1")
  3915. year := time.Now().Format("2006")
  3916. month = time.Now().Format("01")
  3917. day := time.Now().Format("02")
  3918. hour := time.Now().Format("15")
  3919. min := time.Now().Format("04")
  3920. sec := time.Now().Format("05")
  3921. msec := time.Now().Format("000")
  3922. // 生成输入报文
  3923. inputMessage := make(map[string]interface{})
  3924. inputMessage["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  3925. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  3926. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  3927. inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  3928. inputMessage["dev_no"] = "" // 设备编号
  3929. inputMessage["dev_safe_info"] = "" // 设备安全信息
  3930. inputMessage["cainfo"] = "" // 数字签名信息
  3931. inputMessage["signtype"] = "MOCK" // 签名类型
  3932. inputMessage["infver"] = "V1.0" // 接收方系统代码
  3933. inputMessage["opter_type"] = "1" // 经办人类别
  3934. inputMessage["opter"] = doctor // 经办人
  3935. inputMessage["opter_name"] = op_name // 经办人姓名
  3936. inputMessage["inf_time"] = timeFormatOne // 交易时间
  3937. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  3938. inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  3939. if mdtrtarea_admvs == "440100" {
  3940. inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号
  3941. } else {
  3942. inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号 //交易签到流水号
  3943. }
  3944. return inputMessage
  3945. }
  3946. func SetInputMessage(nonce string, timestamp int64, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) map[string]interface{} {
  3947. // 生成签名
  3948. tempTime := time.Unix(timestamp, 0)
  3949. //timeFormat := tempTime.Format("20060102150405")
  3950. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  3951. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  3952. month := time.Unix(1557042972, 0).Format("1")
  3953. year := time.Now().Format("2006")
  3954. month = time.Now().Format("01")
  3955. day := time.Now().Format("02")
  3956. hour := time.Now().Format("15")
  3957. min := time.Now().Format("04")
  3958. sec := time.Now().Format("05")
  3959. msec := time.Now().Format("000")
  3960. // 生成输入报文
  3961. inputMessage := make(map[string]interface{})
  3962. inputMessage["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  3963. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  3964. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  3965. inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  3966. inputMessage["dev_no"] = "" // 设备编号
  3967. inputMessage["dev_safe_info"] = "" // 设备安全信息
  3968. inputMessage["cainfo"] = "" // 数字签名信息
  3969. inputMessage["signtype"] = "MOCK" // 签名类型
  3970. inputMessage["infver"] = "V1.0" // 接收方系统代码
  3971. inputMessage["opter_type"] = "1" // 经办人类别
  3972. inputMessage["opter"] = doctor // 经办人
  3973. inputMessage["opter_name"] = doctor // 经办人姓名
  3974. inputMessage["inf_time"] = timeFormatOne // 交易时间
  3975. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  3976. inputMessage["fixmedins_name"] = org_name
  3977. inputMessage["sign_no"] = "489925883" //交易签到流水号
  3978. //定点医药机构名称
  3979. //if mdtrtarea_admvs == "440100" {
  3980. // inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号
  3981. //} else {
  3982. // inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号 //交易签到流水号
  3983. //}
  3984. return inputMessage
  3985. }
  3986. func SetInputMessagenosign(nonce string, timestamp int64, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) map[string]interface{} {
  3987. // 生成签名
  3988. tempTime := time.Unix(timestamp, 0)
  3989. //timeFormat := tempTime.Format("20060102150405")
  3990. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  3991. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  3992. month := time.Unix(1557042972, 0).Format("1")
  3993. year := time.Now().Format("2006")
  3994. month = time.Now().Format("01")
  3995. day := time.Now().Format("02")
  3996. hour := time.Now().Format("15")
  3997. min := time.Now().Format("04")
  3998. sec := time.Now().Format("05")
  3999. msec := time.Now().Format("000")
  4000. // 生成输入报文
  4001. inputMessage := make(map[string]interface{})
  4002. inputMessage["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  4003. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  4004. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  4005. inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  4006. inputMessage["dev_no"] = "" // 设备编号
  4007. inputMessage["dev_safe_info"] = "" // 设备安全信息
  4008. inputMessage["cainfo"] = "" // 数字签名信息
  4009. inputMessage["signtype"] = "MOCK" // 签名类型
  4010. inputMessage["infver"] = "V1.0" // 接收方系统代码
  4011. inputMessage["opter_type"] = "1" // 经办人类别
  4012. inputMessage["opter"] = doctor // 经办人
  4013. inputMessage["opter_name"] = doctor // 经办人姓名
  4014. inputMessage["inf_time"] = timeFormatOne // 交易时间
  4015. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  4016. inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  4017. if mdtrtarea_admvs == "440100" {
  4018. inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号
  4019. } else {
  4020. inputMessage["sign_no"] = ""
  4021. }
  4022. return inputMessage
  4023. }
  4024. //func GetSignInInfo(code string) string {
  4025. // var sign models.HisSignIn
  4026. // err = readDb.Model(&models.HisSignIn{}).Where("fixmedins_code = ? AND status = 1", code).Last(&sign).Error
  4027. // return sign.SignNo
  4028. //}
  4029. 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{} {
  4030. // 生成签名
  4031. tempTime := time.Unix(timestamp, 0)
  4032. //timeFormat := tempTime.Format("20060102150405")
  4033. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  4034. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  4035. // 生成输入报文
  4036. inputMessage := make(map[string]interface{})
  4037. inputMessage["msgid"] = msg_id // 发送方报文 ID
  4038. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  4039. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  4040. inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  4041. inputMessage["dev_no"] = "" // 设备编号
  4042. inputMessage["dev_safe_info"] = "" // 设备安全信息
  4043. inputMessage["cainfo"] = "" // 数字签名信息
  4044. inputMessage["signtype"] = "SM3" // 签名类型
  4045. inputMessage["infver"] = "V1.0" // 接收方系统代码
  4046. inputMessage["opter_type"] = "1" // 经办人类别
  4047. inputMessage["opter"] = doctor // 经办人
  4048. inputMessage["opter_name"] = doctor // 经办人姓名
  4049. inputMessage["inf_time"] = timeFormatOne // 交易时间
  4050. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  4051. inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  4052. if mdtrtarea_admvs == "440100" {
  4053. inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号
  4054. } else {
  4055. inputMessage["sign_no"] = "" //交易签到流水号
  4056. }
  4057. return inputMessage
  4058. }
  4059. 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{} {
  4060. // 生成签名
  4061. tempTime := time.Unix(timestamp, 0)
  4062. //timeFormat := tempTime.Format("20060102150405")
  4063. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  4064. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  4065. month := time.Unix(1557042972, 0).Format("1")
  4066. year := time.Now().Format("2006")
  4067. month = time.Now().Format("01")
  4068. day := time.Now().Format("02")
  4069. hour := time.Now().Format("15")
  4070. min := time.Now().Format("04")
  4071. sec := time.Now().Format("05")
  4072. msec := time.Now().Format("000")
  4073. // 生成输入报文
  4074. inputMessage := make(map[string]interface{})
  4075. inputMessage["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  4076. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  4077. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  4078. inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  4079. inputMessage["dev_no"] = "" // 设备编号
  4080. inputMessage["dev_safe_info"] = "" // 设备安全信息
  4081. inputMessage["cainfo"] = "" // 数字签名信息
  4082. inputMessage["signtype"] = "SM3" // 签名类型
  4083. inputMessage["infver"] = "V1.0" // 接收方系统代码
  4084. inputMessage["opter_type"] = "1" // 经办人类别
  4085. inputMessage["opter"] = doctor // 经办人
  4086. inputMessage["opter_name"] = doctor // 经办人姓名
  4087. inputMessage["inf_time"] = timeFormatOne // 交易时间
  4088. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  4089. inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  4090. if mdtrtarea_admvs == "440100" {
  4091. inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号
  4092. } else {
  4093. inputMessage["sign_no"] = sign_no //交易签到流水号
  4094. }
  4095. return inputMessage
  4096. }
  4097. func postFile(filename string, target_url string) (*http.Response, error) {
  4098. body_buf := bytes.NewBufferString("")
  4099. body_writer := multipart.NewWriter(body_buf)
  4100. // use the body_writer to write the Part headers to the buffer
  4101. _, err := body_writer.CreateFormFile("userfile", filename)
  4102. if err != nil {
  4103. fmt.Println("error writing to buffer")
  4104. return nil, err
  4105. }
  4106. // the file data will be the second part of the body
  4107. fh, err := os.Open(filename)
  4108. if err != nil {
  4109. fmt.Println("error opening file")
  4110. return nil, err
  4111. }
  4112. // need to know the boundary to properly close the part myself.
  4113. boundary := body_writer.Boundary()
  4114. //close_string := fmt.Sprintf("\r\n--%s--\r\n", boundary)
  4115. close_buf := bytes.NewBufferString(fmt.Sprintf("\r\n--%s--\r\n", boundary))
  4116. // use multi-reader to defer the reading of the file data until
  4117. // writing to the socket buffer.
  4118. request_reader := io.MultiReader(body_buf, fh, close_buf)
  4119. fi, err := fh.Stat()
  4120. if err != nil {
  4121. fmt.Printf("Error Stating file: %s", filename)
  4122. return nil, err
  4123. }
  4124. req, err := http.NewRequest("POST", target_url, request_reader)
  4125. if err != nil {
  4126. return nil, err
  4127. }
  4128. // Set headers for multipart, and Content Length
  4129. req.Header.Add("Content-Type", "multipart/form-data; boundary="+boundary)
  4130. req.ContentLength = fi.Size() + int64(body_buf.Len()) + int64(close_buf.Len())
  4131. return http.DefaultClient.Do(req)
  4132. }
  4133. //func Gdyb1201(psnNo string, org_name string, doctor string) string {
  4134. // // 生成签名
  4135. // nonce := GetRandomString(32)
  4136. // timestamp := time.Now().Unix()
  4137. // signature := setSignature(timestamp, nonce)
  4138. //
  4139. // // 生成输入报文
  4140. // inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, "")
  4141. // input := make(map[string]interface{})
  4142. // inputData := make(map[string]interface{})
  4143. // inputMessage["infno"] = "1201" // 交易编码
  4144. // inputData["fixmedins_type"] = psnNo // 人员编号 (来自1101接口返回)
  4145. // inputData["fixmedins_name"] = org_name // 人员编号 (来自1101接口返回)
  4146. // inputData["fixmedins_code"] = "" // 人员编号 (来自1101接口返回)
  4147. //
  4148. // input["medinsinfo"] = inputData
  4149. // inputMessage["input"] = input //交易输入
  4150. //
  4151. // bytesData, err := json.Marshal(inputMessage)
  4152. // fmt.Println(string(bytesData))
  4153. // if err != nil {
  4154. // fmt.Println(err.Error())
  4155. // return err.Error()
  4156. // }
  4157. // reader := bytes.NewReader(bytesData)
  4158. //
  4159. // url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1201"
  4160. // request, err := http.NewRequest("POST", url, reader)
  4161. // if err != nil {
  4162. // fmt.Println(err.Error())
  4163. // return err.Error()
  4164. // }
  4165. //
  4166. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4167. // request.Header.Set("x-tif-paasid", "test_hosp")
  4168. // request.Header.Set("x-tif-signature", signature)
  4169. // request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4170. // request.Header.Set("x-tif-nonce", nonce)
  4171. //
  4172. // client := http.Client{}
  4173. // resp, err := client.Do(request)
  4174. // if err != nil {
  4175. // fmt.Println(err.Error())
  4176. // return err.Error()
  4177. // }
  4178. // respBytes, err := ioutil.ReadAll(resp.Body)
  4179. // if err != nil {
  4180. // fmt.Println(err.Error())
  4181. // return err.Error()
  4182. // }
  4183. // str := string(respBytes)
  4184. // fmt.Println(str)
  4185. // return str
  4186. //}
  4187. func newfileUploadRequest(uri string, params map[string]string, paramName, path string) (*http.Request, error) {
  4188. file, err := os.Open(path)
  4189. if err != nil {
  4190. return nil, err
  4191. }
  4192. defer file.Close()
  4193. body := &bytes.Buffer{}
  4194. writer := multipart.NewWriter(body)
  4195. part, err := writer.CreateFormFile(paramName, filepath.Base(path))
  4196. if err != nil {
  4197. return nil, err
  4198. }
  4199. _, err = io.Copy(part, file)
  4200. for key, val := range params {
  4201. _ = writer.WriteField(key, val)
  4202. }
  4203. err = writer.Close()
  4204. if err != nil {
  4205. return nil, err
  4206. }
  4207. req, err := http.NewRequest("POST", uri, body)
  4208. req.Header.Set("Content-Type", writer.FormDataContentType())
  4209. return req, err
  4210. }
  4211. func CreateMedicalInsuranceCostCompareRecord(record *models.MedicalInsuranceCostCompare) error {
  4212. err := writeDb.Save(&record).Error
  4213. return err
  4214. }
  4215. //func Gdyb5203(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  4216. // // 生成签名
  4217. // nonce := GetRandomString(32)
  4218. // timestamp := time.Now().Unix()
  4219. // signature := setSignature(timestamp, nonce, secret_key)
  4220. //
  4221. // // 生成输入报文
  4222. // inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4223. // input := make(map[string]interface{})
  4224. // inputData := make(map[string]interface{})
  4225. // inputMessage["infno"] = "5203" // 交易编码
  4226. //
  4227. // inputData["fixmedins_type"] = "1"
  4228. // inputData["fixmedins_name"] = org_name
  4229. // inputData["fixmedins_code"] = fixmedins_code
  4230. // input["medinsinfo"] = inputData
  4231. // inputMessage["input"] = input //交易输入
  4232. //
  4233. // bytesData, err := json.Marshal(inputMessage)
  4234. // fmt.Println(string(bytesData))
  4235. // if err != nil {
  4236. // fmt.Println(err.Error())
  4237. // return err.Error()
  4238. // }
  4239. // reader := bytes.NewReader(bytesData)
  4240. // url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1201"
  4241. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1201"
  4242. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4243. // request, err := http.NewRequest("POST", url, reader)
  4244. // if err != nil {
  4245. // fmt.Println(err.Error())
  4246. // return err.Error()
  4247. // }
  4248. //
  4249. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4250. // request.Header.Set("x-tif-paasid", "sg03_prd")
  4251. // request.Header.Set("x-tif-signature", signature)
  4252. // request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4253. // request.Header.Set("x-tif-nonce", nonce)
  4254. //
  4255. // client := http.Client{}
  4256. // resp, err := client.Do(request)
  4257. // if err != nil {
  4258. // fmt.Println(err.Error())
  4259. // return err.Error()
  4260. // }
  4261. // respBytes, err := ioutil.ReadAll(resp.Body)
  4262. // if err != nil {
  4263. // fmt.Println(err.Error())
  4264. // return err.Error()
  4265. // }
  4266. // fmt.Println(string(respBytes))
  4267. // str := string(respBytes)
  4268. // return str
  4269. //}
  4270. func CreatePsnRecord(record *models.GdybPsnRecord) {
  4271. writeDb.Save(&record)
  4272. return
  4273. }
  4274. func GetPsnRecordById(id int64) (record models.GdybPsnRecord, err error) {
  4275. err = readDb.Model(&models.GdybPsnRecord{}).Where("id = ?").First(&record).Error
  4276. return
  4277. }
  4278. func CreatePsnNCDSRecord(record *models.GdybPsnNcdsRecord) {
  4279. writeDb.Save(&record)
  4280. return
  4281. }
  4282. func GetPsnNCDSRecordById(id int64) (record models.GdybPsnNcdsRecord, err error) {
  4283. err = readDb.Model(&models.GdybPsnNcdsRecord{}).Where("id = ?", id).First(&record).Error
  4284. return
  4285. }
  4286. func GetPatientsByIds(ids []string, current_org_id int64) (patients []*models.Patients, err error) {
  4287. err = readDb.Model(&models.Patients{}).Where("id IN (?) AND user_org_id = ?", ids, current_org_id).Find(&patients).Error
  4288. return
  4289. }
  4290. 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 {
  4291. // 生成签名
  4292. nonce := GetRandomString(32)
  4293. timestamp := time.Now().Unix()
  4294. signature := setSignature(timestamp, nonce, secret_key)
  4295. // 生成输入报文
  4296. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4297. input := make(map[string]interface{})
  4298. inputData := make(map[string]interface{})
  4299. inputMessage["infno"] = "2601" // 交易编码
  4300. inputData["psn_no"] = psnNo
  4301. inputData["omsgid"] = omsgid
  4302. inputData["oinfno"] = oinfno
  4303. input["data"] = inputData
  4304. inputMessage["input"] = input //交易输入
  4305. bytesData, err := json.Marshal(inputMessage)
  4306. fmt.Println(string(bytesData))
  4307. if err != nil {
  4308. fmt.Println(err.Error())
  4309. return err.Error()
  4310. }
  4311. reader := bytes.NewReader(bytesData)
  4312. gdyb_url := beego.AppConfig.String("gdyb_url")
  4313. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4314. url := gdyb_url + "2601"
  4315. request, err := http.NewRequest("POST", url, reader)
  4316. if err != nil {
  4317. fmt.Println(err.Error())
  4318. return err.Error()
  4319. }
  4320. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4321. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4322. request.Header.Set("x-tif-signature", signature)
  4323. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4324. request.Header.Set("x-tif-nonce", nonce)
  4325. client := http.Client{}
  4326. resp, err := client.Do(request)
  4327. if err != nil {
  4328. fmt.Println(err.Error())
  4329. return err.Error()
  4330. }
  4331. respBytes, err := ioutil.ReadAll(resp.Body)
  4332. if err != nil {
  4333. fmt.Println(err.Error())
  4334. return err.Error()
  4335. }
  4336. str := string(respBytes)
  4337. fmt.Println(str)
  4338. return str
  4339. }
  4340. // 人员信息版本3
  4341. 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 {
  4342. //生成签名
  4343. nonce := GetRandomString(32)
  4344. timestamp := time.Now().Unix()
  4345. signature := setSignature(timestamp, nonce, secret_key)
  4346. //生成输入报文
  4347. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4348. inputMessage := make(map[string]interface{})
  4349. //生成输入报文
  4350. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  4351. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  4352. } else {
  4353. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4354. }
  4355. input := make(map[string]interface{})
  4356. inputData := make(map[string]interface{})
  4357. inputMessage["infno"] = "1101" // 交易编码
  4358. if certificates == 3 {
  4359. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  4360. inputData["certno"] = "01836483" // 证件号码
  4361. inputData["psn_cert_type"] = "01" // 人员证件类型
  4362. inputData["mdtrt_cert_no"] = "01836483" // 就诊凭证编号
  4363. } else {
  4364. if certificates == 1 {
  4365. if id_card_type == 1 {
  4366. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  4367. inputData["card_sn"] = card_sn // 卡识别码
  4368. inputData["certno"] = certNo // 证件号码
  4369. inputData["psn_cert_type"] = "01" // 人员证件类型
  4370. inputData["mdtrt_cert_no"] = cardNumber // 就诊凭证编号
  4371. } else {
  4372. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  4373. inputData["card_sn"] = "" // 卡识别码
  4374. inputData["certno"] = certNo // 证件号码
  4375. inputData["psn_cert_type"] = "01" // 人员证件类型
  4376. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  4377. }
  4378. } else if certificates == 6 {
  4379. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  4380. inputData["card_sn"] = "" // 卡识别码
  4381. inputData["certno"] = certNo // 证件号码
  4382. inputData["psn_cert_type"] = "17" // 人员证件类型
  4383. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  4384. }
  4385. }
  4386. inputData["begntime"] = "" // 开始时间
  4387. inputData["psn_name"] = name // 人员姓名
  4388. input["data"] = inputData
  4389. inputMessage["input"] = input //交易输入
  4390. bytesData, err := json.Marshal(inputMessage)
  4391. fmt.Println(string(bytesData))
  4392. if err != nil {
  4393. fmt.Println(err.Error())
  4394. return err.Error()
  4395. }
  4396. reader := bytes.NewReader(bytesData)
  4397. gdyb_url := beego.AppConfig.String("gdyb_url")
  4398. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4399. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4400. //url := gdyb_url + "1101"
  4401. var url string
  4402. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  4403. url = gdyb_url
  4404. } else {
  4405. url = gdyb_url + "1101"
  4406. }
  4407. fmt.Println(url)
  4408. fmt.Println(gdyb_paasid)
  4409. fmt.Println(secret_key)
  4410. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4411. request, err := http.NewRequest("POST", url, reader)
  4412. if err != nil {
  4413. fmt.Println(err.Error())
  4414. return err.Error()
  4415. }
  4416. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4417. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4418. request.Header.Set("x-tif-signature", signature)
  4419. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4420. request.Header.Set("x-tif-nonce", nonce)
  4421. client := http.Client{}
  4422. resp, err := client.Do(request)
  4423. if err != nil {
  4424. fmt.Println(err.Error())
  4425. return err.Error()
  4426. }
  4427. respBytes, err := ioutil.ReadAll(resp.Body)
  4428. if err != nil {
  4429. fmt.Println(err.Error())
  4430. return err.Error()
  4431. }
  4432. fmt.Println(string(respBytes))
  4433. str := string(respBytes)
  4434. return str
  4435. }
  4436. 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 {
  4437. //生成签名
  4438. nonce := GetRandomString(32)
  4439. timestamp := time.Now().Unix()
  4440. signature := setSignature(timestamp, nonce, secret_key)
  4441. inputMessage := make(map[string]interface{})
  4442. //生成输入报文
  4443. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  4444. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  4445. } else {
  4446. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4447. }
  4448. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4449. input := make(map[string]interface{})
  4450. inputData := make(map[string]interface{})
  4451. inputMessage["infno"] = "1101" // 交易编码
  4452. if certificates == 3 {
  4453. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  4454. inputData["certno"] = "01836483" // 证件号码
  4455. inputData["psn_cert_type"] = "01" // 人员证件类型
  4456. inputData["mdtrt_cert_no"] = "01836483" // 就诊凭证编号
  4457. } else {
  4458. if certificates == 1 {
  4459. if id_card_type == 4 {
  4460. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  4461. inputData["card_sn"] = card_sn // 卡识别码
  4462. inputData["certno"] = certNo // 证件号码
  4463. inputData["psn_cert_type"] = "01" // 人员证件类型
  4464. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  4465. }
  4466. } else if certificates == 6 {
  4467. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  4468. inputData["card_sn"] = "" // 卡识别码
  4469. inputData["certno"] = certNo // 证件号码
  4470. inputData["psn_cert_type"] = "17" // 人员证件类型
  4471. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  4472. }
  4473. }
  4474. inputData["begntime"] = "" // 开始时间
  4475. inputData["psn_name"] = name // 人员姓名
  4476. input["data"] = inputData
  4477. inputMessage["input"] = input //交易输入
  4478. bytesData, err := json.Marshal(inputMessage)
  4479. fmt.Println(string(bytesData))
  4480. if err != nil {
  4481. fmt.Println(err.Error())
  4482. return err.Error()
  4483. }
  4484. reader := bytes.NewReader(bytesData)
  4485. gdyb_url := beego.AppConfig.String("gdyb_url")
  4486. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4487. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4488. //url := gdyb_url + "1101"
  4489. var url string
  4490. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  4491. url = gdyb_url
  4492. } else {
  4493. url = gdyb_url + "1101"
  4494. }
  4495. fmt.Println(url)
  4496. fmt.Println(gdyb_paasid)
  4497. fmt.Println(secret_key)
  4498. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4499. request, err := http.NewRequest("POST", url, reader)
  4500. if err != nil {
  4501. fmt.Println(err.Error())
  4502. return err.Error()
  4503. }
  4504. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4505. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4506. request.Header.Set("x-tif-signature", signature)
  4507. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4508. request.Header.Set("x-tif-nonce", nonce)
  4509. client := http.Client{}
  4510. resp, err := client.Do(request)
  4511. if err != nil {
  4512. fmt.Println(err.Error())
  4513. return err.Error()
  4514. }
  4515. respBytes, err := ioutil.ReadAll(resp.Body)
  4516. if err != nil {
  4517. fmt.Println(err.Error())
  4518. return err.Error()
  4519. }
  4520. fmt.Println(string(respBytes))
  4521. str := string(respBytes)
  4522. return str
  4523. }
  4524. 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 {
  4525. //生成签名
  4526. nonce := GetRandomString(32)
  4527. timestamp := time.Now().Unix()
  4528. signature := setSignature(timestamp, nonce, secret_key)
  4529. //生成输入报文
  4530. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4531. input := make(map[string]interface{})
  4532. inputData := make(map[string]interface{})
  4533. inputMessage["infno"] = "1101" // 交易编码
  4534. if certificates == 3 {
  4535. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  4536. inputData["certno"] = "01836483" // 证件号码
  4537. inputData["psn_cert_type"] = "01" // 人员证件类型
  4538. inputData["mdtrt_cert_no"] = "01836483" // 就诊凭证编号
  4539. } else {
  4540. if certificates == 1 {
  4541. if id_card_type == 1 {
  4542. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  4543. inputData["card_sn"] = "" // 卡识别码
  4544. inputData["certno"] = certNo // 证件号码
  4545. inputData["psn_cert_type"] = "01" // 人员证件类型
  4546. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  4547. } else {
  4548. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  4549. inputData["card_sn"] = "" // 卡识别码
  4550. inputData["certno"] = certNo // 证件号码
  4551. inputData["psn_cert_type"] = "" // 人员证件类型
  4552. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  4553. }
  4554. } else if certificates == 6 {
  4555. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  4556. inputData["card_sn"] = "" // 卡识别码
  4557. inputData["certno"] = certNo // 证件号码
  4558. inputData["psn_cert_type"] = "" // 人员证件类型
  4559. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  4560. }
  4561. }
  4562. inputData["begntime"] = "" // 开始时间
  4563. inputData["psn_name"] = "" // 人员姓名
  4564. input["data"] = inputData
  4565. inputMessage["input"] = input //交易输入
  4566. bytesData, err := json.Marshal(inputMessage)
  4567. fmt.Println(string(bytesData))
  4568. if err != nil {
  4569. fmt.Println(err.Error())
  4570. return err.Error()
  4571. }
  4572. reader := bytes.NewReader(bytesData)
  4573. gdyb_url := beego.AppConfig.String("gdyb_url")
  4574. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4575. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4576. //url := gdyb_url + "1101"
  4577. var url string
  4578. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  4579. url = gdyb_url
  4580. } else {
  4581. url = gdyb_url + "1101"
  4582. }
  4583. fmt.Println(url)
  4584. fmt.Println(gdyb_paasid)
  4585. fmt.Println(secret_key)
  4586. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4587. request, err := http.NewRequest("POST", url, reader)
  4588. if err != nil {
  4589. fmt.Println(err.Error())
  4590. return err.Error()
  4591. }
  4592. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4593. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4594. request.Header.Set("x-tif-signature", signature)
  4595. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4596. request.Header.Set("x-tif-nonce", nonce)
  4597. client := http.Client{}
  4598. resp, err := client.Do(request)
  4599. if err != nil {
  4600. fmt.Println(err.Error())
  4601. return err.Error()
  4602. }
  4603. respBytes, err := ioutil.ReadAll(resp.Body)
  4604. if err != nil {
  4605. fmt.Println(err.Error())
  4606. return err.Error()
  4607. }
  4608. fmt.Println(string(respBytes))
  4609. str := string(respBytes)
  4610. return str
  4611. }
  4612. 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 {
  4613. //生成签名
  4614. nonce := GetRandomString(32)
  4615. timestamp := time.Now().Unix()
  4616. signature := setSignature(timestamp, nonce, secret_key)
  4617. //生成输入报文
  4618. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4619. input := make(map[string]interface{})
  4620. inputData := make(map[string]interface{})
  4621. inputMessage["infno"] = "1101" // 交易编码
  4622. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  4623. inputData["card_sn"] = card_sn // 卡识别码
  4624. inputData["certno"] = certNo // 证件号码
  4625. inputData["psn_cert_type"] = "01" // 人员证件类型
  4626. inputData["mdtrt_cert_no"] = cardNumber // 就诊凭证编号
  4627. inputData["begntime"] = "" // 开始时间
  4628. inputData["psn_name"] = name // 人员姓名
  4629. input["data"] = inputData
  4630. inputMessage["input"] = input //交易输入
  4631. bytesData, err := json.Marshal(inputMessage)
  4632. fmt.Println(string(bytesData))
  4633. if err != nil {
  4634. fmt.Println(err.Error())
  4635. return err.Error()
  4636. }
  4637. reader := bytes.NewReader(bytesData)
  4638. gdyb_url := beego.AppConfig.String("gdyb_url")
  4639. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4640. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4641. //url := gdyb_url + "1101"
  4642. var url string
  4643. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  4644. url = gdyb_url
  4645. } else {
  4646. url = gdyb_url + "1101"
  4647. }
  4648. fmt.Println(url)
  4649. fmt.Println(gdyb_paasid)
  4650. fmt.Println(secret_key)
  4651. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4652. request, err := http.NewRequest("POST", url, reader)
  4653. if err != nil {
  4654. fmt.Println(err.Error())
  4655. return err.Error()
  4656. }
  4657. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4658. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4659. request.Header.Set("x-tif-signature", signature)
  4660. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4661. request.Header.Set("x-tif-nonce", nonce)
  4662. client := http.Client{}
  4663. resp, err := client.Do(request)
  4664. if err != nil {
  4665. fmt.Println(err.Error())
  4666. return err.Error()
  4667. }
  4668. respBytes, err := ioutil.ReadAll(resp.Body)
  4669. if err != nil {
  4670. fmt.Println(err.Error())
  4671. return err.Error()
  4672. }
  4673. fmt.Println(string(respBytes))
  4674. str := string(respBytes)
  4675. return str
  4676. }
  4677. 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) {
  4678. //生成签名
  4679. nonce := GetRandomString(32)
  4680. timestamp := time.Now().Unix()
  4681. signature := setSignature(timestamp, nonce, secret_key)
  4682. //生成输入报文
  4683. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4684. input := make(map[string]interface{})
  4685. inputData := make(map[string]interface{})
  4686. inputMessage["infno"] = "1101" // 交易编码
  4687. if certificates == 6 {
  4688. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  4689. inputData["psn_cert_type"] = "" // 人员证件类型
  4690. } else {
  4691. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  4692. inputData["psn_cert_type"] = "01" // 人员证件类型
  4693. }
  4694. inputData["card_sn"] = "" // 卡识别码
  4695. inputData["certno"] = idNo // 证件号码
  4696. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  4697. inputData["begntime"] = "" // 开始时间
  4698. inputData["psn_name"] = user_name // 人员姓名
  4699. input["data"] = inputData
  4700. inputMessage["input"] = input //交易输入
  4701. bytesData, err := json.Marshal(inputMessage)
  4702. fmt.Println(string(bytesData))
  4703. if err != nil {
  4704. fmt.Println(err.Error())
  4705. return err.Error(), ""
  4706. }
  4707. reader := bytes.NewReader(bytesData)
  4708. gdyb_url := beego.AppConfig.String("gdyb_url")
  4709. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4710. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4711. //url := gdyb_url + "1101"
  4712. var url string
  4713. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  4714. url = gdyb_url
  4715. } else {
  4716. url = gdyb_url + "1101"
  4717. }
  4718. fmt.Println(url)
  4719. fmt.Println(gdyb_paasid)
  4720. fmt.Println(secret_key)
  4721. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4722. request, err := http.NewRequest("POST", url, reader)
  4723. if err != nil {
  4724. fmt.Println(err.Error())
  4725. return err.Error(), ""
  4726. }
  4727. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4728. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4729. request.Header.Set("x-tif-signature", signature)
  4730. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4731. request.Header.Set("x-tif-nonce", nonce)
  4732. client := http.Client{}
  4733. resp, err := client.Do(request)
  4734. if err != nil {
  4735. fmt.Println(err.Error())
  4736. return err.Error(), ""
  4737. }
  4738. respBytes, err := ioutil.ReadAll(resp.Body)
  4739. if err != nil {
  4740. fmt.Println(err.Error())
  4741. return err.Error(), ""
  4742. }
  4743. fmt.Println(string(respBytes))
  4744. str := string(respBytes)
  4745. return str, string(bytesData)
  4746. }
  4747. 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) {
  4748. //生成签名
  4749. nonce := GetRandomString(32)
  4750. timestamp := time.Now().Unix()
  4751. signature := setSignature(timestamp, nonce, secret_key)
  4752. //生成输入报文
  4753. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4754. input := make(map[string]interface{})
  4755. inputData := make(map[string]interface{})
  4756. inputMessage["infno"] = "1101" // 交易编码
  4757. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  4758. inputData["psn_cert_type"] = "01" // 人员证件类型
  4759. inputData["card_sn"] = "" // 卡识别码
  4760. inputData["certno"] = idNo // 证件号码
  4761. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  4762. inputData["begntime"] = "" // 开始时间
  4763. inputData["psn_name"] = user_name // 人员姓名
  4764. input["data"] = inputData
  4765. inputMessage["input"] = input //交易输入
  4766. bytesData, err := json.Marshal(inputMessage)
  4767. fmt.Println(string(bytesData))
  4768. if err != nil {
  4769. fmt.Println(err.Error())
  4770. return err.Error(), ""
  4771. }
  4772. reader := bytes.NewReader(bytesData)
  4773. gdyb_url := beego.AppConfig.String("gdyb_url")
  4774. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4775. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4776. //url := gdyb_url + "1101"
  4777. var url string
  4778. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  4779. url = gdyb_url
  4780. } else {
  4781. url = gdyb_url + "1101"
  4782. }
  4783. fmt.Println(url)
  4784. fmt.Println(gdyb_paasid)
  4785. fmt.Println(secret_key)
  4786. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4787. request, err := http.NewRequest("POST", url, reader)
  4788. if err != nil {
  4789. fmt.Println(err.Error())
  4790. return err.Error(), ""
  4791. }
  4792. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4793. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4794. request.Header.Set("x-tif-signature", signature)
  4795. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4796. request.Header.Set("x-tif-nonce", nonce)
  4797. client := http.Client{}
  4798. resp, err := client.Do(request)
  4799. if err != nil {
  4800. fmt.Println(err.Error())
  4801. return err.Error(), ""
  4802. }
  4803. respBytes, err := ioutil.ReadAll(resp.Body)
  4804. if err != nil {
  4805. fmt.Println(err.Error())
  4806. return err.Error(), ""
  4807. }
  4808. fmt.Println(string(respBytes))
  4809. str := string(respBytes)
  4810. return str, string(bytesData)
  4811. }
  4812. 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) {
  4813. //生成签名
  4814. nonce := GetRandomString(32)
  4815. timestamp := time.Now().Unix()
  4816. signature := setSignature(timestamp, nonce, secret_key)
  4817. //生成输入报文
  4818. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4819. input := make(map[string]interface{})
  4820. inputData := make(map[string]interface{})
  4821. inputMessage["infno"] = "1101" // 交易编码
  4822. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  4823. inputData["card_sn"] = "" // 卡识别码
  4824. inputData["certno"] = idNo // 证件号码
  4825. inputData["psn_cert_type"] = "01" // 人员证件类型
  4826. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  4827. inputData["begntime"] = "" // 开始时间
  4828. inputData["psn_name"] = user_name // 人员姓名
  4829. input["data"] = inputData
  4830. inputMessage["input"] = input //交易输入
  4831. bytesData, err := json.Marshal(inputMessage)
  4832. fmt.Println(string(bytesData))
  4833. if err != nil {
  4834. fmt.Println(err.Error())
  4835. return err.Error(), ""
  4836. }
  4837. reader := bytes.NewReader(bytesData)
  4838. gdyb_url := beego.AppConfig.String("gdyb_url")
  4839. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4840. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4841. //url := gdyb_url + "1101"
  4842. var url string
  4843. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  4844. url = gdyb_url
  4845. } else {
  4846. url = gdyb_url + "1101"
  4847. }
  4848. fmt.Println(url)
  4849. fmt.Println(gdyb_paasid)
  4850. fmt.Println(secret_key)
  4851. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4852. request, err := http.NewRequest("POST", url, reader)
  4853. if err != nil {
  4854. fmt.Println(err.Error())
  4855. return err.Error(), ""
  4856. }
  4857. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4858. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4859. request.Header.Set("x-tif-signature", signature)
  4860. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4861. request.Header.Set("x-tif-nonce", nonce)
  4862. client := http.Client{}
  4863. resp, err := client.Do(request)
  4864. if err != nil {
  4865. fmt.Println(err.Error())
  4866. return err.Error(), ""
  4867. }
  4868. respBytes, err := ioutil.ReadAll(resp.Body)
  4869. if err != nil {
  4870. fmt.Println(err.Error())
  4871. return err.Error(), ""
  4872. }
  4873. fmt.Println(string(respBytes))
  4874. str := string(respBytes)
  4875. return str, string(bytesData)
  4876. }
  4877. func Gdyb6101(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) (string, string) {
  4878. //生成签名
  4879. nonce := GetRandomString(32)
  4880. timestamp := time.Now().Unix()
  4881. signature := setSignature(timestamp, nonce, secret_key)
  4882. //生成输入报文
  4883. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4884. input := make(map[string]interface{})
  4885. inputData := make(map[string]interface{})
  4886. inputMessage["infno"] = "6101" // 交易编码
  4887. inputData["orgId"] = fixmedins_code // 就诊凭证类型
  4888. inputData["businessType"] = "01101" // 卡识别码
  4889. inputData["businessInfo"] = "" // 证件号码
  4890. inputData["operateorId"] = "01" // 人员证件类型
  4891. inputData["operateornName"] = doctor // 就诊凭证编号
  4892. inputData["officeId"] = "01" // 开始时间
  4893. inputData["officeName"] = "血透" // 人员姓名
  4894. inputData["deviceType"] = "" // 人员姓名
  4895. input["InData"] = inputData
  4896. inputMessage["input"] = input //交易输入
  4897. bytesData, err := json.Marshal(inputMessage)
  4898. fmt.Println(string(bytesData))
  4899. if err != nil {
  4900. fmt.Println(err.Error())
  4901. return err.Error(), ""
  4902. }
  4903. reader := bytes.NewReader(bytesData)
  4904. gdyb_url := beego.AppConfig.String("gdyb_url")
  4905. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4906. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4907. //url := gdyb_url + "1101"
  4908. var url string
  4909. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450127" {
  4910. url = gdyb_url
  4911. } else {
  4912. url = gdyb_url + "1101"
  4913. }
  4914. fmt.Println(url)
  4915. fmt.Println(gdyb_paasid)
  4916. fmt.Println(secret_key)
  4917. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4918. request, err := http.NewRequest("POST", url, reader)
  4919. if err != nil {
  4920. fmt.Println(err.Error())
  4921. return err.Error(), ""
  4922. }
  4923. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4924. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4925. request.Header.Set("x-tif-signature", signature)
  4926. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4927. request.Header.Set("x-tif-nonce", nonce)
  4928. client := http.Client{}
  4929. resp, err := client.Do(request)
  4930. if err != nil {
  4931. fmt.Println(err.Error())
  4932. return err.Error(), ""
  4933. }
  4934. respBytes, err := ioutil.ReadAll(resp.Body)
  4935. if err != nil {
  4936. fmt.Println(err.Error())
  4937. return err.Error(), ""
  4938. }
  4939. fmt.Println(string(respBytes))
  4940. str := string(respBytes)
  4941. return str, string(bytesData)
  4942. }
  4943. // 人员信息版本4
  4944. 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) {
  4945. //生成签名
  4946. nonce := GetRandomString(32)
  4947. timestamp := time.Now().Unix()
  4948. //signature := setSignature(timestamp, nonce, secret_key)
  4949. //生成输入报文
  4950. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4951. input := make(map[string]interface{})
  4952. inputData := make(map[string]interface{})
  4953. inputMessage["infno"] = "1101" // 交易编码
  4954. if certificates == 3 {
  4955. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  4956. inputData["certno"] = certNo // 证件号码
  4957. inputData["psn_cert_type"] = "99" // 人员证件类型
  4958. } else {
  4959. if id_card_type == 1 {
  4960. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  4961. inputData["card_sn"] = "" // 卡识别码
  4962. inputData["certno"] = "" // 证件号码
  4963. inputData["psn_cert_type"] = "" // 人员证件类型
  4964. } else {
  4965. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  4966. inputData["card_sn"] = "" // 卡识别码
  4967. inputData["certno"] = certNo // 证件号码
  4968. inputData["psn_cert_type"] = "1" // 人员证件类型
  4969. }
  4970. }
  4971. inputData["mdtrt_cert_no"] = "" // 就诊凭证编号
  4972. inputData["begntime"] = "" // 开始时间
  4973. inputData["psn_name"] = "" // 人员姓名
  4974. input["data"] = inputData
  4975. inputMessage["input"] = input //交易输入
  4976. bytesData, err := json.Marshal(inputMessage)
  4977. fmt.Println(string(bytesData))
  4978. if err != nil {
  4979. fmt.Println(err.Error())
  4980. return err.Error(), ""
  4981. }
  4982. var json2 string
  4983. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  4984. out, err := cmd.Output()
  4985. if err != nil {
  4986. fmt.Println("error:", err.Error())
  4987. }
  4988. fmt.Println(string(out))
  4989. return string(out), string(bytesData)
  4990. }
  4991. func StrPtr(s string) uintptr {
  4992. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  4993. }
  4994. 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 {
  4995. //生成签名
  4996. nonce := GetRandomString(32)
  4997. timestamp := time.Now().Unix()
  4998. signature := setSignature(timestamp, nonce, secret_key)
  4999. //生成输入报文
  5000. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  5001. input := make(map[string]interface{})
  5002. inputData := make(map[string]interface{})
  5003. inputMessage["infno"] = "90991" // 交易编码
  5004. inputData["fixmedins_code"] = fixmedins_code // 就诊凭证编号
  5005. inputData["psn_no"] = psn_no // 开始时间
  5006. inputData["card_pwd"] = pwd // 人员姓名
  5007. inputData["sscno"] = card_number // 人员姓名
  5008. input["data"] = inputData
  5009. inputMessage["input"] = input //交易输入
  5010. bytesData, err := json.Marshal(inputMessage)
  5011. fmt.Println(string(bytesData))
  5012. if err != nil {
  5013. fmt.Println(err.Error())
  5014. return err.Error()
  5015. }
  5016. reader := bytes.NewReader(bytesData)
  5017. gdyb_url := beego.AppConfig.String("gdyb_url")
  5018. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5019. url := gdyb_url + "90991"
  5020. request, err := http.NewRequest("POST", url, reader)
  5021. if err != nil {
  5022. fmt.Println(err.Error())
  5023. return err.Error()
  5024. }
  5025. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5026. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5027. request.Header.Set("x-tif-signature", signature)
  5028. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5029. request.Header.Set("x-tif-nonce", nonce)
  5030. client := http.Client{}
  5031. resp, err := client.Do(request)
  5032. if err != nil {
  5033. fmt.Println(err.Error())
  5034. return err.Error()
  5035. }
  5036. respBytes, err := ioutil.ReadAll(resp.Body)
  5037. if err != nil {
  5038. fmt.Println(err.Error())
  5039. return err.Error()
  5040. }
  5041. fmt.Println(string(respBytes))
  5042. str := string(respBytes)
  5043. return str
  5044. }
  5045. func Gdyb90100(psn_no string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  5046. //生成签名
  5047. nonce := GetRandomString(32)
  5048. timestamp := time.Now().Unix()
  5049. signature := setSignature(timestamp, nonce, secret_key)
  5050. //生成输入报文
  5051. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  5052. input := make(map[string]interface{})
  5053. inputData := make(map[string]interface{})
  5054. inputMessage["infno"] = "90100" // 交易编码
  5055. inputData["psn_no"] = psn_no // 开始时间
  5056. input["data"] = inputData
  5057. inputMessage["input"] = input //交易输入
  5058. bytesData, err := json.Marshal(inputMessage)
  5059. fmt.Println(string(bytesData))
  5060. if err != nil {
  5061. fmt.Println(err.Error())
  5062. return err.Error()
  5063. }
  5064. reader := bytes.NewReader(bytesData)
  5065. gdyb_url := beego.AppConfig.String("gdyb_url")
  5066. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5067. url := gdyb_url + "90100"
  5068. request, err := http.NewRequest("POST", url, reader)
  5069. if err != nil {
  5070. fmt.Println(err.Error())
  5071. return err.Error()
  5072. }
  5073. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5074. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5075. request.Header.Set("x-tif-signature", signature)
  5076. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5077. request.Header.Set("x-tif-nonce", nonce)
  5078. client := http.Client{}
  5079. resp, err := client.Do(request)
  5080. if err != nil {
  5081. fmt.Println(err.Error())
  5082. return err.Error()
  5083. }
  5084. respBytes, err := ioutil.ReadAll(resp.Body)
  5085. if err != nil {
  5086. fmt.Println(err.Error())
  5087. return err.Error()
  5088. }
  5089. fmt.Println(string(respBytes))
  5090. str := string(respBytes)
  5091. return str
  5092. }
  5093. 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) {
  5094. //生成签名
  5095. nonce := GetRandomString(32)
  5096. timestamp := time.Now().Unix()
  5097. signature := setSignature(timestamp, nonce, secret_key)
  5098. //生成输入报文
  5099. inputMessage := SetInputMessageTwo(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, sign)
  5100. input := make(map[string]interface{})
  5101. inputData := make(map[string]interface{})
  5102. inputMessage["infno"] = "3260" // 交易编码
  5103. inputData["sign"] = sign // 就诊凭证编号
  5104. inputData["trt_year"] = year // 就诊凭证编号
  5105. inputData["trt_month"] = month // 开始时间
  5106. inputData["startrow"] = count // 人员姓名
  5107. input["data"] = inputData
  5108. inputMessage["input"] = input //交易输入
  5109. var inputLog string
  5110. bytesData, err := json.Marshal(inputMessage)
  5111. inputLog = string(bytesData)
  5112. fmt.Println(string(bytesData))
  5113. if err != nil {
  5114. fmt.Println(err.Error())
  5115. return err.Error(), ""
  5116. }
  5117. reader := bytes.NewReader(bytesData)
  5118. gdyb_url := beego.AppConfig.String("gdyb_url")
  5119. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5120. var url string
  5121. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5122. url = gdyb_url
  5123. } else {
  5124. url = gdyb_url + "3260"
  5125. }
  5126. {
  5127. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  5128. request, err := http.NewRequest("POST", url, reader)
  5129. if err != nil {
  5130. fmt.Println(err.Error())
  5131. return err.Error(), ""
  5132. }
  5133. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5134. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5135. request.Header.Set("x-tif-signature", signature)
  5136. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5137. request.Header.Set("x-tif-nonce", nonce)
  5138. client := http.Client{}
  5139. resp, err := client.Do(request)
  5140. if err != nil {
  5141. fmt.Println(err.Error())
  5142. return err.Error(), ""
  5143. }
  5144. respBytes, err := ioutil.ReadAll(resp.Body)
  5145. if err != nil {
  5146. fmt.Println(err.Error())
  5147. return err.Error(), ""
  5148. }
  5149. fmt.Println(string(respBytes))
  5150. str := string(respBytes)
  5151. return str, inputLog
  5152. }
  5153. }
  5154. 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) {
  5155. //msg_month := time.Unix(1557042972, 0).Format("1")
  5156. //msg_year := time.Now().Format("2006")
  5157. //msg_month = time.Now().Format("01")
  5158. //day := time.Now().Format("02")
  5159. //
  5160. //hour := time.Now().Format("15")
  5161. //min := time.Now().Format("04")
  5162. //sec := time.Now().Format("05")
  5163. //
  5164. //msec := time.Now().Format("000")
  5165. //msg_id := fixmedins_code + msg_year + msg_month + day + hour + min + sec + msec + "0"
  5166. feedetail := make([]map[string]interface{}, 0)
  5167. for _, subitem := range result3260 {
  5168. for _, item := range subitem.Output.Data {
  5169. if item.MdtrtId != "out20230406681871" && item.MdtrtId != "out20230406681868" {
  5170. feedetailInfo := make(map[string]interface{})
  5171. feedetailInfo["certno"] = item.Certno
  5172. feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5173. feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5174. feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5175. feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5176. feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5177. feedetailInfo["cnfm_flag"] = "1" // 处方号
  5178. feedetail = append(feedetail, feedetailInfo)
  5179. }
  5180. }
  5181. }
  5182. for _, subitem := range result3260 {
  5183. for _, item := range subitem.Output.Data {
  5184. if item.MdtrtId == "out20230406681871" {
  5185. feedetailInfo := make(map[string]interface{})
  5186. feedetailInfo["certno"] = item.Certno
  5187. feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5188. feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5189. feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5190. feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5191. feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5192. feedetailInfo["cnfm_flag"] = "0" // 处方号
  5193. feedetail = append(feedetail, feedetailInfo)
  5194. }
  5195. }
  5196. }
  5197. for _, subitem := range result3260 {
  5198. for _, item := range subitem.Output.Data {
  5199. if item.MdtrtId == "out20230406681868" {
  5200. feedetailInfo := make(map[string]interface{})
  5201. feedetailInfo["certno"] = item.Certno
  5202. feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5203. feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5204. feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5205. feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5206. feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5207. feedetailInfo["cnfm_flag"] = "0" // 处方号
  5208. feedetail = append(feedetail, feedetailInfo)
  5209. }
  5210. }
  5211. }
  5212. // 分页操作
  5213. pageSize := 100
  5214. pages := paginate(feedetail, pageSize)
  5215. //aa := 0
  5216. // 输出每一页的数据
  5217. for _, page := range pages {
  5218. nonce := GetRandomString(32)
  5219. timestamp := time.Now().Unix()
  5220. signature := setSignature(timestamp, nonce, secret_key)
  5221. //生成输入报文
  5222. //aa = aa + len(page)
  5223. //nonce := GetRandomString(32)
  5224. //timestamp := time.Now().Unix()
  5225. inputMessage := SetInputMessageTwo(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, sign_no)
  5226. input := make(map[string]interface{})
  5227. inputData := make(map[string]interface{})
  5228. inputMessage["infno"] = "3261" // 交易编码
  5229. inputData["trt_year"] = year // 就诊凭证编号
  5230. inputData["trt_month"] = month // 开始时间
  5231. inputData["totalrow"] = len(feedetail) // 人员姓名
  5232. input["data"] = inputData
  5233. input["detail"] = page
  5234. inputMessage["input"] = input //交易输入
  5235. //var inputLog string
  5236. bytesData, err := json.Marshal(inputMessage)
  5237. //inputLog = string(bytesData)
  5238. fmt.Println(string(bytesData))
  5239. if err != nil {
  5240. fmt.Println(err.Error())
  5241. return
  5242. }
  5243. reader := bytes.NewReader(bytesData)
  5244. gdyb_url := beego.AppConfig.String("gdyb_url")
  5245. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5246. var url string
  5247. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5248. url = gdyb_url
  5249. } else {
  5250. url = gdyb_url + "3261"
  5251. }
  5252. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  5253. request, err := http.NewRequest("POST", url, reader)
  5254. if err != nil {
  5255. fmt.Println(err.Error())
  5256. return
  5257. }
  5258. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5259. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5260. request.Header.Set("x-tif-signature", signature)
  5261. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5262. request.Header.Set("x-tif-nonce", nonce)
  5263. client := http.Client{}
  5264. resp, err := client.Do(request)
  5265. if err != nil {
  5266. fmt.Println(err.Error())
  5267. return
  5268. }
  5269. respBytes, err := ioutil.ReadAll(resp.Body)
  5270. if err != nil {
  5271. fmt.Println(err.Error())
  5272. return
  5273. }
  5274. fmt.Println(string(respBytes))
  5275. str := string(respBytes)
  5276. fmt.Println(str)
  5277. }
  5278. //for _, item := range result3260.Output.Data[start-1 : stop] {
  5279. // if item.MdtrtId != "out20230406681871" && item.MdtrtId != "out20230406681868" {
  5280. // feedetailInfo := make(map[string]interface{})
  5281. // feedetailInfo["certno"] = item.Certno
  5282. // feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5283. // feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5284. // feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5285. // feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5286. // feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5287. // feedetailInfo["cnfm_flag"] = "1" // 处方号
  5288. // feedetail = append(feedetail, feedetailInfo)
  5289. // }
  5290. //}
  5291. //for _, item := range result3260.Output.Data[start-1 : stop] {
  5292. // if item.MdtrtId == "out20230406681871" {
  5293. // feedetailInfo := make(map[string]interface{})
  5294. // feedetailInfo["certno"] = item.Certno
  5295. // feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5296. // feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5297. // feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5298. // feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5299. // feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5300. // feedetailInfo["cnfm_flag"] = "0" // 处方号
  5301. // feedetail = append(feedetail, feedetailInfo)
  5302. // }
  5303. //
  5304. //}
  5305. //for _, item := range result3260.Output.Data[start-1 : stop] {
  5306. // if item.MdtrtId == "out20230406681868" {
  5307. // feedetailInfo := make(map[string]interface{})
  5308. // feedetailInfo["certno"] = item.Certno
  5309. // feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5310. // feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5311. // feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5312. // feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5313. // feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5314. // feedetailInfo["cnfm_flag"] = "0" // 处方号
  5315. // feedetail = append(feedetail, feedetailInfo)
  5316. // }
  5317. //
  5318. //}
  5319. return
  5320. }
  5321. 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) {
  5322. //msg_month := time.Unix(1557042972, 0).Format("1")
  5323. //msg_year := time.Now().Format("2006")
  5324. //msg_month = time.Now().Format("01")
  5325. //day := time.Now().Format("02")
  5326. //
  5327. //hour := time.Now().Format("15")
  5328. //min := time.Now().Format("04")
  5329. //sec := time.Now().Format("05")
  5330. //
  5331. //msec := time.Now().Format("000")
  5332. //msg_id := fixmedins_code + msg_year + msg_month + day + hour + min + sec + msec + "0"
  5333. feedetail := make([]map[string]interface{}, 0)
  5334. for _, subitem := range result3260 {
  5335. for _, item := range subitem.Output.Data {
  5336. if item.MdtrtId != "out20230406681871" && item.MdtrtId != "out20230406681868" {
  5337. feedetailInfo := make(map[string]interface{})
  5338. feedetailInfo["certno"] = item.Certno
  5339. feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5340. feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5341. feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5342. feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5343. feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5344. feedetailInfo["cnfm_flag"] = "1" // 处方号
  5345. feedetail = append(feedetail, feedetailInfo)
  5346. }
  5347. }
  5348. }
  5349. for _, subitem := range result3260 {
  5350. for _, item := range subitem.Output.Data {
  5351. if item.MdtrtId == "out20230406681871" {
  5352. feedetailInfo := make(map[string]interface{})
  5353. feedetailInfo["certno"] = item.Certno
  5354. feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5355. feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5356. feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5357. feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5358. feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5359. feedetailInfo["cnfm_flag"] = "0" // 处方号
  5360. feedetail = append(feedetail, feedetailInfo)
  5361. }
  5362. }
  5363. }
  5364. for _, subitem := range result3260 {
  5365. for _, item := range subitem.Output.Data {
  5366. if item.MdtrtId == "out20230406681868" {
  5367. feedetailInfo := make(map[string]interface{})
  5368. feedetailInfo["certno"] = item.Certno
  5369. feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5370. feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5371. feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5372. feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5373. feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5374. feedetailInfo["cnfm_flag"] = "0" // 处方号
  5375. feedetail = append(feedetail, feedetailInfo)
  5376. }
  5377. }
  5378. }
  5379. var firstSlice, secondSlice []map[string]interface{}
  5380. if len(feedetail) > 500 {
  5381. firstSlice = feedetail[:500]
  5382. secondSlice = feedetail[500:]
  5383. } else {
  5384. firstSlice = feedetail
  5385. secondSlice = []map[string]interface{}{}
  5386. }
  5387. fmt.Println(firstSlice)
  5388. nonce := GetRandomString(32)
  5389. timestamp := time.Now().Unix()
  5390. signature := setSignature(timestamp, nonce, secret_key)
  5391. //生成输入报文
  5392. total := 0
  5393. for _, item := range result3260 {
  5394. total = total + len(item.Output.Data)
  5395. }
  5396. //nonce := GetRandomString(32)
  5397. //timestamp := time.Now().Unix()
  5398. inputMessage := SetInputMessageTwo(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, sign_no)
  5399. input := make(map[string]interface{})
  5400. inputData := make(map[string]interface{})
  5401. inputMessage["infno"] = "3261" // 交易编码
  5402. inputData["trt_year"] = year // 就诊凭证编号
  5403. inputData["trt_month"] = month // 开始时间
  5404. inputData["totalrow"] = len(secondSlice) // 人员姓名
  5405. input["data"] = inputData
  5406. input["detail"] = secondSlice
  5407. inputMessage["input"] = input //交易输入
  5408. //var inputLog string
  5409. bytesData, err := json.Marshal(inputMessage)
  5410. //inputLog = string(bytesData)
  5411. fmt.Println(string(bytesData))
  5412. if err != nil {
  5413. fmt.Println(err.Error())
  5414. return
  5415. }
  5416. reader := bytes.NewReader(bytesData)
  5417. gdyb_url := beego.AppConfig.String("gdyb_url")
  5418. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5419. var url string
  5420. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5421. url = gdyb_url
  5422. } else {
  5423. url = gdyb_url + "3261"
  5424. }
  5425. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  5426. request, err := http.NewRequest("POST", url, reader)
  5427. if err != nil {
  5428. fmt.Println(err.Error())
  5429. return
  5430. }
  5431. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5432. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5433. request.Header.Set("x-tif-signature", signature)
  5434. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5435. request.Header.Set("x-tif-nonce", nonce)
  5436. client := http.Client{}
  5437. resp, err := client.Do(request)
  5438. if err != nil {
  5439. fmt.Println(err.Error())
  5440. return
  5441. }
  5442. respBytes, err := ioutil.ReadAll(resp.Body)
  5443. if err != nil {
  5444. fmt.Println(err.Error())
  5445. return
  5446. }
  5447. fmt.Println(string(respBytes))
  5448. str := string(respBytes)
  5449. fmt.Println(str)
  5450. //for _, item := range result3260.Output.Data[start-1 : stop] {
  5451. // if item.MdtrtId != "out20230406681871" && item.MdtrtId != "out20230406681868" {
  5452. // feedetailInfo := make(map[string]interface{})
  5453. // feedetailInfo["certno"] = item.Certno
  5454. // feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5455. // feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5456. // feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5457. // feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5458. // feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5459. // feedetailInfo["cnfm_flag"] = "1" // 处方号
  5460. // feedetail = append(feedetail, feedetailInfo)
  5461. // }
  5462. //}
  5463. //for _, item := range result3260.Output.Data[start-1 : stop] {
  5464. // if item.MdtrtId == "out20230406681871" {
  5465. // feedetailInfo := make(map[string]interface{})
  5466. // feedetailInfo["certno"] = item.Certno
  5467. // feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5468. // feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5469. // feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5470. // feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5471. // feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5472. // feedetailInfo["cnfm_flag"] = "0" // 处方号
  5473. // feedetail = append(feedetail, feedetailInfo)
  5474. // }
  5475. //
  5476. //}
  5477. //for _, item := range result3260.Output.Data[start-1 : stop] {
  5478. // if item.MdtrtId == "out20230406681868" {
  5479. // feedetailInfo := make(map[string]interface{})
  5480. // feedetailInfo["certno"] = item.Certno
  5481. // feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5482. // feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5483. // feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5484. // feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5485. // feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5486. // feedetailInfo["cnfm_flag"] = "0" // 处方号
  5487. // feedetail = append(feedetail, feedetailInfo)
  5488. // }
  5489. //
  5490. //}
  5491. return
  5492. }
  5493. 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) {
  5494. //生成签名
  5495. nonce := GetRandomString(32)
  5496. timestamp := time.Now().Unix()
  5497. signature := setSignature(timestamp, nonce, secret_key)
  5498. //生成输入报文
  5499. inputMessage := SetInputMessageTwo(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, sign_no)
  5500. input := make(map[string]interface{})
  5501. inputData := make(map[string]interface{})
  5502. inputMessage["infno"] = "3262" // 交易编码
  5503. inputData["trt_year"] = year // 就诊凭证编号
  5504. inputData["trt_month"] = month // 开始时间
  5505. inputData["otransid"] = "0" // 开始时间
  5506. input["data"] = inputData
  5507. inputMessage["input"] = input //交易输入
  5508. var inputLog string
  5509. bytesData, err := json.Marshal(inputMessage)
  5510. inputLog = string(bytesData)
  5511. fmt.Println(string(bytesData))
  5512. if err != nil {
  5513. fmt.Println(err.Error())
  5514. return err.Error(), ""
  5515. }
  5516. reader := bytes.NewReader(bytesData)
  5517. gdyb_url := beego.AppConfig.String("gdyb_url")
  5518. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5519. var url string
  5520. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5521. url = gdyb_url
  5522. } else {
  5523. url = gdyb_url + "3262"
  5524. }
  5525. {
  5526. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  5527. request, err := http.NewRequest("POST", url, reader)
  5528. if err != nil {
  5529. fmt.Println(err.Error())
  5530. return err.Error(), ""
  5531. }
  5532. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5533. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5534. request.Header.Set("x-tif-signature", signature)
  5535. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5536. request.Header.Set("x-tif-nonce", nonce)
  5537. client := http.Client{}
  5538. resp, err := client.Do(request)
  5539. if err != nil {
  5540. fmt.Println(err.Error())
  5541. return err.Error(), ""
  5542. }
  5543. respBytes, err := ioutil.ReadAll(resp.Body)
  5544. if err != nil {
  5545. fmt.Println(err.Error())
  5546. return err.Error(), ""
  5547. }
  5548. fmt.Println(string(respBytes))
  5549. str := string(respBytes)
  5550. return str, inputLog
  5551. }
  5552. }
  5553. 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) {
  5554. //生成签名
  5555. nonce := GetRandomString(32)
  5556. timestamp := time.Now().Unix()
  5557. signature := setSignature(timestamp, nonce, "d6Ad0P1B3z6Dsdst0gYAFPlz8YlIvFDx")
  5558. inputMessage := make(map[string]interface{})
  5559. //生成输入报文
  5560. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5561. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  5562. } else {
  5563. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  5564. }
  5565. input := make(map[string]interface{})
  5566. inputData := make(map[string]interface{})
  5567. inputMessage["infno"] = "9001" // 交易编码
  5568. inputData["opter_no"] = admin_user_id // 就诊凭证编号
  5569. inputData["mac"] = "11-11-11-11-11" // 开始时间
  5570. inputData["ip"] = "11.11.11.11"
  5571. //inputData["userid"] = "H44010400081"
  5572. //month := time.Unix(1557042972, 0).Format("1")
  5573. //year := time.Now().Format("2006")
  5574. //month = time.Now().Format("01")
  5575. //day := time.Now().Format("02")
  5576. //hour := time.Now().Format("15")
  5577. //min := time.Now().Format("04")
  5578. //sec := time.Now().Format("05")
  5579. //custom_time := year + month + day + hour + min + sec
  5580. //inputData["currenttime"] = custom_time
  5581. //var psd string
  5582. //psd = custom_time + "Gzyb$867"
  5583. //h := md5.New()
  5584. //h.Write([]byte(psd))
  5585. //inputData["password"] = strings.ToUpper(hex.EncodeToString(h.Sum(nil)))
  5586. input["data"] = inputData
  5587. inputMessage["input"] = input //交易输入
  5588. var inputLog string
  5589. bytesData, err := json.Marshal(inputMessage)
  5590. inputLog = string(bytesData)
  5591. fmt.Println(string(bytesData))
  5592. if err != nil {
  5593. fmt.Println(err.Error())
  5594. return err.Error(), ""
  5595. }
  5596. reader := bytes.NewReader(bytesData)
  5597. gdyb_url := beego.AppConfig.String("gdyb_url")
  5598. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5599. var url string
  5600. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5601. url = gdyb_url
  5602. } else {
  5603. url = gdyb_url + "9001"
  5604. }
  5605. {
  5606. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  5607. request, err := http.NewRequest("POST", url, reader)
  5608. if err != nil {
  5609. fmt.Println(err.Error())
  5610. return err.Error(), ""
  5611. }
  5612. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5613. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5614. request.Header.Set("x-tif-signature", signature)
  5615. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5616. request.Header.Set("x-tif-nonce", nonce)
  5617. fmt.Println(string(bytesData))
  5618. fmt.Println(gdyb_url)
  5619. fmt.Println(gdyb_paasid)
  5620. fmt.Println(request.Header)
  5621. client := http.Client{}
  5622. resp, err := client.Do(request)
  5623. if err != nil {
  5624. fmt.Println(err.Error())
  5625. return err.Error(), ""
  5626. }
  5627. respBytes, err := ioutil.ReadAll(resp.Body)
  5628. if err != nil {
  5629. fmt.Println(err.Error())
  5630. return err.Error(), ""
  5631. }
  5632. fmt.Println(string(respBytes))
  5633. str := string(respBytes)
  5634. return str, inputLog
  5635. }
  5636. }
  5637. 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) {
  5638. //生成签名
  5639. nonce := GetRandomString(32)
  5640. timestamp := time.Now().Unix()
  5641. signature := setSignature(timestamp, nonce, secret_key)
  5642. inputMessage := make(map[string]interface{})
  5643. //生成输入报文
  5644. //生成输入报文
  5645. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5646. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  5647. } else {
  5648. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  5649. }
  5650. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  5651. input := make(map[string]interface{})
  5652. inputData := make(map[string]interface{})
  5653. inputMessage["infno"] = "9001" // 交易编码
  5654. inputData["opter_no"] = admin_user_id // 就诊凭证编号
  5655. inputData["mac"] = GetMac() // 开始时间
  5656. inputData["ip"] = GetLocalIp()
  5657. input["signIn"] = inputData
  5658. inputMessage["input"] = input //交易输入
  5659. var inputLog string
  5660. bytesData, err := json.Marshal(inputMessage)
  5661. inputLog = string(bytesData)
  5662. fmt.Println(string(bytesData))
  5663. if err != nil {
  5664. fmt.Println(err.Error())
  5665. return err.Error(), ""
  5666. }
  5667. reader := bytes.NewReader(bytesData)
  5668. gdyb_url := beego.AppConfig.String("gdyb_url")
  5669. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5670. var url string
  5671. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5672. url = gdyb_url
  5673. } else {
  5674. url = gdyb_url + "9001"
  5675. }
  5676. {
  5677. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  5678. request, err := http.NewRequest("POST", url, reader)
  5679. if err != nil {
  5680. fmt.Println(err.Error())
  5681. return err.Error(), ""
  5682. }
  5683. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5684. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5685. request.Header.Set("x-tif-signature", signature)
  5686. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5687. request.Header.Set("x-tif-nonce", nonce)
  5688. fmt.Println(string(bytesData))
  5689. fmt.Println(gdyb_url)
  5690. fmt.Println(gdyb_paasid)
  5691. fmt.Println(request.Header)
  5692. client := http.Client{}
  5693. resp, err := client.Do(request)
  5694. if err != nil {
  5695. fmt.Println(err.Error())
  5696. return err.Error(), ""
  5697. }
  5698. respBytes, err := ioutil.ReadAll(resp.Body)
  5699. if err != nil {
  5700. fmt.Println(err.Error())
  5701. return err.Error(), ""
  5702. }
  5703. fmt.Println(string(respBytes))
  5704. str := string(respBytes)
  5705. return str, inputLog
  5706. }
  5707. }
  5708. // 获取本机ip
  5709. func GetLocalIp() string {
  5710. addrs, err := net.InterfaceAddrs()
  5711. if err != nil {
  5712. fmt.Println("get local ip failed")
  5713. }
  5714. for _, address := range addrs {
  5715. if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
  5716. if ipnet.IP.To4() != nil {
  5717. return ipnet.IP.String()
  5718. }
  5719. }
  5720. }
  5721. return ""
  5722. }
  5723. // 获取本机Mac
  5724. func GetMac() string {
  5725. interfaces, err := net.Interfaces()
  5726. if err != nil {
  5727. fmt.Println("Get loacl Mac failed")
  5728. }
  5729. for _, inter := range interfaces {
  5730. mac := inter.HardwareAddr
  5731. fmt.Println("+======" + mac.String())
  5732. if mac.String() != "" {
  5733. return mac.String()
  5734. }
  5735. }
  5736. return ""
  5737. }
  5738. // 人员基本信息
  5739. 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) {
  5740. //生成签名
  5741. fmt.Println("DDDDD")
  5742. nonce := GetRandomString(32)
  5743. timestamp := time.Now().Unix()
  5744. signature := setSignature(timestamp, nonce, secret_key)
  5745. //生成输入报文
  5746. inputMessage := make(map[string]interface{})
  5747. //tempTime := time.Unix(timestamp, 0)
  5748. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  5749. // 生成输入报文
  5750. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5751. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  5752. } else {
  5753. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  5754. }
  5755. //inputMessage := SetInputMessagenosign(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  5756. input := make(map[string]interface{})
  5757. inputData := make(map[string]interface{})
  5758. inputMessage["infno"] = "1101" // 交易编码
  5759. if certificates == "3" {
  5760. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  5761. inputData["certno"] = certNo // 证件号码
  5762. inputData["psn_cert_type"] = "99" // 人员证件类型
  5763. } else {
  5764. if certificates == "1" {
  5765. if id_card_type == 1 {
  5766. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  5767. inputData["card_sn"] = "" // 卡识别码
  5768. inputData["certno"] = certNo // 证件号码
  5769. inputData["psn_cert_type"] = "01" // 人员证件类型
  5770. } else if id_card_type == 4 {
  5771. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  5772. inputData["certno"] = certNo // 证件号码
  5773. inputData["psn_cert_type"] = "01" // 人员证件类型
  5774. } else {
  5775. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  5776. inputData["card_sn"] = "" // 卡识别码
  5777. inputData["certno"] = certNo // 证件号码
  5778. inputData["psn_cert_type"] = "01" // 人员证件类型
  5779. }
  5780. } else if certificates == "6" {
  5781. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  5782. inputData["card_sn"] = "" // 卡识别码
  5783. inputData["certno"] = certNo // 证件号码
  5784. inputData["psn_cert_type"] = "17" // 人员证件类型
  5785. }
  5786. }
  5787. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  5788. inputData["begntime"] = "" // 开始时间
  5789. inputData["psn_name"] = "" // 人员姓名
  5790. input["data"] = inputData
  5791. inputMessage["input"] = input //交易输入
  5792. var inputLog string
  5793. bytesData, err := json.Marshal(inputMessage)
  5794. inputLog = string(bytesData)
  5795. fmt.Println(string(bytesData))
  5796. if err != nil {
  5797. fmt.Println(err.Error())
  5798. return err.Error(), ""
  5799. }
  5800. reader := bytes.NewReader(bytesData)
  5801. gdyb_url := beego.AppConfig.String("gdyb_url")
  5802. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5803. //DllDef := syscall.MustLoadDLL("yh_hb_sctrl.dll")
  5804. //Iinit := DllDef.MustFindProc("yh_hb_call")
  5805. //var str3 string
  5806. //ret, _, _ := Iinit.Call(StrPtr("1101"), StrPtr(string(bytesData)), StrPtr(str3))
  5807. //fmt.Println(ret)
  5808. //fmt.Println(str3)
  5809. //
  5810. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  5811. var url string
  5812. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5813. url = gdyb_url
  5814. } else {
  5815. url = gdyb_url + "1101"
  5816. }
  5817. {
  5818. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  5819. request, err := http.NewRequest("POST", url, reader)
  5820. if err != nil {
  5821. fmt.Println(err.Error())
  5822. return err.Error(), ""
  5823. }
  5824. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5825. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5826. request.Header.Set("x-tif-signature", signature)
  5827. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5828. request.Header.Set("x-tif-nonce", nonce)
  5829. client := http.Client{}
  5830. resp, err := client.Do(request)
  5831. if err != nil {
  5832. fmt.Println(err.Error())
  5833. return err.Error(), ""
  5834. }
  5835. respBytes, err := ioutil.ReadAll(resp.Body)
  5836. if err != nil {
  5837. fmt.Println(err.Error())
  5838. return err.Error(), ""
  5839. }
  5840. fmt.Println(string(respBytes))
  5841. str := string(respBytes)
  5842. return str, inputLog
  5843. }
  5844. }
  5845. //func SetInputMessageFour(nonce string, timestamp int64, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) map[string]interface{} {
  5846. // // 生成签名
  5847. // //tempTime := time.Unix(timestamp, 0)
  5848. // //timeFormat := tempTime.Format("20060102150405")
  5849. // //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  5850. // //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  5851. //
  5852. // msec := time.Now().Format("000")
  5853. // fmt.Println(utils.GetNetTime())
  5854. // // 生成输入报文
  5855. // inputMessage := make(map[string]interface{})
  5856. // inputMessage["msgid"] = fixmedins_code + utils.GetNetTime() + msec + "0" // 发送方报文 ID
  5857. // inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  5858. // inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  5859. // inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  5860. // inputMessage["dev_no"] = "" // 设备编号
  5861. // inputMessage["dev_safe_info"] = "" // 设备安全信息
  5862. // inputMessage["cainfo"] = "" // 数字签名信息
  5863. // inputMessage["signtype"] = "SM3" // 签名类型
  5864. // inputMessage["infver"] = "V1.0" // 接收方系统代码
  5865. // inputMessage["opter_type"] = "1" // 经办人类别
  5866. // inputMessage["opter"] = doctor // 经办人
  5867. // inputMessage["opter_name"] = doctor // 经办人姓名
  5868. // inputMessage["inf_time"] = utils.GetNetTime() // 交易时间
  5869. // inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  5870. // inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  5871. // inputMessage["sign_no"] = "" //交易签到流水号
  5872. // return inputMessage
  5873. //}
  5874. func Gdyb5302(psnNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  5875. // 生成签名
  5876. nonce := GetRandomString(32)
  5877. //timestamp := time.Now().Unix()
  5878. timestamp := time.Now().UnixNano() / 1e6
  5879. signature := setSignature(timestamp, nonce, secret_key)
  5880. // 生成输入报文
  5881. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  5882. input := make(map[string]interface{})
  5883. inputData := make(map[string]interface{})
  5884. inputMessage["infno"] = "5302" // 交易编码
  5885. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  5886. inputData["biz_appy_type"] = "03" // 人员编号 (来自1101接口返回)
  5887. input["data"] = inputData
  5888. inputMessage["input"] = input //交易输入
  5889. bytesData, err := json.Marshal(inputMessage)
  5890. fmt.Println(string(bytesData))
  5891. if err != nil {
  5892. fmt.Println(err.Error())
  5893. return err.Error()
  5894. }
  5895. reader := bytes.NewReader(bytesData)
  5896. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  5897. gdyb_url := beego.AppConfig.String("gdyb_url")
  5898. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5899. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  5900. url := gdyb_url + "5302"
  5901. request, err := http.NewRequest("POST", url, reader)
  5902. if err != nil {
  5903. fmt.Println(err.Error())
  5904. return err.Error()
  5905. }
  5906. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5907. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5908. request.Header.Set("x-tif-signature", signature)
  5909. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5910. request.Header.Set("x-tif-nonce", nonce)
  5911. client := http.Client{}
  5912. resp, err := client.Do(request)
  5913. if err != nil {
  5914. fmt.Println(err.Error())
  5915. return err.Error()
  5916. }
  5917. respBytes, err := ioutil.ReadAll(resp.Body)
  5918. if err != nil {
  5919. fmt.Println(err.Error())
  5920. return err.Error()
  5921. }
  5922. str := string(respBytes)
  5923. fmt.Println(str)
  5924. return str
  5925. }
  5926. func CreateSignIn(record *models.HisSignIn) (err error) {
  5927. err = writeDb.Save(&record).Error
  5928. return
  5929. }
  5930. func GetSignInInfo(code string) string {
  5931. var sign models.HisSignIn
  5932. err = readDb.Model(&models.HisSignIn{}).Where("fixmedins_code = ? AND status = 1", code).Last(&sign).Error
  5933. return sign.SignNo
  5934. }
  5935. func Gdyb3501(struct3501 models.Struct3501, secret_key string) (string, string) {
  5936. // 生成签名
  5937. nonce := GetRandomString(32)
  5938. timestamp := time.Now().Unix()
  5939. signature := setSignature(timestamp, nonce, secret_key)
  5940. // 生成输入报文
  5941. inputMessage := SetGdInputMessage(timestamp, struct3501.OrgName, struct3501.Opter, struct3501.Code, struct3501.InsuplcAdmdvs, struct3501.MdtrtareaAdmvs, struct3501.Cainfo)
  5942. input := make(map[string]interface{})
  5943. inputData := make(map[string]interface{})
  5944. inputMessage["infno"] = "3501" // 交易编码
  5945. inputData["med_list_codg"] = struct3501.MedListCodg // 定点医药机构目录编号
  5946. inputData["fixmedins_hilist_id"] = struct3501.FixmedinsHilistId // 定点医药机构目录编号
  5947. inputData["fixmedins_hilist_name"] = struct3501.FixmedinsHilistName // 定点医药机构目录名称
  5948. inputData["rx_flag"] = struct3501.RxFlag //
  5949. inputData["invdate"] = struct3501.Invdate // 人员编号 (来自1101接口返回)
  5950. inputData["inv_cnt"] = struct3501.InvCnt // 人员编号 (来自1101接口返回)
  5951. inputData["manu_lotnum"] = struct3501.ManuLotnum // 人员编号 (来自1101接口返回)
  5952. inputData["fixmedins_bchno"] = struct3501.FixmedinsBchno // 人员编号 (来自1101接口返回)
  5953. inputData["manu_date"] = struct3501.ManuDate // 人员编号 (来自1101接口返回)
  5954. inputData["expy_end"] = struct3501.ExpyEnd // 人员编号 (来自1101接口返回)
  5955. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  5956. feedetail := make([]map[string]interface{}, 0)
  5957. codes := strings.Split(struct3501.DrugTracCodg, ",")
  5958. for _, item := range codes {
  5959. if len(item) > 0 {
  5960. druginputData := make(map[string]interface{})
  5961. druginputData["drug_trac_codg"] = item
  5962. feedetail = append(feedetail, druginputData)
  5963. }
  5964. }
  5965. inputData["drugtracinfo"] = feedetail
  5966. input["invinfo"] = inputData
  5967. inputMessage["input"] = input //交易输入
  5968. bytesData, err := json.Marshal(inputMessage)
  5969. fmt.Println(string(bytesData))
  5970. if err != nil {
  5971. fmt.Println(err.Error())
  5972. return err.Error(), ""
  5973. }
  5974. reader := bytes.NewReader(bytesData)
  5975. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  5976. gdyb_url := beego.AppConfig.String("gdyb_url")
  5977. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5978. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  5979. url := gdyb_url + "3501"
  5980. request, err := http.NewRequest("POST", url, reader)
  5981. if err != nil {
  5982. fmt.Println(err.Error())
  5983. return err.Error(), ""
  5984. }
  5985. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5986. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5987. request.Header.Set("x-tif-signature", signature)
  5988. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5989. request.Header.Set("x-tif-nonce", nonce)
  5990. client := http.Client{}
  5991. resp, err := client.Do(request)
  5992. if err != nil {
  5993. fmt.Println(err.Error())
  5994. return err.Error(), ""
  5995. }
  5996. respBytes, err := ioutil.ReadAll(resp.Body)
  5997. if err != nil {
  5998. fmt.Println(err.Error())
  5999. return err.Error(), ""
  6000. }
  6001. str := string(respBytes)
  6002. fmt.Println(str)
  6003. return str, string(bytesData)
  6004. }
  6005. func Gdyb3502(struct3502 models.Struct3502, secret_key string) (string, string) {
  6006. // 生成签名
  6007. nonce := GetRandomString(32)
  6008. timestamp := time.Now().Unix()
  6009. signature := setSignature(timestamp, nonce, secret_key)
  6010. // 生成输入报文
  6011. inputMessage := SetGdInputMessage(timestamp, struct3502.OrgName, struct3502.Opter, struct3502.FixmedinsCode, struct3502.InsuplcAdmdvs, struct3502.MdtrtareaAdmvs, struct3502.Cainfo)
  6012. input := make(map[string]interface{})
  6013. inputData := make(map[string]interface{})
  6014. inputMessage["infno"] = "3502" // 交易编码
  6015. inputData["med_list_codg"] = struct3502.MedListCodg // 定点医药机构目录编号
  6016. inputData["inv_chg_type"] = struct3502.InvChgType // 定点医药机构目录编号
  6017. inputData["fixmedins_hilist_id"] = struct3502.FixmedinsCode // 定点医药机构目录编号
  6018. inputData["fixmedins_hilist_name"] = struct3502.FixmedinsHilistName // 定点医药机构目录名称
  6019. inputData["fixmedins_bchno"] = struct3502.FixmedinsBchno // 人员编号 (来自1101接口返回)
  6020. inputData["pric"] = struct3502.Pric // 人员编号 (来自1101接口返回)
  6021. inputData["cnt"] = struct3502.Cnt // 人员编号 (来自1101接口返回)
  6022. inputData["rx_flag"] = struct3502.RxFlag //
  6023. inputData["inv_chg_time"] = struct3502.InvChgTime // 人员编号 (来自1101接口返回)
  6024. inputData["inv_chg_opter_name"] = "" // 人员编号 (来自1101接口返回)
  6025. inputData["memo"] = struct3502.Memo // 人员编号 (来自1101接口返回)
  6026. inputData["trdn_flag"] = "" // 人员编号 (来自1101接口返回)
  6027. input["invinfo"] = inputData
  6028. //feedetail := make([]map[string]interface{}, 0)
  6029. //druginputData := make(map[string]interface{})
  6030. //druginputData["drug_trac_codg"] = struct3502.DrugTracCodg
  6031. //feedetail = append(feedetail, druginputData)
  6032. //inputData["drugtracinfo"] = feedetail
  6033. feedetail := make([]map[string]interface{}, 0)
  6034. codes := strings.Split(struct3502.DrugTracCodg, ",")
  6035. for _, item := range codes {
  6036. if len(item) > 0 {
  6037. druginputData := make(map[string]interface{})
  6038. druginputData["drug_trac_codg"] = item
  6039. feedetail = append(feedetail, druginputData)
  6040. }
  6041. }
  6042. inputData["drugtracinfo"] = feedetail
  6043. input["invinfo"] = inputData
  6044. inputMessage["input"] = input //交易输入
  6045. bytesData, err := json.Marshal(inputMessage)
  6046. fmt.Println(string(bytesData))
  6047. if err != nil {
  6048. fmt.Println(err.Error())
  6049. return err.Error(), ""
  6050. }
  6051. reader := bytes.NewReader(bytesData)
  6052. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6053. gdyb_url := beego.AppConfig.String("gdyb_url")
  6054. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6055. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6056. url := gdyb_url + "3502"
  6057. request, err := http.NewRequest("POST", url, reader)
  6058. if err != nil {
  6059. fmt.Println(err.Error())
  6060. return err.Error(), ""
  6061. }
  6062. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6063. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6064. request.Header.Set("x-tif-signature", signature)
  6065. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6066. request.Header.Set("x-tif-nonce", nonce)
  6067. client := http.Client{}
  6068. resp, err := client.Do(request)
  6069. if err != nil {
  6070. fmt.Println(err.Error())
  6071. return err.Error(), ""
  6072. }
  6073. respBytes, err := ioutil.ReadAll(resp.Body)
  6074. if err != nil {
  6075. fmt.Println(err.Error())
  6076. return err.Error(), ""
  6077. }
  6078. str := string(respBytes)
  6079. fmt.Println(str)
  6080. return str, string(bytesData)
  6081. }
  6082. func Gdyb3503(struct3503 models.Struct3503, secret_key string) (string, string) {
  6083. // 生成签名
  6084. nonce := GetRandomString(32)
  6085. timestamp := time.Now().Unix()
  6086. signature := setSignature(timestamp, nonce, secret_key)
  6087. // 生成输入报文
  6088. inputMessage := SetGdInputMessage(timestamp, struct3503.OrgName, struct3503.Opter, struct3503.FixmedinsHilistId, struct3503.InsuplcAdmdvs, struct3503.MdtrtareaAdmvs, struct3503.Cainfo)
  6089. input := make(map[string]interface{})
  6090. inputMessage["infno"] = "3503"
  6091. item := struct3503
  6092. feedetailInfo := make(map[string]interface{})
  6093. feedetailInfo["med_list_codg"] = item.MedListCodg
  6094. feedetailInfo["fixmedins_hilist_id"] = item.FixmedinsHilistId
  6095. feedetailInfo["fixmedins_hilist_name"] = item.FixmedinsHilistName
  6096. feedetailInfo["dynt_no"] = ""
  6097. feedetailInfo["fixmedins_bchno"] = item.FixmedinsBchno // 人员编号 (来自1101接口返回)
  6098. feedetailInfo["spler_name"] = item.SplerName // 人员编号 (来自1101接口返回)
  6099. feedetailInfo["spler_pmtno"] = "" // 人员编号 (来自1101接口返回)
  6100. feedetailInfo["manu_lotnum"] = item.ManuLotnum // 人员编号 (来自1101接口返回)
  6101. feedetailInfo["prodentp_name"] = item.ProdentpName // 人员编号 (来自1101接口返回)
  6102. feedetailInfo["aprvno"] = item.Aprvno // 人员编号 (来自1101接口返回)
  6103. feedetailInfo["manu_date"] = item.ManuDate // 人员编号 (来自1101接口返回)
  6104. feedetailInfo["expy_end"] = item.ExpyEnd // 人员编号 (来自1101接口返回)
  6105. feedetailInfo["finl_trns_pric"] = item.FinlTrnsPric // 人员编号 (来自1101接口返回)
  6106. feedetailInfo["purc_retn_cnt"] = item.PurcRetnCnt // 人员编号 (来自1101接口返回)
  6107. feedetailInfo["purc_invo_codg"] = item.PurcInvoCodg // 人员编号 (来自1101接口返回)
  6108. feedetailInfo["purc_invo_no"] = item.PurcInvoNo // 人员编号 (来自1101接口返回)
  6109. feedetailInfo["rx_flag"] = item.RxFlag // 人员编号 (来自1101接口返回)
  6110. feedetailInfo["purc_retn_stoin_time"] = item.PurcRetnStoinTime // 人员编号 (来自1101接口返回)
  6111. feedetailInfo["purc_retn_opter_name"] = item.PurcRetnOpterName // 人员编号 (来自1101接口返回)
  6112. feedetailInfo["prod_geay_flag"] = "" // 人员编号 (来自1101接口返回)
  6113. feedetailInfo["memo"] = "" // 人员编号 (来自1101接口返回)
  6114. input["purcinfo"] = feedetailInfo
  6115. inputMessage["input"] = input //交易输入
  6116. bytesData, err := json.Marshal(inputMessage)
  6117. fmt.Println(string(bytesData))
  6118. if err != nil {
  6119. fmt.Println(err.Error())
  6120. return err.Error(), ""
  6121. }
  6122. reader := bytes.NewReader(bytesData)
  6123. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6124. gdyb_url := beego.AppConfig.String("gdyb_url")
  6125. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6126. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6127. url := gdyb_url + "3503"
  6128. request, err := http.NewRequest("POST", url, reader)
  6129. if err != nil {
  6130. fmt.Println(err.Error())
  6131. return err.Error(), ""
  6132. }
  6133. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6134. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6135. request.Header.Set("x-tif-signature", signature)
  6136. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6137. request.Header.Set("x-tif-nonce", nonce)
  6138. client := http.Client{}
  6139. resp, err := client.Do(request)
  6140. if err != nil {
  6141. fmt.Println(err.Error())
  6142. return err.Error(), ""
  6143. }
  6144. respBytes, err := ioutil.ReadAll(resp.Body)
  6145. if err != nil {
  6146. fmt.Println(err.Error())
  6147. return err.Error(), ""
  6148. }
  6149. str := string(respBytes)
  6150. fmt.Println(str)
  6151. return str, string(bytesData)
  6152. }
  6153. func Gdyb3504(struct3504 models.Struct3504, secret_key string) (string, string) {
  6154. // 生成签名
  6155. nonce := GetRandomString(32)
  6156. timestamp := time.Now().Unix()
  6157. signature := setSignature(timestamp, nonce, secret_key)
  6158. // 生成输入报文
  6159. inputMessage := SetGdInputMessage(timestamp, struct3504.OrgName, struct3504.Opter, struct3504.FixmedinsCode, struct3504.InsuplcAdmdvs, struct3504.MdtrtareaAdmvs, struct3504.Cainfo)
  6160. input := make(map[string]interface{})
  6161. inputData := make(map[string]interface{})
  6162. inputMessage["infno"] = "3504" // 交易编码
  6163. inputData["med_list_codg"] = struct3504.MedListCodg // 定点医药机构目录编号
  6164. inputData["fixmedins_hilist_id"] = struct3504.FixmedinsHilistId // 定点医药机构目录编号
  6165. inputData["fixmedins_hilist_name"] = struct3504.FixmedinsHilistName // 定点医药机构目录名称
  6166. inputData["fixmedins_bchno"] = struct3504.FixmedinsBchno // 人员编号 (来自1101接口返回)
  6167. inputData["spler_name"] = struct3504.SplerName // 人员编号 (来自1101接口返回)
  6168. inputData["spler_pmtno"] = "" // 人员编号 (来自1101接口返回)
  6169. inputData["manu_date"] = struct3504.ManuDate // 人员编号 (来自1101接口返回)
  6170. inputData["expy_end"] = struct3504.ExpyEnd // 人员编号 (来自1101接口返回)
  6171. inputData["finl_trns_pric"] = struct3504.FinlTrnsPric // 人员编号 (来自1101接口返回)
  6172. inputData["purc_retn_cnt"] = struct3504.PurcRetnCnt // 人员编号 (来自1101接口返回)
  6173. inputData["purc_invo_codg"] = struct3504.PurcInvoCodg // 人员编号 (来自1101接口返回)
  6174. inputData["purc_invo_no"] = struct3504.PurcInvoNo // 人员编号 (来自1101接口返回)
  6175. inputData["rx_flag"] = struct3504.RxFlag // 人员编号 (来自1101接口返回)
  6176. inputData["purc_retn_stoin_time"] = struct3504.PurcRetnStoinTime // 人员编号 (来自1101接口返回)
  6177. inputData["purc_retn_opter_name"] = struct3504.PurcRetnOpterName // 人员编号 (来自1101接口返回)
  6178. inputData["medins_prod_purc_no"] = "" // 人员编号 (来自1101接口返回)
  6179. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  6180. input["purcinfo"] = inputData
  6181. inputMessage["input"] = input //交易输入
  6182. bytesData, err := json.Marshal(inputMessage)
  6183. fmt.Println(string(bytesData))
  6184. if err != nil {
  6185. fmt.Println(err.Error())
  6186. return err.Error(), ""
  6187. }
  6188. reader := bytes.NewReader(bytesData)
  6189. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6190. gdyb_url := beego.AppConfig.String("gdyb_url")
  6191. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6192. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6193. url := gdyb_url + "3504"
  6194. request, err := http.NewRequest("POST", url, reader)
  6195. if err != nil {
  6196. fmt.Println(err.Error())
  6197. return err.Error(), ""
  6198. }
  6199. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6200. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6201. request.Header.Set("x-tif-signature", signature)
  6202. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6203. request.Header.Set("x-tif-nonce", nonce)
  6204. client := http.Client{}
  6205. resp, err := client.Do(request)
  6206. if err != nil {
  6207. fmt.Println(err.Error())
  6208. return err.Error(), ""
  6209. }
  6210. respBytes, err := ioutil.ReadAll(resp.Body)
  6211. if err != nil {
  6212. fmt.Println(err.Error())
  6213. return err.Error(), ""
  6214. }
  6215. str := string(respBytes)
  6216. fmt.Println(str)
  6217. return str, string(bytesData)
  6218. }
  6219. func Gdyb3505(struct3505 models.Struct3505, secret_key string) (string, string) {
  6220. // 生成签名
  6221. nonce := GetRandomString(32)
  6222. timestamp := time.Now().Unix()
  6223. signature := setSignature(timestamp, nonce, secret_key)
  6224. // 生成输入报文
  6225. inputMessage := SetGdInputMessage(timestamp, struct3505.OrgName, struct3505.Opter, struct3505.Code, struct3505.InsuplcAdmdvs, struct3505.MdtrtareaAdmvs, struct3505.Cainfo)
  6226. input := make(map[string]interface{})
  6227. inputData := make(map[string]interface{})
  6228. inputMessage["infno"] = "3505" // 交易编码
  6229. inputData["med_list_codg"] = struct3505.MedListCodg // 定点医药机构目录编号
  6230. inputData["fixmedins_hilist_id"] = struct3505.FixmedinsHilistId // 定点医药机构目录编号
  6231. inputData["fixmedins_hilist_name"] = struct3505.FixmedinsHilistName // 定点医药机构目录名称
  6232. inputData["fixmedins_bchno"] = struct3505.FixmedinsBchno // 人员编号 (来自1101接口返回)
  6233. inputData["prsc_dr_cert_type"] = struct3505.PrscDrCertType // 人员编号 (来自1101接口返回)
  6234. inputData["prsc_dr_certno"] = struct3505.PrscDrCertno // 人员编号 (来自1101接口返回)
  6235. inputData["prsc_dr_name"] = struct3505.PrscDrName // 人员编号 (来自1101接口返回)
  6236. inputData["phar_cert_type"] = struct3505.PharCertType // 人员编号 (来自1101接口返回)
  6237. inputData["phar_certno"] = struct3505.PharCertno // 人员编号 (来自1101接口返回)
  6238. inputData["phar_name"] = struct3505.PharName // 人员编号 (来自1101接口返回)
  6239. inputData["phar_prac_cert_no"] = struct3505.PharPracCertNo // 人员编号 (来自1101接口返回)
  6240. inputData["hi_feesetl_type"] = struct3505.HiFeesetlType // 人员编号 (来自1101接口返回)
  6241. inputData["setl_id"] = struct3505.SetlId // 人员编号 (来自1101接口返回)
  6242. inputData["mdtrt_sn"] = struct3505.MdtrtSn // 人员编号 (来自1101接口返回)
  6243. inputData["psn_no"] = struct3505.PsnNo // 人员编号 (来自1101接口返回)
  6244. inputData["psn_cert_type"] = struct3505.PsnCertType // 人员编号 (来自1101接口返回)
  6245. inputData["certno"] = struct3505.CertNo // 人员编号 (来自1101接口返回)
  6246. inputData["psn_name"] = struct3505.PsnName // 人员编号 (来自1101接口返回)
  6247. inputData["manu_lotnum"] = struct3505.ManuLotnum // 人员编号 (来自1101接口返回)
  6248. inputData["manu_date"] = struct3505.ManuDate // 人员编号 (来自1101接口返回)
  6249. inputData["expy_end"] = struct3505.ExpyEnd // 人员编号 (来自1101接口返回)
  6250. inputData["rx_flag"] = struct3505.RxFlag // 人员编号 (来自1101接口返回)
  6251. inputData["trdn_flag"] = struct3505.TrdnFlag // 人员编号 (来自1101接口返回)
  6252. inputData["finl_trns_pric"] = struct3505.FinlTrnsPric // 人员编号 (来自1101接口返回)
  6253. inputData["rxno"] = struct3505.Rxno // 人员编号 (来自1101接口返回)
  6254. inputData["rx_circ_flag"] = struct3505.RxCircFlag // 人员编号 (来自1101接口返回)
  6255. inputData["rtal_docno"] = struct3505.RtalDocno // 人员编号 (来自1101接口返回)
  6256. inputData["stoout_no"] = struct3505.StooutNo // 人员编号 (来自1101接口返回)
  6257. inputData["MDTRT_SETL_TYPE"] = struct3505.MdtrtSetlType // 人员编号 (来自1101接口返回)
  6258. inputData["bchno"] = struct3505.Bchno // 人员编号 (来自1101接口返回)
  6259. inputData["drug_trac_codg"] = struct3505.DrugTracCodg // 人员编号 (来自1101接口返回)
  6260. inputData["drug_prod_barc"] = struct3505.DrugProdBarc // 人员编号 (来自1101接口返回)
  6261. inputData["shelf_posi"] = struct3505.ShelfPosi // 人员编号 (来自1101接口返回)
  6262. inputData["sel_retn_cnt"] = struct3505.SelRetnCnt // 人员编号 (来自1101接口返回)
  6263. inputData["sel_retn_time"] = struct3505.SelRetnTime // 人员编号 (来自1101接口返回)
  6264. inputData["sel_retn_opter_name"] = struct3505.SelRetnOpterName // 人员编号 (来自1101接口返回)
  6265. inputData["memo"] = struct3505.Memo // 人员编号 (来自1101接口返回)
  6266. //input["selinfo"] = inputData
  6267. feedetail := make([]map[string]interface{}, 0)
  6268. codes := strings.Split(struct3505.DrugTracCodg, ",")
  6269. for _, item := range codes {
  6270. if len(item) > 0 {
  6271. druginputData := make(map[string]interface{})
  6272. druginputData["drug_trac_codg"] = item
  6273. feedetail = append(feedetail, druginputData)
  6274. }
  6275. }
  6276. inputData["drugtracinfo"] = feedetail
  6277. input["selinfo"] = inputData
  6278. inputMessage["input"] = input //交易输入
  6279. bytesData, err := json.Marshal(inputMessage)
  6280. fmt.Println(string(bytesData))
  6281. if err != nil {
  6282. fmt.Println(err.Error())
  6283. return err.Error(), ""
  6284. }
  6285. reader := bytes.NewReader(bytesData)
  6286. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6287. gdyb_url := beego.AppConfig.String("gdyb_url")
  6288. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6289. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6290. url := gdyb_url + "3505"
  6291. request, err := http.NewRequest("POST", url, reader)
  6292. if err != nil {
  6293. fmt.Println(err.Error())
  6294. return err.Error(), ""
  6295. }
  6296. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6297. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6298. request.Header.Set("x-tif-signature", signature)
  6299. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6300. request.Header.Set("x-tif-nonce", nonce)
  6301. client := http.Client{}
  6302. resp, err := client.Do(request)
  6303. if err != nil {
  6304. fmt.Println(err.Error())
  6305. return err.Error(), ""
  6306. }
  6307. respBytes, err := ioutil.ReadAll(resp.Body)
  6308. if err != nil {
  6309. fmt.Println(err.Error())
  6310. return err.Error(), ""
  6311. }
  6312. str := string(respBytes)
  6313. fmt.Println(str)
  6314. return str, ""
  6315. }
  6316. func Gdyb3506(struct3506 models.Struct3506, secret_key string) (string, string) {
  6317. // 生成签名
  6318. nonce := GetRandomString(32)
  6319. timestamp := time.Now().Unix()
  6320. signature := setSignature(timestamp, nonce, secret_key)
  6321. // 生成输入报文
  6322. inputMessage := SetGdInputMessage(timestamp, struct3506.OrgName, struct3506.Opter, struct3506.FixmedinsCode, struct3506.InsuplcAdmdvs, struct3506.MdtrtareaAdmvs, struct3506.Cainfo)
  6323. input := make(map[string]interface{})
  6324. inputData := make(map[string]interface{})
  6325. inputMessage["infno"] = "3506" // 交易编码
  6326. inputData["med_list_codg"] = struct3506.MedListCodg // 定点医药机构目录编号
  6327. inputData["fixmedins_hilist_id"] = struct3506.FixmedinsHilistId // 定点医药机构目录编号
  6328. inputData["fixmedins_hilist_name"] = struct3506.FixmedinsHilistName // 定点医药机构目录名称
  6329. inputData["fixmedins_bchno"] = struct3506.FixmedinsBchno // 人员编号 (来自1101接口返回)
  6330. inputData["setl_id"] = struct3506.SetlId // 人员编号 (来自1101接口返回)
  6331. inputData["psn_no"] = struct3506.PsnNo // 人员编号 (来自1101接口返回)
  6332. inputData["psn_cert_type"] = struct3506.PsnCertType // 人员编号 (来自1101接口返回)
  6333. inputData["certno"] = struct3506.Certno // 人员编号 (来自1101接口返回)
  6334. inputData["psn_name"] = struct3506.PsnName // 人员编号 (来自1101接口返回)
  6335. inputData["manu_lotnum"] = struct3506.ManuLotnum // 人员编号 (来自1101接口返回)
  6336. inputData["manu_date"] = struct3506.ManuDate // 人员编号 (来自1101接口返回)
  6337. inputData["expy_end"] = struct3506.ExpyEnd // 人员编号 (来自1101接口返回)
  6338. inputData["rx_flag"] = struct3506.RxFlag // 人员编号 (来自1101接口返回)
  6339. inputData["trdn_flag"] = struct3506.TrdnFlag // 人员编号 (来自1101接口返回)
  6340. inputData["finl_trns_pric"] = struct3506.FinlTrnsPric // 人员编号 (来自1101接口返回)
  6341. inputData["sel_retn_cnt"] = struct3506.SelRetnCnt // 人员编号 (来自1101接口返回)
  6342. inputData["sel_retn_time"] = struct3506.SelRetnTime // 人员编号 (来自1101接口返回)
  6343. inputData["sel_retn_opter_name"] = struct3506.SelRetnOpterName // 人员编号 (来自1101接口返回)
  6344. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  6345. inputData["medins_prod_sel_no"] = "" // 人员编号 (来自1101接口返回)
  6346. input["selinfo"] = inputData
  6347. inputMessage["input"] = input //交易输入
  6348. bytesData, err := json.Marshal(inputMessage)
  6349. fmt.Println(string(bytesData))
  6350. if err != nil {
  6351. fmt.Println(err.Error())
  6352. return err.Error(), ""
  6353. }
  6354. reader := bytes.NewReader(bytesData)
  6355. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6356. gdyb_url := beego.AppConfig.String("gdyb_url")
  6357. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6358. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6359. url := gdyb_url + "3506"
  6360. request, err := http.NewRequest("POST", url, reader)
  6361. if err != nil {
  6362. fmt.Println(err.Error())
  6363. return err.Error(), ""
  6364. }
  6365. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6366. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6367. request.Header.Set("x-tif-signature", signature)
  6368. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6369. request.Header.Set("x-tif-nonce", nonce)
  6370. client := http.Client{}
  6371. resp, err := client.Do(request)
  6372. if err != nil {
  6373. fmt.Println(err.Error())
  6374. return err.Error(), ""
  6375. }
  6376. respBytes, err := ioutil.ReadAll(resp.Body)
  6377. if err != nil {
  6378. fmt.Println(err.Error())
  6379. return err.Error(), ""
  6380. }
  6381. str := string(respBytes)
  6382. fmt.Println(str)
  6383. return str, string(bytesData)
  6384. }
  6385. func Gdyb3507(struct3507 models.Struct3507, secret_key string) (string, string) {
  6386. // 生成签名
  6387. nonce := GetRandomString(32)
  6388. timestamp := time.Now().Unix()
  6389. signature := setSignature(timestamp, nonce, secret_key)
  6390. // 生成输入报文
  6391. inputMessage := SetGdInputMessage(timestamp, struct3507.OrgName, struct3507.Opter, struct3507.FixmedinsCode, struct3507.InsuplcAdmdvs, struct3507.MdtrtareaAdmvs, struct3507.Cainfo)
  6392. input := make(map[string]interface{})
  6393. inputData := make(map[string]interface{})
  6394. inputMessage["infno"] = "3507" // 交易编码
  6395. inputData["fixmedins_bchno"] = struct3507.FixmedinsBchno // 人员编号 (来自1101接口返回)
  6396. inputData["inv_data_type"] = struct3507.InvDataType // 人员编号 (来自1101接口返回)
  6397. input["data"] = inputData
  6398. inputMessage["input"] = input //交易输入
  6399. bytesData, err := json.Marshal(inputMessage)
  6400. fmt.Println(string(bytesData))
  6401. if err != nil {
  6402. fmt.Println(err.Error())
  6403. return err.Error(), ""
  6404. }
  6405. reader := bytes.NewReader(bytesData)
  6406. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6407. gdyb_url := beego.AppConfig.String("gdyb_url")
  6408. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6409. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6410. url := gdyb_url + "3507"
  6411. request, err := http.NewRequest("POST", url, reader)
  6412. if err != nil {
  6413. fmt.Println(err.Error())
  6414. return err.Error(), ""
  6415. }
  6416. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6417. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6418. request.Header.Set("x-tif-signature", signature)
  6419. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6420. request.Header.Set("x-tif-nonce", nonce)
  6421. client := http.Client{}
  6422. resp, err := client.Do(request)
  6423. if err != nil {
  6424. fmt.Println(err.Error())
  6425. return err.Error(), ""
  6426. }
  6427. respBytes, err := ioutil.ReadAll(resp.Body)
  6428. if err != nil {
  6429. fmt.Println(err.Error())
  6430. return err.Error(), ""
  6431. }
  6432. str := string(respBytes)
  6433. fmt.Println(str)
  6434. return str, string(bytesData)
  6435. }
  6436. func Gdyb3508(struct3508 models.Struct3508, secret_key string) (string, string) {
  6437. // 生成签名
  6438. nonce := GetRandomString(32)
  6439. timestamp := time.Now().Unix()
  6440. signature := setSignature(timestamp, nonce, secret_key)
  6441. // 生成输入报文
  6442. inputMessage := SetGdInputMessage(timestamp, struct3508.OrgName, struct3508.Opter, struct3508.FixmedinsCode, struct3508.InsuplcAdmdvs, struct3508.MdtrtareaAdmvs, struct3508.Cainfo)
  6443. input := make(map[string]interface{})
  6444. inputData := make(map[string]interface{})
  6445. inputMessage["infno"] = "3508"
  6446. inputData["fixmedins_code"] = struct3508.FixmedinsCode
  6447. inputData["medins_list_codg"] = struct3508.MedListCodg
  6448. inputData["fixmedins_bchno"] = ""
  6449. inputData["begndate"] = struct3508.Begndate
  6450. inputData["enddate"] = struct3508.Enddate
  6451. inputData["medins_prod_inv_no"] = ""
  6452. inputData["medins_list_name"] = ""
  6453. inputData["rx_flag"] = ""
  6454. inputData["list_sp_item_flag"] = ""
  6455. inputData["trdn_flag"] = ""
  6456. inputData["invdate"] = ""
  6457. inputData["manu_lotnum"] = ""
  6458. inputData["manu_date"] = ""
  6459. inputData["expy_end"] = ""
  6460. inputData["memo"] = ""
  6461. inputData["vali_flag"] = ""
  6462. inputData["rid"] = ""
  6463. inputData["crter_id"] = ""
  6464. inputData["crter_name"] = ""
  6465. inputData["crte_optins_no"] = ""
  6466. inputData["opter_id"] = ""
  6467. inputData["opter_name"] = ""
  6468. inputData["optins_no"] = ""
  6469. inputData["poolarea_no"] = ""
  6470. inputData["fixmedins_bchno"] = ""
  6471. inputData["inv_data_type"] = ""
  6472. input["data"] = inputData
  6473. inputMessage["input"] = input //交易输入
  6474. bytesData, err := json.Marshal(inputMessage)
  6475. fmt.Println(string(bytesData))
  6476. if err != nil {
  6477. fmt.Println(err.Error())
  6478. return err.Error(), ""
  6479. }
  6480. reader := bytes.NewReader(bytesData)
  6481. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6482. gdyb_url := beego.AppConfig.String("gdyb_url")
  6483. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6484. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6485. url := gdyb_url + "3508"
  6486. request, err := http.NewRequest("POST", url, reader)
  6487. if err != nil {
  6488. fmt.Println(err.Error())
  6489. return err.Error(), ""
  6490. }
  6491. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6492. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6493. request.Header.Set("x-tif-signature", signature)
  6494. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6495. request.Header.Set("x-tif-nonce", nonce)
  6496. client := http.Client{}
  6497. resp, err := client.Do(request)
  6498. if err != nil {
  6499. fmt.Println(err.Error())
  6500. return err.Error(), ""
  6501. }
  6502. respBytes, err := ioutil.ReadAll(resp.Body)
  6503. if err != nil {
  6504. fmt.Println(err.Error())
  6505. return err.Error(), ""
  6506. }
  6507. str := string(respBytes)
  6508. fmt.Println(str)
  6509. return str, string(bytesData)
  6510. }
  6511. func Gdyb3509(struct3509 models.Struct3509, secret_key string) (string, string) {
  6512. // 生成签名
  6513. nonce := GetRandomString(32)
  6514. timestamp := time.Now().Unix()
  6515. signature := setSignature(timestamp, nonce, secret_key)
  6516. // 生成输入报文
  6517. inputMessage := SetGdInputMessage(timestamp, struct3509.OrgName, struct3509.Opter, struct3509.FixmedinsCode, struct3509.InsuplcAdmdvs, struct3509.MdtrtareaAdmvs, struct3509.Cainfo)
  6518. input := make(map[string]interface{})
  6519. inputData := make(map[string]interface{})
  6520. inputMessage["infno"] = "3509"
  6521. inputData["fixmedins_code"] = struct3509.FixmedinsCode
  6522. //inputData["med_list_codg"] = struct3509.MedinsListCodg
  6523. inputData["medins_list_codg"] = struct3509.MedListCodg
  6524. inputData["fixmedins_bchno"] = ""
  6525. inputData["begndate"] = struct3509.Begndate
  6526. inputData["enddate"] = struct3509.Enddate
  6527. inputData["medins_prod_inv_no"] = ""
  6528. inputData["medins_list_name"] = ""
  6529. inputData["rx_flag"] = ""
  6530. inputData["list_sp_item_flag"] = ""
  6531. inputData["trdn_flag"] = ""
  6532. inputData["invdate"] = ""
  6533. inputData["manu_lotnum"] = ""
  6534. inputData["manu_date"] = ""
  6535. inputData["expy_end"] = ""
  6536. inputData["memo"] = ""
  6537. inputData["vali_flag"] = ""
  6538. inputData["rid"] = ""
  6539. inputData["crter_id"] = ""
  6540. inputData["crter_name"] = ""
  6541. inputData["crte_optins_no"] = ""
  6542. inputData["opter_id"] = ""
  6543. inputData["opter_name"] = ""
  6544. inputData["optins_no"] = ""
  6545. inputData["poolarea_no"] = ""
  6546. inputData["fixmedins_bchno"] = ""
  6547. inputData["inv_data_type"] = ""
  6548. input["data"] = inputData
  6549. inputMessage["input"] = input //交易输入
  6550. bytesData, err := json.Marshal(inputMessage)
  6551. fmt.Println(string(bytesData))
  6552. if err != nil {
  6553. fmt.Println(err.Error())
  6554. return err.Error(), ""
  6555. }
  6556. reader := bytes.NewReader(bytesData)
  6557. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6558. gdyb_url := beego.AppConfig.String("gdyb_url")
  6559. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6560. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6561. url := gdyb_url + "3509"
  6562. request, err := http.NewRequest("POST", url, reader)
  6563. if err != nil {
  6564. fmt.Println(err.Error())
  6565. return err.Error(), ""
  6566. }
  6567. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6568. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6569. request.Header.Set("x-tif-signature", signature)
  6570. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6571. request.Header.Set("x-tif-nonce", nonce)
  6572. client := http.Client{}
  6573. resp, err := client.Do(request)
  6574. if err != nil {
  6575. fmt.Println(err.Error())
  6576. return err.Error(), ""
  6577. }
  6578. respBytes, err := ioutil.ReadAll(resp.Body)
  6579. if err != nil {
  6580. fmt.Println(err.Error())
  6581. return err.Error(), ""
  6582. }
  6583. str := string(respBytes)
  6584. fmt.Println(str)
  6585. return str, string(bytesData)
  6586. }
  6587. func Gdyb3510(struct3510 models.Struct3510, secret_key string) (string, string) {
  6588. // 生成签名
  6589. nonce := GetRandomString(32)
  6590. timestamp := time.Now().Unix()
  6591. signature := setSignature(timestamp, nonce, secret_key)
  6592. // 生成输入报文
  6593. inputMessage := SetGdInputMessage(timestamp, struct3510.OrgName, struct3510.Opter, struct3510.FixmedinsCode, struct3510.InsuplcAdmdvs, struct3510.MdtrtareaAdmvs, struct3510.Cainfo)
  6594. input := make(map[string]interface{})
  6595. inputData := make(map[string]interface{})
  6596. inputMessage["infno"] = "3510"
  6597. inputData["fixmedins_code"] = struct3510.FixmedinsCode
  6598. //inputData["medins_list_codg"] = struct3510.MedinsListCodg
  6599. inputData["medins_list_codg"] = struct3510.MedListCodg
  6600. inputData["fixmedins_bchno"] = ""
  6601. inputData["begndate"] = struct3510.Begndate
  6602. inputData["enddate"] = struct3510.Enddate
  6603. inputData["medins_prod_inv_no"] = ""
  6604. inputData["medins_list_name"] = ""
  6605. inputData["rx_flag"] = ""
  6606. inputData["list_sp_item_flag"] = ""
  6607. inputData["trdn_flag"] = ""
  6608. inputData["invdate"] = ""
  6609. inputData["manu_lotnum"] = ""
  6610. inputData["manu_date"] = ""
  6611. inputData["expy_end"] = ""
  6612. inputData["memo"] = ""
  6613. inputData["vali_flag"] = ""
  6614. inputData["rid"] = ""
  6615. inputData["crter_id"] = ""
  6616. inputData["crter_name"] = ""
  6617. inputData["crte_optins_no"] = ""
  6618. inputData["opter_id"] = ""
  6619. inputData["opter_name"] = ""
  6620. inputData["optins_no"] = ""
  6621. inputData["poolarea_no"] = ""
  6622. inputData["fixmedins_bchno"] = ""
  6623. inputData["inv_data_type"] = ""
  6624. input["data"] = inputData
  6625. inputMessage["input"] = input //交易输入
  6626. bytesData, err := json.Marshal(inputMessage)
  6627. fmt.Println(string(bytesData))
  6628. if err != nil {
  6629. fmt.Println(err.Error())
  6630. return err.Error(), ""
  6631. }
  6632. reader := bytes.NewReader(bytesData)
  6633. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6634. gdyb_url := beego.AppConfig.String("gdyb_url")
  6635. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6636. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6637. url := gdyb_url + "3510"
  6638. request, err := http.NewRequest("POST", url, reader)
  6639. if err != nil {
  6640. fmt.Println(err.Error())
  6641. return err.Error(), ""
  6642. }
  6643. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6644. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6645. request.Header.Set("x-tif-signature", signature)
  6646. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6647. request.Header.Set("x-tif-nonce", nonce)
  6648. client := http.Client{}
  6649. resp, err := client.Do(request)
  6650. if err != nil {
  6651. fmt.Println(err.Error())
  6652. return err.Error(), ""
  6653. }
  6654. respBytes, err := ioutil.ReadAll(resp.Body)
  6655. if err != nil {
  6656. fmt.Println(err.Error())
  6657. return err.Error(), ""
  6658. }
  6659. str := string(respBytes)
  6660. fmt.Println(str)
  6661. return str, string(bytesData)
  6662. }
  6663. func Gdyb3511(struct3511 models.Struct3511, secret_key string) (string, string) {
  6664. // 生成签名
  6665. nonce := GetRandomString(32)
  6666. timestamp := time.Now().Unix()
  6667. signature := setSignature(timestamp, nonce, secret_key)
  6668. // 生成输入报文
  6669. inputMessage := SetGdInputMessage(timestamp, struct3511.OrgName, struct3511.Opter, struct3511.FixmedinsCode, struct3511.InsuplcAdmdvs, struct3511.MdtrtareaAdmvs, struct3511.Cainfo)
  6670. input := make(map[string]interface{})
  6671. inputData := make(map[string]interface{})
  6672. inputMessage["infno"] = "3511"
  6673. inputData["fixmedins_code"] = struct3511.FixmedinsCode
  6674. //inputData["medins_list_codg"] = struct3511.MedinsListCodg
  6675. inputData["medins_list_codg"] = struct3511.MedListCodg
  6676. inputData["fixmedins_bchno"] = ""
  6677. inputData["begndate"] = struct3511.Begndate
  6678. inputData["enddate"] = struct3511.Enddate
  6679. inputData["medins_prod_inv_no"] = ""
  6680. inputData["medins_list_name"] = ""
  6681. inputData["rx_flag"] = ""
  6682. inputData["list_sp_item_flag"] = ""
  6683. inputData["trdn_flag"] = ""
  6684. inputData["invdate"] = ""
  6685. inputData["manu_lotnum"] = ""
  6686. inputData["manu_date"] = ""
  6687. inputData["expy_end"] = ""
  6688. inputData["memo"] = ""
  6689. inputData["vali_flag"] = ""
  6690. inputData["rid"] = ""
  6691. inputData["crter_id"] = ""
  6692. inputData["crter_name"] = ""
  6693. inputData["crte_optins_no"] = ""
  6694. inputData["opter_id"] = ""
  6695. inputData["opter_name"] = ""
  6696. inputData["optins_no"] = ""
  6697. inputData["poolarea_no"] = ""
  6698. inputData["fixmedins_bchno"] = ""
  6699. inputData["inv_data_type"] = ""
  6700. input["data"] = inputData
  6701. inputMessage["input"] = input //交易输入
  6702. bytesData, err := json.Marshal(inputMessage)
  6703. fmt.Println(string(bytesData))
  6704. if err != nil {
  6705. fmt.Println(err.Error())
  6706. return err.Error(), ""
  6707. }
  6708. reader := bytes.NewReader(bytesData)
  6709. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6710. gdyb_url := beego.AppConfig.String("gdyb_url")
  6711. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6712. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6713. url := gdyb_url + "3511"
  6714. request, err := http.NewRequest("POST", url, reader)
  6715. if err != nil {
  6716. fmt.Println(err.Error())
  6717. return err.Error(), ""
  6718. }
  6719. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6720. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6721. request.Header.Set("x-tif-signature", signature)
  6722. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6723. request.Header.Set("x-tif-nonce", nonce)
  6724. client := http.Client{}
  6725. resp, err := client.Do(request)
  6726. if err != nil {
  6727. fmt.Println(err.Error())
  6728. return err.Error(), ""
  6729. }
  6730. respBytes, err := ioutil.ReadAll(resp.Body)
  6731. if err != nil {
  6732. fmt.Println(err.Error())
  6733. return err.Error(), ""
  6734. }
  6735. str := string(respBytes)
  6736. fmt.Println(str)
  6737. return str, string(bytesData)
  6738. }
  6739. func Gdyb3512(struct3512 models.Struct3512, secret_key string) (string, string) {
  6740. // 生成签名
  6741. nonce := GetRandomString(32)
  6742. timestamp := time.Now().Unix()
  6743. signature := setSignature(timestamp, nonce, secret_key)
  6744. // 生成输入报文
  6745. inputMessage := SetGdInputMessage(timestamp, struct3512.OrgName, struct3512.Opter, struct3512.FixmedinsCode, struct3512.InsuplcAdmdvs, struct3512.MdtrtareaAdmvs, struct3512.Cainfo)
  6746. input := make(map[string]interface{})
  6747. inputData := make(map[string]interface{})
  6748. inputMessage["infno"] = "3512"
  6749. inputData["fixmedins_code"] = struct3512.FixmedinsCode
  6750. //inputData["medins_list_codg"] = struct3512.MedinsListCodg
  6751. inputData["medins_list_codg"] = struct3512.MedListCodg
  6752. inputData["fixmedins_bchno"] = ""
  6753. inputData["begndate"] = struct3512.Begndate
  6754. inputData["enddate"] = struct3512.Enddate
  6755. inputData["medins_prod_inv_no"] = ""
  6756. inputData["medins_list_name"] = ""
  6757. inputData["rx_flag"] = ""
  6758. inputData["list_sp_item_flag"] = ""
  6759. inputData["trdn_flag"] = ""
  6760. inputData["invdate"] = ""
  6761. inputData["manu_lotnum"] = ""
  6762. inputData["manu_date"] = ""
  6763. inputData["expy_end"] = ""
  6764. inputData["memo"] = ""
  6765. inputData["vali_flag"] = ""
  6766. inputData["rid"] = ""
  6767. inputData["crter_id"] = ""
  6768. inputData["crter_name"] = ""
  6769. inputData["crte_optins_no"] = ""
  6770. inputData["opter_id"] = ""
  6771. inputData["opter_name"] = ""
  6772. inputData["optins_no"] = ""
  6773. inputData["poolarea_no"] = ""
  6774. inputData["fixmedins_bchno"] = ""
  6775. inputData["inv_data_type"] = ""
  6776. input["data"] = inputData
  6777. inputMessage["input"] = input //交易输入
  6778. bytesData, err := json.Marshal(inputMessage)
  6779. fmt.Println(string(bytesData))
  6780. if err != nil {
  6781. fmt.Println(err.Error())
  6782. return err.Error(), ""
  6783. }
  6784. reader := bytes.NewReader(bytesData)
  6785. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6786. gdyb_url := beego.AppConfig.String("gdyb_url")
  6787. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6788. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6789. url := gdyb_url + "3512"
  6790. request, err := http.NewRequest("POST", url, reader)
  6791. if err != nil {
  6792. fmt.Println(err.Error())
  6793. return err.Error(), ""
  6794. }
  6795. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6796. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6797. request.Header.Set("x-tif-signature", signature)
  6798. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6799. request.Header.Set("x-tif-nonce", nonce)
  6800. client := http.Client{}
  6801. resp, err := client.Do(request)
  6802. if err != nil {
  6803. fmt.Println(err.Error())
  6804. return err.Error(), ""
  6805. }
  6806. respBytes, err := ioutil.ReadAll(resp.Body)
  6807. if err != nil {
  6808. fmt.Println(err.Error())
  6809. return err.Error(), ""
  6810. }
  6811. str := string(respBytes)
  6812. fmt.Println(str)
  6813. return str, string(bytesData)
  6814. }
  6815. func Gdyb3513(struct3513 models.Struct3513, secret_key string) (string, string) {
  6816. // 生成签名
  6817. nonce := GetRandomString(32)
  6818. timestamp := time.Now().Unix()
  6819. signature := setSignature(timestamp, nonce, secret_key)
  6820. // 生成输入报文
  6821. inputMessage := SetGdInputMessage(timestamp, struct3513.OrgName, struct3513.Opter, struct3513.FixmedinsCode, struct3513.InsuplcAdmdvs, struct3513.MdtrtareaAdmvs, struct3513.Cainfo)
  6822. input := make(map[string]interface{})
  6823. inputData := make(map[string]interface{})
  6824. inputMessage["infno"] = "3513"
  6825. inputData["fixmedins_code"] = struct3513.FixmedinsCode
  6826. //inputData["medins_list_codg"] = struct3513.MedinsListCodg
  6827. inputData["medins_list_codg"] = struct3513.MedListCodg
  6828. inputData["fixmedins_bchno"] = ""
  6829. inputData["begndate"] = struct3513.Begndate
  6830. inputData["enddate"] = struct3513.Enddate
  6831. inputData["medins_prod_inv_no"] = ""
  6832. inputData["med_list_codg"] = ""
  6833. inputData["medins_list_name"] = ""
  6834. inputData["rx_flag"] = ""
  6835. inputData["list_sp_item_flag"] = ""
  6836. inputData["trdn_flag"] = ""
  6837. inputData["invdate"] = ""
  6838. inputData["manu_lotnum"] = ""
  6839. inputData["manu_date"] = ""
  6840. inputData["expy_end"] = ""
  6841. inputData["memo"] = ""
  6842. inputData["vali_flag"] = ""
  6843. inputData["rid"] = ""
  6844. inputData["crter_id"] = ""
  6845. inputData["crter_name"] = ""
  6846. inputData["crte_optins_no"] = ""
  6847. inputData["opter_id"] = ""
  6848. inputData["opter_name"] = ""
  6849. inputData["optins_no"] = ""
  6850. inputData["poolarea_no"] = ""
  6851. inputData["fixmedins_bchno"] = ""
  6852. inputData["inv_data_type"] = ""
  6853. input["data"] = inputData
  6854. inputMessage["input"] = input //交易输入
  6855. bytesData, err := json.Marshal(inputMessage)
  6856. fmt.Println(string(bytesData))
  6857. if err != nil {
  6858. fmt.Println(err.Error())
  6859. return err.Error(), ""
  6860. }
  6861. reader := bytes.NewReader(bytesData)
  6862. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6863. gdyb_url := beego.AppConfig.String("gdyb_url")
  6864. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6865. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6866. url := gdyb_url + "3513"
  6867. request, err := http.NewRequest("POST", url, reader)
  6868. if err != nil {
  6869. fmt.Println(err.Error())
  6870. return err.Error(), ""
  6871. }
  6872. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6873. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6874. request.Header.Set("x-tif-signature", signature)
  6875. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6876. request.Header.Set("x-tif-nonce", nonce)
  6877. client := http.Client{}
  6878. resp, err := client.Do(request)
  6879. if err != nil {
  6880. fmt.Println(err.Error())
  6881. return err.Error(), ""
  6882. }
  6883. respBytes, err := ioutil.ReadAll(resp.Body)
  6884. if err != nil {
  6885. fmt.Println(err.Error())
  6886. return err.Error(), ""
  6887. }
  6888. str := string(respBytes)
  6889. fmt.Println(str)
  6890. return str, string(bytesData)
  6891. }
  6892. // 生成基础报文
  6893. func SetGdInputMessage(timestamp int64, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, cainfo string) map[string]interface{} {
  6894. // 生成签名
  6895. tempTime := time.Unix(timestamp, 0)
  6896. //timeFormat := tempTime.Format("20060102150405")
  6897. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  6898. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  6899. month := time.Unix(1557042972, 0).Format("1")
  6900. year := time.Now().Format("2006")
  6901. month = time.Now().Format("01")
  6902. day := time.Now().Format("02")
  6903. hour := time.Now().Format("15")
  6904. min := time.Now().Format("04")
  6905. sec := time.Now().Format("05")
  6906. msec := time.Now().Format("000")
  6907. // 生成输入报文
  6908. inputMessage := make(map[string]interface{})
  6909. inputMessage["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  6910. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  6911. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  6912. inputMessage["recer_sys_code"] = "MBS_LOCAL" // 接收方系统代码
  6913. inputMessage["dev_no"] = "1" // 设备编号
  6914. inputMessage["dev_safe_info"] = "1" // 设备安全信息
  6915. inputMessage["cainfo"] = cainfo // 数字签名信息
  6916. inputMessage["signtype"] = "SM3" // 签名类型
  6917. inputMessage["infver"] = "1.0.0" // 接收方系统代码
  6918. inputMessage["opter_type"] = "1" // 经办人类别
  6919. inputMessage["opter"] = doctor // 经办人
  6920. inputMessage["opter_name"] = doctor // 经办人姓名
  6921. inputMessage["inf_time"] = timeFormatOne // 交易时间
  6922. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  6923. inputMessage["fixmedins_name"] = org_name
  6924. inputMessage["fixmedins_soft_fcty"] = "深圳市领透科技有限公司" //定点医药机构名称
  6925. //定点医药机构名称
  6926. inputMessage["sign_no"] = "" //交易签到流水号
  6927. return inputMessage
  6928. }
  6929. 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) {
  6930. nonce := GetRandomString(32)
  6931. timestamp := time.Now().Unix()
  6932. signature := setSignature(timestamp, nonce, params.SecretKey)
  6933. // 生成输入报文
  6934. inputMessage := SetGdInputMessage(timestamp, params.FixmedinsName, params.OpterName, params.FixmedinsCode, params.InsuplcAdmdvs, params.MdtrtareaAdmvs, params.Cainfo)
  6935. //inputMessage := SetJSInputMessage(timestamp, params.FixmedinsName, params.OpterName, params.FixmedinsCode, params.InsuplcAdmdvs, params.MdtrtareaAdmvs, params.Cainfo)
  6936. input := make(map[string]interface{})
  6937. inputData := make(map[string]interface{})
  6938. patientDtosinputData := make(map[string]interface{})
  6939. fisEncounterDtosData := make(map[string]interface{})
  6940. fsiDiagnoseDtosDatas := make([]map[string]interface{}, 0)
  6941. fsiOrderDtosDatas := make([]map[string]interface{}, 0)
  6942. fsiOperationDtosData := make(map[string]interface{})
  6943. fsiOperationDtosDatas := make([]map[string]interface{}, 0)
  6944. //就诊信息
  6945. fisEncounterDtosData["mdtrt_id"] = fed.MdtrtID
  6946. fisEncounterDtosData["medins_id"] = fed.MedinsID
  6947. fisEncounterDtosData["medins_name"] = fed.MedinsName
  6948. fisEncounterDtosData["medins_admdvs"] = fed.MedinsAdmdvs
  6949. fisEncounterDtosData["medins_type"] = fed.MedinsType
  6950. fisEncounterDtosData["medins_lv"] = fed.MedinsLv
  6951. fisEncounterDtosData["wardarea_codg"] = fed.WardareaCodg
  6952. fisEncounterDtosData["wardno"] = fed.Wardno
  6953. fisEncounterDtosData["bedno"] = fed.Bedno
  6954. fisEncounterDtosData["adm_date"] = fed.AdmDate
  6955. fisEncounterDtosData["dscg_date"] = fed.DscgDate
  6956. fisEncounterDtosData["dscg_main_dise_codg"] = fed.DscgMainDiseCodg
  6957. fisEncounterDtosData["dscg_main_dise_name"] = fed.DscgMainDiseName
  6958. for _, fdd := range fdds {
  6959. fsiDiagnoseDtosData := make(map[string]interface{})
  6960. //诊断集合
  6961. fsiDiagnoseDtosData["dise_id"] = fdd.DiseID
  6962. fsiDiagnoseDtosData["inout_dise_type"] = fdd.InoutDiseType
  6963. fsiDiagnoseDtosData["maindise_flag"] = fdd.MaindiseFlag
  6964. fsiDiagnoseDtosData["dias_srt_no"] = fdd.DiasSrtNo
  6965. fsiDiagnoseDtosData["dise_codg"] = fdd.DiseCodg
  6966. fsiDiagnoseDtosData["dise_name"] = fdd.DiseName
  6967. fsiDiagnoseDtosData["dise_date"] = fdd.DiseDate
  6968. fsiDiagnoseDtosDatas = append(fsiDiagnoseDtosDatas, fsiDiagnoseDtosData)
  6969. }
  6970. fisEncounterDtosData["fsi_diagnose_dtos"] = fsiDiagnoseDtosDatas
  6971. fisEncounterDtosData["dr_codg"] = fed.DrCodg
  6972. fisEncounterDtosData["adm_dept_codg"] = fed.AdmDeptCodg
  6973. fisEncounterDtosData["adm_dept_name"] = fed.AdmDeptName
  6974. fisEncounterDtosData["dscg_dept_codg"] = fed.DscgDeptCodg
  6975. fisEncounterDtosData["dscg_dept_name"] = fed.DscgDeptName
  6976. fisEncounterDtosData["med_mdtrt_type"] = fed.MedMdtrtType
  6977. fisEncounterDtosData["med_type"] = fed.MedType
  6978. for _, fod := range fods {
  6979. fsiOrderDtosData := make(map[string]interface{})
  6980. //医嘱集合
  6981. fsiOrderDtosData["rx_id"] = fod.RxID
  6982. fsiOrderDtosData["rxno"] = fod.Rxno
  6983. fsiOrderDtosData["grpno"] = fod.Grpno
  6984. fsiOrderDtosData["long_drord_flag"] = fod.LongDrordFlag
  6985. fsiOrderDtosData["hilist_type"] = fod.HilistType
  6986. fsiOrderDtosData["chrg_type"] = fod.ChrgType
  6987. fsiOrderDtosData["drord_bhvr"] = fod.DrordBhvr
  6988. fsiOrderDtosData["hilist_code"] = fod.HilistCode
  6989. fsiOrderDtosData["hilist_name"] = fod.HosplistName
  6990. fsiOrderDtosData["hilist_dosform"] = fod.HilistDosform
  6991. fsiOrderDtosData["hilist_lv"] = fod.HilistLv
  6992. fsiOrderDtosData["hilist_pric"] = fod.HilistPric
  6993. fsiOrderDtosData["lv1_hosp_item_pric"] = fod.Lv1HospItemPric
  6994. fsiOrderDtosData["lv2_hosp_item_pric"] = fod.Lv2HospItemPric
  6995. fsiOrderDtosData["lv3_hosp_item_pric"] = fod.Lv3HospItemPric
  6996. fsiOrderDtosData["hilist_memo"] = fod.HilistMemo
  6997. fsiOrderDtosData["hosplist_code"] = fod.HosplistCode
  6998. fsiOrderDtosData["hosplist_name"] = fod.HosplistName
  6999. fsiOrderDtosData["hosplist_dosform"] = fod.HosplistDosform
  7000. fsiOrderDtosData["cnt"] = fod.Cnt
  7001. fsiOrderDtosData["pric"] = fod.Pric
  7002. fsiOrderDtosData["sumamt"] = fod.Sumamt
  7003. fsiOrderDtosData["ownpay_amt"] = fod.OwnpayAmt
  7004. fsiOrderDtosData["selfpay_amt"] = fod.SelfpayAmt
  7005. fsiOrderDtosData["spec"] = fod.Spec
  7006. fsiOrderDtosData["spec_unt"] = fod.SpecUnt
  7007. fsiOrderDtosData["drord_begn_date"] = fod.DrordBegnDate
  7008. fsiOrderDtosData["drord_stop_date"] = fod.DrordStopDate
  7009. fsiOrderDtosData["drord_dept_codg"] = fod.DrordDeptCodg
  7010. fsiOrderDtosData["drord_dept_name"] = fod.DrordDeptName
  7011. fsiOrderDtosData["drord_dr_codg"] = fod.DrordDrCodg
  7012. fsiOrderDtosData["drord_dr_name"] = fod.DrordDrName
  7013. fsiOrderDtosData["drord_dr_profttl"] = fod.DrordDrProfttl
  7014. fsiOrderDtosData["curr_drord_flag"] = fod.CurrDrordFlag
  7015. fsiOrderDtosDatas = append(fsiOrderDtosDatas, fsiOrderDtosData)
  7016. }
  7017. fisEncounterDtosData["fsi_order_dtos"] = fsiOrderDtosDatas
  7018. fisEncounterDtosData["matn_stas"] = fed.MatnStas
  7019. fisEncounterDtosData["medfee_sumamt"] = fed.MedfeeSumamt
  7020. fisEncounterDtosData["ownpay_amt"] = fed.OwnpayAmt
  7021. fisEncounterDtosData["selfpay_amt"] = fed.SelfpayAmt
  7022. fisEncounterDtosData["acct_payamt"] = fed.AcctPayamt
  7023. fisEncounterDtosData["ma_amt"] = fed.MaAmt
  7024. fisEncounterDtosData["hifp_payamt"] = fed.HifpPayamt
  7025. fisEncounterDtosData["setl_totlnum"] = fed.SetlTotlnum
  7026. fisEncounterDtosData["insutype"] = fed.Insutype
  7027. fisEncounterDtosData["reim_flag"] = fed.ReimFlag
  7028. fisEncounterDtosData["out_setl_flag"] = fed.OutSetlFlag
  7029. //手术操作
  7030. for _, fopd := range fopds {
  7031. fsiOperationDtosData["setl_list_oprn_id"] = fopd.Setl_list_oprn_id
  7032. fsiOperationDtosData["oprn_code"] = fopd.Oprn_code
  7033. fsiOperationDtosData["oprn_name"] = fopd.Oprn_name
  7034. fsiOperationDtosData["main_oprn_flag"] = fopd.Main_oprn_flag
  7035. fsiOperationDtosData["oprn_date"] = fopd.Oprn_date
  7036. fsiOperationDtosData["anst_way"] = fopd.Anst_way
  7037. fsiOperationDtosData["oper_dr_name"] = fopd.Oper_dr_name
  7038. fsiOperationDtosData["oper_dr_code"] = fopd.Oper_dr_code
  7039. fsiOperationDtosData["anst_dr_name"] = fopd.Anst_dr_name
  7040. fsiOperationDtosData["anst_dr_code"] = fopd.Anst_dr_code
  7041. fsiOperationDtosDatas = append(fsiOperationDtosDatas, fsiOperationDtosData)
  7042. }
  7043. fisEncounterDtosData["fsi_operation_dtos"] = fsiOperationDtosDatas
  7044. patientDtosinputData["patn_id"] = pd.PatnID
  7045. patientDtosinputData["patn_name"] = pd.PatnName
  7046. patientDtosinputData["gend"] = pd.Gend
  7047. patientDtosinputData["brdy"] = pd.Brdy
  7048. patientDtosinputData["poolarea"] = pd.Poolarea
  7049. patientDtosinputData["curr_mdtrt_id"] = pd.CurrMdtrtID
  7050. patientDtosinputData["fsi_his_data_dto"] = ""
  7051. patientDtosinputData["fsi_encounter_dtos"] = fisEncounterDtosData
  7052. inputData["syscode"] = "LinkDialysis"
  7053. inputData["trig_scen"] = trig_scen
  7054. inputData["rule_ids"] = ""
  7055. inputData["task_id"] = ""
  7056. inputData["patient_dtos"] = patientDtosinputData
  7057. input["data"] = inputData
  7058. inputMessage["infno"] = "3101"
  7059. inputMessage["input"] = input //交易输入
  7060. bytesData, err := json.Marshal(inputMessage)
  7061. fmt.Println(string(bytesData))
  7062. if err != nil {
  7063. fmt.Println(err.Error())
  7064. return err.Error(), ""
  7065. }
  7066. reader := bytes.NewReader(bytesData)
  7067. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7068. gdyb_url := beego.AppConfig.String("gdyb_url")
  7069. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7070. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7071. url := gdyb_url + "3101"
  7072. request, err := http.NewRequest("POST", url, reader)
  7073. if err != nil {
  7074. fmt.Println(err.Error())
  7075. return err.Error(), ""
  7076. }
  7077. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  7078. request.Header.Set("x-tif-paasid", gdyb_paasid)
  7079. request.Header.Set("x-tif-signature", signature)
  7080. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  7081. request.Header.Set("x-tif-nonce", nonce)
  7082. client := http.Client{}
  7083. resp, err := client.Do(request)
  7084. if err != nil {
  7085. fmt.Println(err.Error())
  7086. return err.Error(), ""
  7087. }
  7088. respBytes, err := ioutil.ReadAll(resp.Body)
  7089. if err != nil {
  7090. fmt.Println(err.Error())
  7091. return err.Error(), ""
  7092. }
  7093. str := string(respBytes)
  7094. fmt.Println(str)
  7095. return str, string(bytesData)
  7096. }
  7097. 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) {
  7098. nonce := GetRandomString(32)
  7099. timestamp := time.Now().Unix()
  7100. signature := setSignature(timestamp, nonce, params.SecretKey)
  7101. // 生成输入报文
  7102. inputMessage := SetGdInputMessage(timestamp, params.FixmedinsName, params.OpterName, params.FixmedinsCode, params.InsuplcAdmdvs, params.MdtrtareaAdmvs, params.Cainfo)
  7103. input := make(map[string]interface{})
  7104. inputData := make(map[string]interface{})
  7105. patientDtosinputData := make(map[string]interface{})
  7106. fisEncounterDtosData := make(map[string]interface{})
  7107. fsiDiagnoseDtosDatas := make([]map[string]interface{}, 0)
  7108. fsiOrderDtosDatas := make([]map[string]interface{}, 0)
  7109. fsiOperationDtosData := make(map[string]interface{})
  7110. fsiOperationDtosDatas := make([]map[string]interface{}, 0)
  7111. //就诊信息
  7112. fisEncounterDtosData["mdtrt_id"] = fed.MdtrtID
  7113. fisEncounterDtosData["medins_id"] = fed.MedinsID
  7114. fisEncounterDtosData["medins_name"] = fed.MedinsName
  7115. fisEncounterDtosData["medins_admdvs"] = fed.MedinsAdmdvs
  7116. fisEncounterDtosData["medins_type"] = fed.MedinsType
  7117. fisEncounterDtosData["medins_lv"] = fed.MedinsLv
  7118. fisEncounterDtosData["wardarea_codg"] = fed.WardareaCodg
  7119. fisEncounterDtosData["wardno"] = fed.Wardno
  7120. fisEncounterDtosData["bedno"] = fed.Bedno
  7121. fisEncounterDtosData["adm_date"] = fed.AdmDate
  7122. fisEncounterDtosData["dscg_date"] = fed.DscgDate
  7123. fisEncounterDtosData["dscg_main_dise_codg"] = fed.DscgMainDiseCodg
  7124. fisEncounterDtosData["dscg_main_dise_name"] = fed.DscgMainDiseName
  7125. for _, fdd := range fdds {
  7126. fsiDiagnoseDtosData := make(map[string]interface{})
  7127. //诊断集合
  7128. fsiDiagnoseDtosData["dise_id"] = fdd.DiseID
  7129. fsiDiagnoseDtosData["inout_dise_type"] = fdd.InoutDiseType
  7130. fsiDiagnoseDtosData["maindise_flag"] = fdd.MaindiseFlag
  7131. fsiDiagnoseDtosData["dias_srt_no"] = fdd.DiasSrtNo
  7132. fsiDiagnoseDtosData["dise_codg"] = fdd.DiseCodg
  7133. fsiDiagnoseDtosData["dise_name"] = fdd.DiseName
  7134. fsiDiagnoseDtosData["dise_date"] = fdd.DiseDate
  7135. fsiDiagnoseDtosDatas = append(fsiDiagnoseDtosDatas, fsiDiagnoseDtosData)
  7136. }
  7137. fisEncounterDtosData["fsi_diagnose_dtos"] = fsiDiagnoseDtosDatas
  7138. fisEncounterDtosData["dr_codg"] = fed.DrCodg
  7139. fisEncounterDtosData["adm_dept_codg"] = fed.AdmDeptCodg
  7140. fisEncounterDtosData["adm_dept_name"] = fed.AdmDeptName
  7141. fisEncounterDtosData["dscg_dept_codg"] = fed.DscgDeptCodg
  7142. fisEncounterDtosData["dscg_dept_name"] = fed.DscgDeptName
  7143. fisEncounterDtosData["med_mdtrt_type"] = fed.MedMdtrtType
  7144. fisEncounterDtosData["med_type"] = fed.MedType
  7145. for _, fod := range fods {
  7146. fsiOrderDtosData := make(map[string]interface{})
  7147. //医嘱集合
  7148. fsiOrderDtosData["rx_id"] = fod.RxID
  7149. fsiOrderDtosData["rxno"] = fod.Rxno
  7150. fsiOrderDtosData["grpno"] = fod.Grpno
  7151. fsiOrderDtosData["long_drord_flag"] = fod.LongDrordFlag
  7152. fsiOrderDtosData["hilist_type"] = fod.HilistType
  7153. fsiOrderDtosData["chrg_type"] = fod.ChrgType
  7154. fsiOrderDtosData["drord_bhvr"] = fod.DrordBhvr
  7155. fsiOrderDtosData["hilist_code"] = fod.HosplistCode
  7156. fsiOrderDtosData["hilist_name"] = fod.HosplistName
  7157. fsiOrderDtosData["hilist_dosform"] = fod.HilistDosform
  7158. fsiOrderDtosData["hilist_lv"] = fod.HilistLv
  7159. fsiOrderDtosData["hilist_pric"] = fod.HilistPric
  7160. fsiOrderDtosData["lv1_hosp_item_pric"] = fod.Lv1HospItemPric
  7161. fsiOrderDtosData["lv2_hosp_item_pric"] = fod.Lv2HospItemPric
  7162. fsiOrderDtosData["lv3_hosp_item_pric"] = fod.Lv3HospItemPric
  7163. fsiOrderDtosData["hilist_memo"] = fod.HilistMemo
  7164. fsiOrderDtosData["hosplist_code"] = fod.HosplistCode
  7165. fsiOrderDtosData["hosplist_name"] = fod.HosplistName
  7166. fsiOrderDtosData["hosplist_dosform"] = fod.HosplistDosform
  7167. fsiOrderDtosData["cnt"] = fod.Cnt
  7168. fsiOrderDtosData["pric"] = fod.Pric
  7169. fsiOrderDtosData["sumamt"] = fod.Sumamt
  7170. fsiOrderDtosData["ownpay_amt"] = fod.OwnpayAmt
  7171. fsiOrderDtosData["selfpay_amt"] = fod.SelfpayAmt
  7172. fsiOrderDtosData["spec"] = fod.Spec
  7173. fsiOrderDtosData["spec_unt"] = fod.SpecUnt
  7174. fsiOrderDtosData["drord_begn_date"] = fod.DrordBegnDate
  7175. fsiOrderDtosData["drord_stop_date"] = fod.DrordStopDate
  7176. fsiOrderDtosData["drord_dept_codg"] = fod.DrordDeptCodg
  7177. fsiOrderDtosData["drord_dept_name"] = fod.DrordDeptName
  7178. fsiOrderDtosData["drord_dr_codg"] = fod.DrordDrCodg
  7179. fsiOrderDtosData["drord_dr_name"] = fod.DrordDrName
  7180. fsiOrderDtosData["drord_dr_profttl"] = fod.DrordDrProfttl
  7181. fsiOrderDtosData["curr_drord_flag"] = fod.CurrDrordFlag
  7182. fsiOrderDtosDatas = append(fsiOrderDtosDatas, fsiOrderDtosData)
  7183. }
  7184. fisEncounterDtosData["fsi_order_dtos"] = fsiOrderDtosDatas
  7185. fisEncounterDtosData["matn_stas"] = fed.MatnStas
  7186. fisEncounterDtosData["medfee_sumamt"] = fed.MedfeeSumamt
  7187. fisEncounterDtosData["ownpay_amt"] = fed.OwnpayAmt
  7188. fisEncounterDtosData["selfpay_amt"] = fed.SelfpayAmt
  7189. fisEncounterDtosData["acct_payamt"] = fed.AcctPayamt
  7190. fisEncounterDtosData["ma_amt"] = fed.MaAmt
  7191. fisEncounterDtosData["hifp_payamt"] = fed.HifpPayamt
  7192. fisEncounterDtosData["setl_totlnum"] = fed.SetlTotlnum
  7193. fisEncounterDtosData["insutype"] = fed.Insutype
  7194. fisEncounterDtosData["reim_flag"] = fed.ReimFlag
  7195. fisEncounterDtosData["out_setl_flag"] = fed.OutSetlFlag
  7196. //手术操作
  7197. for _, fopd := range fopds {
  7198. fsiOperationDtosData["setl_list_oprn_id"] = fopd.Setl_list_oprn_id
  7199. fsiOperationDtosData["oprn_code"] = fopd.Oprn_code
  7200. fsiOperationDtosData["oprn_name"] = fopd.Oprn_name
  7201. fsiOperationDtosData["main_oprn_flag"] = fopd.Main_oprn_flag
  7202. fsiOperationDtosData["oprn_date"] = fopd.Oprn_date
  7203. fsiOperationDtosData["anst_way"] = fopd.Anst_way
  7204. fsiOperationDtosData["oper_dr_name"] = fopd.Oper_dr_name
  7205. fsiOperationDtosData["oper_dr_code"] = fopd.Oper_dr_code
  7206. fsiOperationDtosData["anst_dr_name"] = fopd.Anst_dr_name
  7207. fsiOperationDtosData["anst_dr_code"] = fopd.Anst_dr_code
  7208. fsiOperationDtosDatas = append(fsiOperationDtosDatas, fsiOperationDtosData)
  7209. }
  7210. fisEncounterDtosData["fsi_operation_dtos"] = fsiOperationDtosDatas
  7211. patientDtosinputData["patn_id"] = pd.PatnID
  7212. patientDtosinputData["patn_name"] = pd.PatnName
  7213. patientDtosinputData["gend"] = pd.Gend
  7214. patientDtosinputData["brdy"] = pd.Brdy
  7215. patientDtosinputData["poolarea"] = pd.Poolarea
  7216. patientDtosinputData["curr_mdtrt_id"] = pd.CurrMdtrtID
  7217. patientDtosinputData["fsi_his_data_dto"] = ""
  7218. patientDtosinputData["fsi_encounter_dtos"] = fisEncounterDtosData
  7219. inputData["syscode"] = "LinkDialysis"
  7220. inputData["trig_scen"] = trig_scen
  7221. inputData["rule_ids"] = ""
  7222. inputData["task_id"] = ""
  7223. inputData["patient_dtos"] = patientDtosinputData
  7224. input["data"] = inputData
  7225. inputMessage["infno"] = "3102"
  7226. inputMessage["input"] = input //交易输入
  7227. bytesData, err := json.Marshal(inputMessage)
  7228. fmt.Println(string(bytesData))
  7229. if err != nil {
  7230. fmt.Println(err.Error())
  7231. return err.Error(), ""
  7232. }
  7233. reader := bytes.NewReader(bytesData)
  7234. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7235. gdyb_url := beego.AppConfig.String("gdyb_url")
  7236. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7237. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7238. url := gdyb_url + "3102"
  7239. request, err := http.NewRequest("POST", url, reader)
  7240. if err != nil {
  7241. fmt.Println(err.Error())
  7242. return err.Error(), ""
  7243. }
  7244. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  7245. request.Header.Set("x-tif-paasid", gdyb_paasid)
  7246. request.Header.Set("x-tif-signature", signature)
  7247. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  7248. request.Header.Set("x-tif-nonce", nonce)
  7249. client := http.Client{}
  7250. resp, err := client.Do(request)
  7251. if err != nil {
  7252. fmt.Println(err.Error())
  7253. return err.Error(), ""
  7254. }
  7255. respBytes, err := ioutil.ReadAll(resp.Body)
  7256. if err != nil {
  7257. fmt.Println(err.Error())
  7258. return err.Error(), ""
  7259. }
  7260. str := string(respBytes)
  7261. fmt.Println(str)
  7262. return str, string(bytesData)
  7263. }
  7264. // 分页函数
  7265. func paginate(data []map[string]interface{}, pageSize int) [][]map[string]interface{} {
  7266. var pages [][]map[string]interface{}
  7267. totalItems := len(data)
  7268. for i := 0; i < totalItems; i += pageSize {
  7269. end := i + pageSize
  7270. if end > totalItems {
  7271. end = totalItems
  7272. }
  7273. pages = append(pages, data[i:end])
  7274. }
  7275. return pages
  7276. }
  7277. func Gzyb3501(struct3501 models.Struct3501, secret_key string) (string, string) {
  7278. // 生成签名
  7279. nonce := GetRandomString(32)
  7280. timestamp := time.Now().Unix()
  7281. signature := setSignature(timestamp, nonce, secret_key)
  7282. // 生成输入报文
  7283. //inputMessage := SetInputMessage(timestamp, struct3501.OrgName, struct3501.Opter, struct3501.FixmedinsHilistId, struct3501.InsuplcAdmdvs, struct3501.MdtrtareaAdmvs, struct3501.Cainfo,"")
  7284. sign := GetSignInInfo(struct3501.FixmedinsCode)
  7285. inputMessage := SetGZInputMessage(nonce, timestamp, struct3501.OrgName, struct3501.Opter, struct3501.FixmedinsCode, struct3501.InsuplcAdmdvs, struct3501.MdtrtareaAdmvs, sign)
  7286. input := make(map[string]interface{})
  7287. inputData := make(map[string]interface{})
  7288. inputMessage["infno"] = "3501" // 交易编码
  7289. inputData["med_list_codg"] = struct3501.MedListCodg // 定点医药机构目录编号
  7290. inputData["fixmedins_hilist_id"] = struct3501.FixmedinsHilistId // 定点医药机构目录编号
  7291. inputData["fixmedins_hilist_name"] = struct3501.OrgName // 定点医药机构目录名称
  7292. inputData["rx_flag"] = struct3501.RxFlag //
  7293. inputData["invdate"] = struct3501.Invdate // 人员编号 (来自1101接口返回)
  7294. inputData["inv_cnt"] = struct3501.InvCnt // 人员编号 (来自1101接口返回)
  7295. inputData["manu_lotnum"] = struct3501.ManuLotnum // 人员编号 (来自1101接口返回)
  7296. inputData["fixmedins_bchno"] = struct3501.FixmedinsBchno // 人员编号 (来自1101接口返回)
  7297. inputData["manu_date"] = struct3501.ManuDate // 人员编号 (来自1101接口返回)
  7298. inputData["expy_end"] = struct3501.ExpyEnd // 人员编号 (来自1101接口返回)
  7299. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  7300. input["invinfo"] = inputData
  7301. inputMessage["input"] = input //交易输入
  7302. bytesData, err := json.Marshal(inputMessage)
  7303. fmt.Println(string(bytesData))
  7304. if err != nil {
  7305. fmt.Println(err.Error())
  7306. return err.Error(), ""
  7307. }
  7308. reader := bytes.NewReader(bytesData)
  7309. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7310. gdyb_url := beego.AppConfig.String("gdyb_url")
  7311. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7312. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7313. url := gdyb_url + "3501"
  7314. request, err := http.NewRequest("POST", url, reader)
  7315. if err != nil {
  7316. fmt.Println(err.Error())
  7317. return err.Error(), ""
  7318. }
  7319. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  7320. request.Header.Set("x-tif-paasid", gdyb_paasid)
  7321. request.Header.Set("x-tif-signature", signature)
  7322. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  7323. request.Header.Set("x-tif-nonce", nonce)
  7324. client := http.Client{}
  7325. resp, err := client.Do(request)
  7326. if err != nil {
  7327. fmt.Println(err.Error())
  7328. return err.Error(), ""
  7329. }
  7330. respBytes, err := ioutil.ReadAll(resp.Body)
  7331. if err != nil {
  7332. fmt.Println(err.Error())
  7333. return err.Error(), ""
  7334. }
  7335. str := string(respBytes)
  7336. fmt.Println(str)
  7337. return str, string(bytesData)
  7338. }
  7339. func Gzyb3502(struct3502 models.Struct3502, secret_key string) (string, string) {
  7340. // 生成签名
  7341. nonce := GetRandomString(32)
  7342. timestamp := time.Now().Unix()
  7343. signature := setSignature(timestamp, nonce, secret_key)
  7344. sign := GetSignInInfo(struct3502.FixmedinsCode)
  7345. inputMessage := SetGZInputMessage(nonce, timestamp, struct3502.OrgName, struct3502.Opter, struct3502.FixmedinsCode, struct3502.InsuplcAdmdvs, struct3502.MdtrtareaAdmvs, sign)
  7346. // 生成输入报文
  7347. //inputMessage := SetGdInputMessage(timestamp, struct3502.OrgName, struct3502.Opter, struct3502.FixmedinsCode, struct3502.InsuplcAdmdvs, struct3502.MdtrtareaAdmvs, struct3502.Cainfo,sign)
  7348. input := make(map[string]interface{})
  7349. inputData := make(map[string]interface{})
  7350. inputMessage["infno"] = "3502" // 交易编码
  7351. inputData["med_list_codg"] = struct3502.MedListCodg // 定点医药机构目录编号
  7352. inputData["inv_chg_type"] = struct3502.InvChgType // 定点医药机构目录编号
  7353. inputData["fixmedins_hilist_id"] = struct3502.FixmedinsHilistId // 定点医药机构目录编号
  7354. inputData["fixmedins_hilist_name"] = struct3502.FixmedinsHilistName // 定点医药机构目录名称
  7355. inputData["fixmedins_bchno"] = struct3502.FixmedinsBchno // 人员编号 (来自1101接口返回)
  7356. inputData["pric"] = struct3502.Pric // 人员编号 (来自1101接口返回)
  7357. inputData["cnt"] = struct3502.Cnt // 人员编号 (来自1101接口返回)
  7358. inputData["rx_flag"] = struct3502.RxFlag //
  7359. inputData["inv_chg_time"] = struct3502.InvChgTime // 人员编号 (来自1101接口返回)
  7360. inputData["inv_chg_opter_name"] = "" // 人员编号 (来自1101接口返回)
  7361. inputData["memo"] = struct3502.Memo // 人员编号 (来自1101接口返回)
  7362. inputData["trdn_flag"] = "" // 人员编号 (来自1101接口返回)
  7363. feedetail := make([]map[string]interface{}, 0)
  7364. codes := strings.Split(struct3502.DrugTracCodg, ",")
  7365. for _, item := range codes {
  7366. druginputData := make(map[string]interface{})
  7367. druginputData["drug_trac_codg"] = item
  7368. feedetail = append(feedetail, druginputData)
  7369. }
  7370. inputData["drugtracinfo"] = feedetail
  7371. input["invinfo"] = inputData
  7372. inputMessage["input"] = input //交易输入
  7373. bytesData, err := json.Marshal(inputMessage)
  7374. fmt.Println(string(bytesData))
  7375. if err != nil {
  7376. fmt.Println(err.Error())
  7377. return err.Error(), ""
  7378. }
  7379. reader := bytes.NewReader(bytesData)
  7380. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7381. //gdyb_url := beego.AppConfig.String("gdyb_url")
  7382. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7383. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7384. url := "http://hosp-gz.gd.hsip.gov.cn/ebus/gdyb_api/prd/hsa/hgs/" + "3502"
  7385. request, err := http.NewRequest("POST", url, reader)
  7386. if err != nil {
  7387. fmt.Println(err.Error())
  7388. return err.Error(), ""
  7389. }
  7390. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  7391. request.Header.Set("x-tif-paasid", gdyb_paasid)
  7392. request.Header.Set("x-tif-signature", signature)
  7393. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  7394. request.Header.Set("x-tif-nonce", nonce)
  7395. client := http.Client{}
  7396. resp, err := client.Do(request)
  7397. if err != nil {
  7398. fmt.Println(err.Error())
  7399. return err.Error(), ""
  7400. }
  7401. respBytes, err := ioutil.ReadAll(resp.Body)
  7402. if err != nil {
  7403. fmt.Println(err.Error())
  7404. return err.Error(), ""
  7405. }
  7406. str := string(respBytes)
  7407. fmt.Println(str)
  7408. return str, string(bytesData)
  7409. }
  7410. func Gzyb3503(struct3503 models.Struct3503, secret_key string) (string, string) {
  7411. // 生成签名
  7412. nonce := GetRandomString(32)
  7413. timestamp := time.Now().Unix()
  7414. signature := setSignature(timestamp, nonce, secret_key)
  7415. // 生成输入报文
  7416. sign := GetSignInInfo(struct3503.FixmedinsCode)
  7417. inputMessage := SetGZInputMessage(nonce, timestamp, struct3503.OrgName, struct3503.Opter, struct3503.FixmedinsCode, struct3503.InsuplcAdmdvs, struct3503.MdtrtareaAdmvs, sign)
  7418. input := make(map[string]interface{})
  7419. inputMessage["infno"] = "3503"
  7420. item := struct3503
  7421. feedetailInfo := make(map[string]interface{})
  7422. feedetailInfo["med_list_codg"] = item.MedListCodg
  7423. feedetailInfo["fixmedins_hilist_id"] = item.FixmedinsHilistId
  7424. feedetailInfo["fixmedins_hilist_name"] = item.FixmedinsHilistName
  7425. feedetailInfo["dynt_no"] = ""
  7426. feedetailInfo["fixmedins_bchno"] = item.FixmedinsBchno // 人员编号 (来自1101接口返回)
  7427. feedetailInfo["spler_name"] = item.SplerName // 人员编号 (来自1101接口返回)
  7428. feedetailInfo["spler_pmtno"] = "" // 人员编号 (来自1101接口返回)
  7429. feedetailInfo["manu_lotnum"] = item.ManuLotnum // 人员编号 (来自1101接口返回)
  7430. feedetailInfo["prodentp_name"] = item.ProdentpName // 人员编号 (来自1101接口返回)
  7431. feedetailInfo["aprvno"] = item.Aprvno // 人员编号 (来自1101接口返回)
  7432. feedetailInfo["manu_date"] = item.ManuDate // 人员编号 (来自1101接口返回)
  7433. feedetailInfo["expy_end"] = item.ExpyEnd // 人员编号 (来自1101接口返回)
  7434. feedetailInfo["finl_trns_pric"] = item.FinlTrnsPric // 人员编号 (来自1101接口返回)
  7435. feedetailInfo["purc_retn_cnt"] = item.PurcRetnCnt // 人员编号 (来自1101接口返回)
  7436. feedetailInfo["purc_invo_codg"] = item.PurcInvoCodg // 人员编号 (来自1101接口返回)
  7437. feedetailInfo["purc_invo_no"] = item.PurcInvoNo // 人员编号 (来自1101接口返回)
  7438. feedetailInfo["rx_flag"] = item.RxFlag // 人员编号 (来自1101接口返回)
  7439. feedetailInfo["purc_retn_stoin_time"] = item.PurcRetnStoinTime // 人员编号 (来自1101接口返回)
  7440. feedetailInfo["purc_retn_opter_name"] = item.PurcRetnOpterName // 人员编号 (来自1101接口返回)
  7441. feedetailInfo["prod_geay_flag"] = "" // 人员编号 (来自1101接口返回)
  7442. feedetailInfo["memo"] = "" // 人员编号 (来自1101接口返回)
  7443. input["purcinfo"] = feedetailInfo
  7444. inputMessage["input"] = input //交易输入
  7445. bytesData, err := json.Marshal(inputMessage)
  7446. fmt.Println(string(bytesData))
  7447. if err != nil {
  7448. fmt.Println(err.Error())
  7449. return err.Error(), ""
  7450. }
  7451. reader := bytes.NewReader(bytesData)
  7452. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7453. gdyb_url := beego.AppConfig.String("gdyb_url")
  7454. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7455. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7456. url := gdyb_url + "3503"
  7457. request, err := http.NewRequest("POST", url, reader)
  7458. if err != nil {
  7459. fmt.Println(err.Error())
  7460. return err.Error(), ""
  7461. }
  7462. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  7463. request.Header.Set("x-tif-paasid", gdyb_paasid)
  7464. request.Header.Set("x-tif-signature", signature)
  7465. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  7466. request.Header.Set("x-tif-nonce", nonce)
  7467. client := http.Client{}
  7468. resp, err := client.Do(request)
  7469. if err != nil {
  7470. fmt.Println(err.Error())
  7471. return err.Error(), ""
  7472. }
  7473. respBytes, err := ioutil.ReadAll(resp.Body)
  7474. if err != nil {
  7475. fmt.Println(err.Error())
  7476. return err.Error(), ""
  7477. }
  7478. str := string(respBytes)
  7479. fmt.Println(str)
  7480. return str, string(bytesData)
  7481. }
  7482. func Gzyb3504(struct3504 models.Struct3504, secret_key string) (string, string) {
  7483. // 生成签名
  7484. nonce := GetRandomString(32)
  7485. timestamp := time.Now().Unix()
  7486. signature := setSignature(timestamp, nonce, secret_key)
  7487. // 生成输入报文
  7488. //inputMessage := SetGdInputMessage(timestamp, struct3504.OrgName, struct3504.Opter, struct3504.FixmedinsCode, struct3504.InsuplcAdmdvs, struct3504.MdtrtareaAdmvs, struct3504.Cainfo)
  7489. sign := GetSignInInfo(struct3504.FixmedinsCode)
  7490. inputMessage := SetGZInputMessage(nonce, timestamp, struct3504.OrgName, struct3504.Opter, struct3504.FixmedinsCode, struct3504.InsuplcAdmdvs, struct3504.MdtrtareaAdmvs, sign)
  7491. input := make(map[string]interface{})
  7492. inputData := make(map[string]interface{})
  7493. inputMessage["infno"] = "3504" // 交易编码
  7494. inputData["med_list_codg"] = struct3504.MedListCodg // 定点医药机构目录编号
  7495. inputData["fixmedins_hilist_id"] = struct3504.FixmedinsHilistId // 定点医药机构目录编号
  7496. inputData["fixmedins_hilist_name"] = struct3504.FixmedinsHilistName // 定点医药机构目录名称
  7497. inputData["fixmedins_bchno"] = struct3504.FixmedinsBchno // 人员编号 (来自1101接口返回)
  7498. inputData["spler_name"] = struct3504.SplerName // 人员编号 (来自1101接口返回)
  7499. inputData["spler_pmtno"] = "" // 人员编号 (来自1101接口返回)
  7500. inputData["manu_date"] = struct3504.ManuDate // 人员编号 (来自1101接口返回)
  7501. inputData["expy_end"] = struct3504.ExpyEnd // 人员编号 (来自1101接口返回)
  7502. inputData["finl_trns_pric"] = struct3504.FinlTrnsPric // 人员编号 (来自1101接口返回)
  7503. inputData["purc_retn_cnt"] = struct3504.PurcRetnCnt // 人员编号 (来自1101接口返回)
  7504. inputData["purc_invo_codg"] = struct3504.PurcInvoCodg // 人员编号 (来自1101接口返回)
  7505. inputData["purc_invo_no"] = struct3504.PurcInvoNo // 人员编号 (来自1101接口返回)
  7506. inputData["rx_flag"] = struct3504.RxFlag
  7507. inputData["purc_retn_stoin_time"] = struct3504.PurcRetnStoin
  7508. inputData["purc_retn_opter_name"] = struct3504.PurcRetnStoin
  7509. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  7510. inputData["medins_prod_purc_no"] = "" // 人员编号 (来自1101接口返回)
  7511. input["purcinfo"] = inputData
  7512. inputMessage["input"] = input //交易输入
  7513. bytesData, err := json.Marshal(inputMessage)
  7514. fmt.Println(string(bytesData))
  7515. if err != nil {
  7516. fmt.Println(err.Error())
  7517. return err.Error(), ""
  7518. }
  7519. reader := bytes.NewReader(bytesData)
  7520. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7521. gdyb_url := beego.AppConfig.String("gdyb_url")
  7522. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7523. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7524. url := gdyb_url + "3504"
  7525. request, err := http.NewRequest("POST", url, reader)
  7526. if err != nil {
  7527. fmt.Println(err.Error())
  7528. return err.Error(), ""
  7529. }
  7530. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  7531. request.Header.Set("x-tif-paasid", gdyb_paasid)
  7532. request.Header.Set("x-tif-signature", signature)
  7533. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  7534. request.Header.Set("x-tif-nonce", nonce)
  7535. client := http.Client{}
  7536. resp, err := client.Do(request)
  7537. if err != nil {
  7538. fmt.Println(err.Error())
  7539. return err.Error(), ""
  7540. }
  7541. respBytes, err := ioutil.ReadAll(resp.Body)
  7542. if err != nil {
  7543. fmt.Println(err.Error())
  7544. return err.Error(), ""
  7545. }
  7546. str := string(respBytes)
  7547. fmt.Println(str)
  7548. return str, string(bytesData)
  7549. }
  7550. func Gzyb3505(struct3505 models.Struct3505, secret_key string) (string, string) {
  7551. // 生成签名
  7552. nonce := GetRandomString(32)
  7553. timestamp := time.Now().Unix()
  7554. signature := setSignature(timestamp, nonce, secret_key)
  7555. // 生成输入报文
  7556. //inputMessage := SetGdInputMessage(timestamp, struct3505.OrgName, struct3505.Opter, struct3505.FixmedinsHilistId, struct3505.InsuplcAdmdvs, struct3505.MdtrtareaAdmvs, struct3505.Cainfo)
  7557. sign := GetSignInInfo(struct3505.FixmedinsCode)
  7558. inputMessage := SetGZInputMessage(nonce, timestamp, struct3505.OrgName, struct3505.Opter, struct3505.FixmedinsCode, struct3505.InsuplcAdmdvs, struct3505.MdtrtareaAdmvs, sign)
  7559. input := make(map[string]interface{})
  7560. inputData := make(map[string]interface{})
  7561. inputMessage["infno"] = "3505" // 交易编码
  7562. inputData["med_list_codg"] = struct3505.MedListCodg // 定点医药机构目录编号
  7563. inputData["fixmedins_hilist_id"] = struct3505.FixmedinsHilistId // 定点医药机构目录编号
  7564. inputData["fixmedins_hilist_name"] = struct3505.FixmedinsHilistName // 定点医药机构目录名称
  7565. inputData["fixmedins_bchno"] = struct3505.FixmedinsBchno // 人员编号 (来自1101接口返回)
  7566. inputData["prsc_dr_cert_type"] = struct3505.PrscDrCertType // 人员编号 (来自1101接口返回)
  7567. inputData["prsc_dr_certno"] = struct3505.PrscDrCertno // 人员编号 (来自1101接口返回)
  7568. inputData["prsc_dr_name"] = struct3505.PrscDrName // 人员编号 (来自1101接口返回)
  7569. inputData["phar_cert_type"] = struct3505.PharCertType // 人员编号 (来自1101接口返回)
  7570. inputData["phar_certno"] = struct3505.PharCertno // 人员编号 (来自1101接口返回)
  7571. inputData["phar_name"] = struct3505.PharName // 人员编号 (来自1101接口返回)
  7572. inputData["phar_prac_cert_no"] = struct3505.PharPracCertNo // 人员编号 (来自1101接口返回)
  7573. inputData["hi_feesetl_type"] = struct3505.HiFeesetlType // 人员编号 (来自1101接口返回)
  7574. inputData["setl_id"] = struct3505.SetlId // 人员编号 (来自1101接口返回)
  7575. inputData["mdtrt_sn"] = struct3505.MdtrtSn // 人员编号 (来自1101接口返回)
  7576. inputData["psn_no"] = struct3505.PsnNo // 人员编号 (来自1101接口返回)
  7577. inputData["psn_cert_type"] = struct3505.PsnCertType // 人员编号 (来自1101接口返回)
  7578. inputData["certno"] = struct3505.CertNo // 人员编号 (来自1101接口返回)
  7579. inputData["psn_name"] = struct3505.PsnName // 人员编号 (来自1101接口返回)
  7580. inputData["manu_lotnum"] = struct3505.ManuLotnum // 人员编号 (来自1101接口返回)
  7581. inputData["manu_date"] = struct3505.ManuDate // 人员编号 (来自1101接口返回)
  7582. inputData["expy_end"] = struct3505.ExpyEnd // 人员编号 (来自1101接口返回)
  7583. inputData["rx_flag"] = struct3505.RxFlag // 人员编号 (来自1101接口返回)
  7584. inputData["trdn_flag"] = struct3505.TrdnFlag // 人员编号 (来自1101接口返回)
  7585. inputData["finl_trns_pric"] = struct3505.FinlTrnsPric // 人员编号 (来自1101接口返回)
  7586. inputData["rxno"] = struct3505.Rxno // 人员编号 (来自1101接口返回)
  7587. inputData["rx_circ_flag"] = struct3505.RxCircFlag // 人员编号 (来自1101接口返回)
  7588. inputData["rtal_docno"] = struct3505.RtalDocno // 人员编号 (来自1101接口返回)
  7589. inputData["stoout_no"] = struct3505.StooutNo // 人员编号 (来自1101接口返回)
  7590. inputData["MDTRT_SETL_TYPE"] = struct3505.MdtrtSetlType // 人员编号 (来自1101接口返回)
  7591. inputData["bchno"] = struct3505.Bchno // 人员编号 (来自1101接口返回)
  7592. codes := strings.Split(struct3505.DrugTracCodg, ",")
  7593. inputData["drug_trac_codg"] = codes[0] // 人员编号 (来自1101接口返回)
  7594. inputData["drug_prod_barc"] = struct3505.DrugProdBarc // 人员编号 (来自1101接口返回)
  7595. inputData["shelf_posi"] = struct3505.ShelfPosi // 人员编号 (来自1101接口返回)
  7596. inputData["sel_retn_cnt"] = struct3505.SelRetnCnt // 人员编号 (来自1101接口返回)
  7597. inputData["sel_retn_time"] = struct3505.SelRetnTime // 人员编号 (来自1101接口返回)
  7598. inputData["sel_retn_opter_name"] = struct3505.SelRetnOpterName // 人员编号 (来自1101接口返回)
  7599. inputData["memo"] = struct3505.Memo // 人员编号 (来自1101接口返回)
  7600. //drug_trac_cod .g
  7601. feedetail := make([]map[string]interface{}, 0)
  7602. //codes = strings.Split(struct3505.DrugTracCodg, ",")
  7603. for _, item := range codes {
  7604. if len(item) > 0{
  7605. druginputData := make(map[string]interface{})
  7606. druginputData["drug_trac_codg"] = item
  7607. feedetail = append(feedetail, druginputData)
  7608. }
  7609. }
  7610. inputData["drugtracinfo"] = feedetail
  7611. input["selinfo"] = inputData
  7612. inputMessage["input"] = input //交易输入
  7613. input["selinfo"] = inputData
  7614. inputMessage["input"] = input //交易输入
  7615. bytesData, err := json.Marshal(inputMessage)
  7616. fmt.Println(string(bytesData))
  7617. if err != nil {
  7618. fmt.Println(err.Error())
  7619. return err.Error(), ""
  7620. }
  7621. reader := bytes.NewReader(bytesData)
  7622. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7623. //gdyb_url := ""
  7624. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7625. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7626. //url := "" + "3505"
  7627. url := "http://hosp-gz.gd.hsip.gov.cn/ebus/gdyb_api/prd/hsa/hgs/" + "3505"
  7628. fmt.Println(gdyb_paasid)
  7629. fmt.Println(url)
  7630. request, err := http.NewRequest("POST", url, reader)
  7631. if err != nil {
  7632. fmt.Println(err.Error())
  7633. return err.Error(), ""
  7634. }
  7635. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  7636. request.Header.Set("x-tif-paasid", gdyb_paasid)
  7637. request.Header.Set("x-tif-signature", signature)
  7638. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  7639. request.Header.Set("x-tif-nonce", nonce)
  7640. client := http.Client{}
  7641. resp, err := client.Do(request)
  7642. if err != nil {
  7643. fmt.Println(err.Error())
  7644. return err.Error(), ""
  7645. }
  7646. respBytes, err := ioutil.ReadAll(resp.Body)
  7647. if err != nil {
  7648. fmt.Println(err.Error())
  7649. return err.Error(), ""
  7650. }
  7651. str := string(respBytes)
  7652. fmt.Println(str)
  7653. return str, string(bytesData)
  7654. }
  7655. func Gzyb3506(struct3506 models.Struct3506, secret_key string) (string, string) {
  7656. // 生成签名
  7657. nonce := GetRandomString(32)
  7658. timestamp := time.Now().Unix()
  7659. signature := setSignature(timestamp, nonce, secret_key)
  7660. // 生成输入报文
  7661. //inputMessage := SetGdInputMessage(timestamp, struct3506.OrgName, struct3506.Opter, struct3506.FixmedinsCode, struct3506.InsuplcAdmdvs, struct3506.MdtrtareaAdmvs, struct3506.Cainfo)
  7662. sign := GetSignInInfo(struct3506.FixmedinsCode)
  7663. inputMessage := SetGZInputMessage(nonce, timestamp, struct3506.OrgName, struct3506.Opter, struct3506.FixmedinsCode, struct3506.InsuplcAdmdvs, struct3506.MdtrtareaAdmvs, sign)
  7664. input := make(map[string]interface{})
  7665. inputData := make(map[string]interface{})
  7666. inputMessage["infno"] = "3506" // 交易编码
  7667. inputData["med_list_codg"] = struct3506.MedListCodg // 定点医药机构目录编号
  7668. inputData["fixmedins_hilist_id"] = struct3506.FixmedinsHilistId // 定点医药机构目录编号
  7669. inputData["fixmedins_hilist_name"] = struct3506.OrgName // 定点医药机构目录名称
  7670. inputData["fixmedins_bchno"] = struct3506.FixmedinsBchno // 人员编号 (来自1101接口返回)
  7671. inputData["setl_id"] = struct3506.SetlId // 人员编号 (来自1101接口返回)
  7672. inputData["psn_no"] = struct3506.PsnNo // 人员编号 (来自1101接口返回)
  7673. inputData["psn_cert_type"] = struct3506.PsnCertType // 人员编号 (来自1101接口返回)
  7674. inputData["certno"] = struct3506.Certno // 人员编号 (来自1101接口返回)
  7675. inputData["psn_name"] = struct3506.PsnName // 人员编号 (来自1101接口返回)
  7676. inputData["manu_lotnum"] = struct3506.ManuLotnum // 人员编号 (来自1101接口返回)
  7677. inputData["manu_date"] = struct3506.ManuDate // 人员编号 (来自1101接口返回)
  7678. inputData["expy_end"] = struct3506.ExpyEnd // 人员编号 (来自1101接口返回)
  7679. inputData["rx_flag"] = struct3506.RxFlag // 人员编号 (来自1101接口返回)
  7680. inputData["trdn_flag"] = struct3506.TrdnFlag // 人员编号 (来自1101接口返回)
  7681. inputData["finl_trns_pric"] = struct3506.FinlTrnsPric // 人员编号 (来自1101接口返回)
  7682. inputData["sel_retn_cnt"] = struct3506.SelRetnCnt // 人员编号 (来自1101接口返回)
  7683. inputData["sel_retn_time"] = struct3506.SelRetnTime // 人员编号 (来自1101接口返回)
  7684. inputData["sel_retn_opter_name"] = struct3506.SelRetnOpterName // 人员编号 (来自1101接口返回)
  7685. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  7686. inputData["medins_prod_sel_no"] = "" // 人员编号 (来自1101接口返回)
  7687. input["selinfo"] = inputData
  7688. inputMessage["input"] = input //交易输入
  7689. bytesData, err := json.Marshal(inputMessage)
  7690. fmt.Println(string(bytesData))
  7691. if err != nil {
  7692. fmt.Println(err.Error())
  7693. return err.Error(), ""
  7694. }
  7695. reader := bytes.NewReader(bytesData)
  7696. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7697. gdyb_url := beego.AppConfig.String("gdyb_url")
  7698. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7699. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7700. url := gdyb_url + "3506"
  7701. request, err := http.NewRequest("POST", url, reader)
  7702. if err != nil {
  7703. fmt.Println(err.Error())
  7704. return err.Error(), ""
  7705. }
  7706. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  7707. request.Header.Set("x-tif-paasid", gdyb_paasid)
  7708. request.Header.Set("x-tif-signature", signature)
  7709. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  7710. request.Header.Set("x-tif-nonce", nonce)
  7711. client := http.Client{}
  7712. resp, err := client.Do(request)
  7713. if err != nil {
  7714. fmt.Println(err.Error())
  7715. return err.Error(), ""
  7716. }
  7717. respBytes, err := ioutil.ReadAll(resp.Body)
  7718. if err != nil {
  7719. fmt.Println(err.Error())
  7720. return err.Error(), ""
  7721. }
  7722. str := string(respBytes)
  7723. fmt.Println(str)
  7724. return str, string(bytesData)
  7725. }
  7726. func Gzyb3507(struct3507 models.Struct3507, secret_key string) (string, string) {
  7727. // 生成签名
  7728. nonce := GetRandomString(32)
  7729. timestamp := time.Now().Unix()
  7730. signature := setSignature(timestamp, nonce, secret_key)
  7731. // 生成输入报文
  7732. //inputMessage := SetGdInputMessage(timestamp, struct3507.OrgName, struct3507.Opter, struct3507.FixmedinsCode, struct3507.InsuplcAdmdvs, struct3507.MdtrtareaAdmvs, struct3507.Cainfo)
  7733. sign := GetSignInInfo(struct3507.FixmedinsCode)
  7734. inputMessage := SetGZInputMessage(nonce, timestamp, struct3507.OrgName, struct3507.Opter, struct3507.FixmedinsCode, struct3507.InsuplcAdmdvs, struct3507.MdtrtareaAdmvs, sign)
  7735. input := make(map[string]interface{})
  7736. inputData := make(map[string]interface{})
  7737. inputMessage["infno"] = "3507" // 交易编码
  7738. inputData["fixmedins_bchno"] = struct3507.FixmedinsCode // 人员编号 (来自1101接口返回)
  7739. inputData["inv_data_type"] = struct3507.InvDataType // 人员编号 (来自1101接口返回)
  7740. input["data"] = inputData
  7741. inputMessage["input"] = input //交易输入
  7742. bytesData, err := json.Marshal(inputMessage)
  7743. fmt.Println(string(bytesData))
  7744. if err != nil {
  7745. fmt.Println(err.Error())
  7746. return err.Error(), ""
  7747. }
  7748. reader := bytes.NewReader(bytesData)
  7749. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7750. gdyb_url := beego.AppConfig.String("gdyb_url")
  7751. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7752. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7753. url := gdyb_url + "3507"
  7754. request, err := http.NewRequest("POST", url, reader)
  7755. if err != nil {
  7756. fmt.Println(err.Error())
  7757. return err.Error(), ""
  7758. }
  7759. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  7760. request.Header.Set("x-tif-paasid", gdyb_paasid)
  7761. request.Header.Set("x-tif-signature", signature)
  7762. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  7763. request.Header.Set("x-tif-nonce", nonce)
  7764. client := http.Client{}
  7765. resp, err := client.Do(request)
  7766. if err != nil {
  7767. fmt.Println(err.Error())
  7768. return err.Error(), ""
  7769. }
  7770. respBytes, err := ioutil.ReadAll(resp.Body)
  7771. if err != nil {
  7772. fmt.Println(err.Error())
  7773. return err.Error(), ""
  7774. }
  7775. str := string(respBytes)
  7776. fmt.Println(str)
  7777. return str, string(bytesData)
  7778. }
  7779. func Gzyb3508(struct3508 models.Struct3508, secret_key string) (string, string) {
  7780. // 生成签名
  7781. nonce := GetRandomString(32)
  7782. timestamp := time.Now().Unix()
  7783. signature := setSignature(timestamp, nonce, secret_key)
  7784. // 生成输入报文
  7785. //inputMessage := SetGdInputMessage(timestamp, struct3508.OrgName, struct3508.Opter, struct3508.FixmedinsCode, struct3508.InsuplcAdmdvs, struct3508.MdtrtareaAdmvs, struct3508.Cainfo)
  7786. sign := GetSignInInfo(struct3508.FixmedinsCode)
  7787. inputMessage := SetGZInputMessage(nonce, timestamp, struct3508.OrgName, struct3508.Opter, struct3508.FixmedinsCode, struct3508.InsuplcAdmdvs, struct3508.MdtrtareaAdmvs, sign)
  7788. input := make(map[string]interface{})
  7789. inputData := make(map[string]interface{})
  7790. inputMessage["infno"] = "3508"
  7791. inputData["fixmedins_code"] = struct3508.FixmedinsCode
  7792. inputData["medins_list_codg"] = struct3508.MedListCodg
  7793. inputData["fixmedins_bchno"] = ""
  7794. inputData["begndate"] = struct3508.Begndate
  7795. inputData["enddate"] = struct3508.Enddate
  7796. inputData["medins_prod_inv_no"] = ""
  7797. inputData["medins_list_name"] = ""
  7798. inputData["rx_flag"] = ""
  7799. inputData["list_sp_item_flag"] = ""
  7800. inputData["trdn_flag"] = ""
  7801. inputData["invdate"] = ""
  7802. inputData["manu_lotnum"] = ""
  7803. inputData["manu_date"] = ""
  7804. inputData["expy_end"] = ""
  7805. inputData["memo"] = ""
  7806. inputData["vali_flag"] = ""
  7807. inputData["rid"] = ""
  7808. inputData["crter_id"] = ""
  7809. inputData["crter_name"] = ""
  7810. inputData["crte_optins_no"] = ""
  7811. inputData["opter_id"] = ""
  7812. inputData["opter_name"] = ""
  7813. inputData["optins_no"] = ""
  7814. inputData["poolarea_no"] = ""
  7815. inputData["fixmedins_bchno"] = ""
  7816. inputData["inv_data_type"] = ""
  7817. input["data"] = inputData
  7818. inputMessage["input"] = input //交易输入
  7819. bytesData, err := json.Marshal(inputMessage)
  7820. fmt.Println(string(bytesData))
  7821. if err != nil {
  7822. fmt.Println(err.Error())
  7823. return err.Error(), ""
  7824. }
  7825. reader := bytes.NewReader(bytesData)
  7826. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7827. gdyb_url := beego.AppConfig.String("gdyb_url")
  7828. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7829. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7830. url := gdyb_url + "3508"
  7831. request, err := http.NewRequest("POST", url, reader)
  7832. if err != nil {
  7833. fmt.Println(err.Error())
  7834. return err.Error(), ""
  7835. }
  7836. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  7837. request.Header.Set("x-tif-paasid", gdyb_paasid)
  7838. request.Header.Set("x-tif-signature", signature)
  7839. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  7840. request.Header.Set("x-tif-nonce", nonce)
  7841. client := http.Client{}
  7842. resp, err := client.Do(request)
  7843. if err != nil {
  7844. fmt.Println(err.Error())
  7845. return err.Error(), ""
  7846. }
  7847. respBytes, err := ioutil.ReadAll(resp.Body)
  7848. if err != nil {
  7849. fmt.Println(err.Error())
  7850. return err.Error(), ""
  7851. }
  7852. str := string(respBytes)
  7853. fmt.Println(str)
  7854. return str, string(bytesData)
  7855. }
  7856. func Gzyb3509(struct3509 models.Struct3509, secret_key string) (string, string) {
  7857. // 生成签名
  7858. nonce := GetRandomString(32)
  7859. timestamp := time.Now().Unix()
  7860. signature := setSignature(timestamp, nonce, secret_key)
  7861. // 生成输入报文
  7862. //inputMessage := SetGdInputMessage(timestamp, struct3509.OrgName, struct3509.Opter, struct3509.FixmedinsCode, struct3509.InsuplcAdmdvs, struct3509.MdtrtareaAdmvs, struct3509.Cainfo)
  7863. sign := GetSignInInfo(struct3509.FixmedinsCode)
  7864. inputMessage := SetGZInputMessage(nonce, timestamp, struct3509.OrgName, struct3509.Opter, struct3509.FixmedinsCode, struct3509.InsuplcAdmdvs, struct3509.MdtrtareaAdmvs, sign)
  7865. input := make(map[string]interface{})
  7866. inputData := make(map[string]interface{})
  7867. inputMessage["infno"] = "3509"
  7868. inputData["fixmedins_code"] = struct3509.FixmedinsCode
  7869. //inputData["med_list_codg"] = struct3509.MedinsListCodg
  7870. inputData["medins_list_codg"] = struct3509.MedListCodg
  7871. inputData["fixmedins_bchno"] = ""
  7872. inputData["begndate"] = struct3509.Begndate
  7873. inputData["enddate"] = struct3509.Enddate
  7874. inputData["medins_prod_inv_no"] = ""
  7875. inputData["medins_list_name"] = ""
  7876. inputData["rx_flag"] = ""
  7877. inputData["list_sp_item_flag"] = ""
  7878. inputData["trdn_flag"] = ""
  7879. inputData["invdate"] = ""
  7880. inputData["manu_lotnum"] = ""
  7881. inputData["manu_date"] = ""
  7882. inputData["expy_end"] = ""
  7883. inputData["memo"] = ""
  7884. inputData["vali_flag"] = ""
  7885. inputData["rid"] = ""
  7886. inputData["crter_id"] = ""
  7887. inputData["crter_name"] = ""
  7888. inputData["crte_optins_no"] = ""
  7889. inputData["opter_id"] = ""
  7890. inputData["opter_name"] = ""
  7891. inputData["optins_no"] = ""
  7892. inputData["poolarea_no"] = ""
  7893. inputData["fixmedins_bchno"] = ""
  7894. inputData["inv_data_type"] = ""
  7895. input["data"] = inputData
  7896. inputMessage["input"] = input //交易输入
  7897. bytesData, err := json.Marshal(inputMessage)
  7898. fmt.Println(string(bytesData))
  7899. if err != nil {
  7900. fmt.Println(err.Error())
  7901. return err.Error(), ""
  7902. }
  7903. reader := bytes.NewReader(bytesData)
  7904. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7905. gdyb_url := beego.AppConfig.String("gdyb_url")
  7906. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7907. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7908. url := gdyb_url + "3509"
  7909. request, err := http.NewRequest("POST", url, reader)
  7910. if err != nil {
  7911. fmt.Println(err.Error())
  7912. return err.Error(), ""
  7913. }
  7914. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  7915. request.Header.Set("x-tif-paasid", gdyb_paasid)
  7916. request.Header.Set("x-tif-signature", signature)
  7917. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  7918. request.Header.Set("x-tif-nonce", nonce)
  7919. client := http.Client{}
  7920. resp, err := client.Do(request)
  7921. if err != nil {
  7922. fmt.Println(err.Error())
  7923. return err.Error(), ""
  7924. }
  7925. respBytes, err := ioutil.ReadAll(resp.Body)
  7926. if err != nil {
  7927. fmt.Println(err.Error())
  7928. return err.Error(), ""
  7929. }
  7930. str := string(respBytes)
  7931. fmt.Println(str)
  7932. return str, string(bytesData)
  7933. }
  7934. func Gzyb3510(struct3510 models.Struct3510, secret_key string) (string, string) {
  7935. // 生成签名
  7936. nonce := GetRandomString(32)
  7937. timestamp := time.Now().Unix()
  7938. signature := setSignature(timestamp, nonce, secret_key)
  7939. // 生成输入报文
  7940. //inputMessage := SetGdInputMessage(timestamp, struct3510.OrgName, struct3510.Opter, struct3510.FixmedinsCode, struct3510.InsuplcAdmdvs, struct3510.MdtrtareaAdmvs, struct3510.Cainfo)
  7941. sign := GetSignInInfo(struct3510.FixmedinsCode)
  7942. inputMessage := SetGZInputMessage(nonce, timestamp, struct3510.OrgName, struct3510.Opter, struct3510.FixmedinsCode, struct3510.InsuplcAdmdvs, struct3510.MdtrtareaAdmvs, sign)
  7943. input := make(map[string]interface{})
  7944. inputData := make(map[string]interface{})
  7945. inputMessage["infno"] = "3510"
  7946. inputData["fixmedins_code"] = struct3510.FixmedinsCode
  7947. //inputData["medins_list_codg"] = struct3510.MedinsListCodg
  7948. inputData["medins_list_codg"] = struct3510.MedListCodg
  7949. inputData["fixmedins_bchno"] = ""
  7950. inputData["begndate"] = struct3510.Begndate
  7951. inputData["enddate"] = struct3510.Enddate
  7952. inputData["medins_prod_inv_no"] = ""
  7953. inputData["medins_list_name"] = ""
  7954. inputData["rx_flag"] = ""
  7955. inputData["list_sp_item_flag"] = ""
  7956. inputData["trdn_flag"] = ""
  7957. inputData["invdate"] = ""
  7958. inputData["manu_lotnum"] = ""
  7959. inputData["manu_date"] = ""
  7960. inputData["expy_end"] = ""
  7961. inputData["memo"] = ""
  7962. inputData["vali_flag"] = ""
  7963. inputData["rid"] = ""
  7964. inputData["crter_id"] = ""
  7965. inputData["crter_name"] = ""
  7966. inputData["crte_optins_no"] = ""
  7967. inputData["opter_id"] = ""
  7968. inputData["opter_name"] = ""
  7969. inputData["optins_no"] = ""
  7970. inputData["poolarea_no"] = ""
  7971. inputData["fixmedins_bchno"] = ""
  7972. inputData["inv_data_type"] = ""
  7973. input["data"] = inputData
  7974. inputMessage["input"] = input //交易输入
  7975. bytesData, err := json.Marshal(inputMessage)
  7976. fmt.Println(string(bytesData))
  7977. if err != nil {
  7978. fmt.Println(err.Error())
  7979. return err.Error(), ""
  7980. }
  7981. reader := bytes.NewReader(bytesData)
  7982. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7983. gdyb_url := beego.AppConfig.String("gdyb_url")
  7984. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7985. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7986. url := gdyb_url + "3510"
  7987. request, err := http.NewRequest("POST", url, reader)
  7988. if err != nil {
  7989. fmt.Println(err.Error())
  7990. return err.Error(), ""
  7991. }
  7992. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  7993. request.Header.Set("x-tif-paasid", gdyb_paasid)
  7994. request.Header.Set("x-tif-signature", signature)
  7995. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  7996. request.Header.Set("x-tif-nonce", nonce)
  7997. client := http.Client{}
  7998. resp, err := client.Do(request)
  7999. if err != nil {
  8000. fmt.Println(err.Error())
  8001. return err.Error(), ""
  8002. }
  8003. respBytes, err := ioutil.ReadAll(resp.Body)
  8004. if err != nil {
  8005. fmt.Println(err.Error())
  8006. return err.Error(), ""
  8007. }
  8008. str := string(respBytes)
  8009. fmt.Println(str)
  8010. return str, string(bytesData)
  8011. }
  8012. func Gzyb3511(struct3511 models.Struct3511, secret_key string) (string, string) {
  8013. // 生成签名
  8014. nonce := GetRandomString(32)
  8015. timestamp := time.Now().Unix()
  8016. signature := setSignature(timestamp, nonce, secret_key)
  8017. // 生成输入报文
  8018. //inputMessage := SetGdInputMessage(timestamp, struct3511.OrgName, struct3511.Opter, struct3511.FixmedinsCode, struct3511.InsuplcAdmdvs, struct3511.MdtrtareaAdmvs, struct3511.Cainfo)
  8019. sign := GetSignInInfo(struct3511.FixmedinsCode)
  8020. inputMessage := SetGZInputMessage(nonce, timestamp, struct3511.OrgName, struct3511.Opter, struct3511.FixmedinsCode, struct3511.InsuplcAdmdvs, struct3511.MdtrtareaAdmvs, sign)
  8021. input := make(map[string]interface{})
  8022. inputData := make(map[string]interface{})
  8023. inputMessage["infno"] = "3511"
  8024. inputData["fixmedins_code"] = struct3511.FixmedinsCode
  8025. //inputData["medins_list_codg"] = struct3511.MedinsListCodg
  8026. inputData["medins_list_codg"] = struct3511.MedListCodg
  8027. inputData["fixmedins_bchno"] = ""
  8028. inputData["begndate"] = struct3511.Begndate
  8029. inputData["enddate"] = struct3511.Enddate
  8030. inputData["medins_prod_inv_no"] = ""
  8031. inputData["medins_list_name"] = ""
  8032. inputData["rx_flag"] = ""
  8033. inputData["list_sp_item_flag"] = ""
  8034. inputData["trdn_flag"] = ""
  8035. inputData["invdate"] = ""
  8036. inputData["manu_lotnum"] = ""
  8037. inputData["manu_date"] = ""
  8038. inputData["expy_end"] = ""
  8039. inputData["memo"] = ""
  8040. inputData["vali_flag"] = ""
  8041. inputData["rid"] = ""
  8042. inputData["crter_id"] = ""
  8043. inputData["crter_name"] = ""
  8044. inputData["crte_optins_no"] = ""
  8045. inputData["opter_id"] = ""
  8046. inputData["opter_name"] = ""
  8047. inputData["optins_no"] = ""
  8048. inputData["poolarea_no"] = ""
  8049. inputData["fixmedins_bchno"] = ""
  8050. inputData["inv_data_type"] = ""
  8051. input["data"] = inputData
  8052. inputMessage["input"] = input //交易输入
  8053. bytesData, err := json.Marshal(inputMessage)
  8054. fmt.Println(string(bytesData))
  8055. if err != nil {
  8056. fmt.Println(err.Error())
  8057. return err.Error(), ""
  8058. }
  8059. reader := bytes.NewReader(bytesData)
  8060. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  8061. gdyb_url := beego.AppConfig.String("gdyb_url")
  8062. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  8063. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  8064. url := gdyb_url + "3511"
  8065. request, err := http.NewRequest("POST", url, reader)
  8066. if err != nil {
  8067. fmt.Println(err.Error())
  8068. return err.Error(), ""
  8069. }
  8070. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  8071. request.Header.Set("x-tif-paasid", gdyb_paasid)
  8072. request.Header.Set("x-tif-signature", signature)
  8073. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  8074. request.Header.Set("x-tif-nonce", nonce)
  8075. client := http.Client{}
  8076. resp, err := client.Do(request)
  8077. if err != nil {
  8078. fmt.Println(err.Error())
  8079. return err.Error(), ""
  8080. }
  8081. respBytes, err := ioutil.ReadAll(resp.Body)
  8082. if err != nil {
  8083. fmt.Println(err.Error())
  8084. return err.Error(), ""
  8085. }
  8086. str := string(respBytes)
  8087. fmt.Println(str)
  8088. return str, string(bytesData)
  8089. }
  8090. func Gzyb3512(struct3512 models.Struct3512, secret_key string) (string, string) {
  8091. // 生成签名
  8092. nonce := GetRandomString(32)
  8093. timestamp := time.Now().Unix()
  8094. signature := setSignature(timestamp, nonce, secret_key)
  8095. // 生成输入报文
  8096. //inputMessage := SetGdInputMessage(timestamp, struct3512.OrgName, struct3512.Opter, struct3512.FixmedinsCode, struct3512.InsuplcAdmdvs, struct3512.MdtrtareaAdmvs, struct3512.Cainfo)
  8097. sign := GetSignInInfo(struct3512.FixmedinsCode)
  8098. inputMessage := SetGZInputMessage(nonce, timestamp, struct3512.OrgName, struct3512.Opter, struct3512.FixmedinsCode, struct3512.InsuplcAdmdvs, struct3512.MdtrtareaAdmvs, sign)
  8099. input := make(map[string]interface{})
  8100. inputData := make(map[string]interface{})
  8101. inputMessage["infno"] = "3512"
  8102. inputData["fixmedins_code"] = struct3512.FixmedinsCode
  8103. //inputData["medins_list_codg"] = struct3512.MedinsListCodg
  8104. inputData["medins_list_codg"] = struct3512.MedListCodg
  8105. inputData["fixmedins_bchno"] = ""
  8106. inputData["begndate"] = struct3512.Begndate
  8107. inputData["enddate"] = struct3512.Enddate
  8108. inputData["medins_prod_inv_no"] = ""
  8109. inputData["medins_list_name"] = ""
  8110. inputData["rx_flag"] = ""
  8111. inputData["list_sp_item_flag"] = ""
  8112. inputData["trdn_flag"] = ""
  8113. inputData["invdate"] = ""
  8114. inputData["manu_lotnum"] = ""
  8115. inputData["manu_date"] = ""
  8116. inputData["expy_end"] = ""
  8117. inputData["memo"] = ""
  8118. inputData["vali_flag"] = ""
  8119. inputData["rid"] = ""
  8120. inputData["crter_id"] = ""
  8121. inputData["crter_name"] = ""
  8122. inputData["crte_optins_no"] = ""
  8123. inputData["opter_id"] = ""
  8124. inputData["opter_name"] = ""
  8125. inputData["optins_no"] = ""
  8126. inputData["poolarea_no"] = ""
  8127. inputData["fixmedins_bchno"] = ""
  8128. inputData["inv_data_type"] = ""
  8129. input["data"] = inputData
  8130. inputMessage["input"] = input //交易输入
  8131. bytesData, err := json.Marshal(inputMessage)
  8132. fmt.Println(string(bytesData))
  8133. if err != nil {
  8134. fmt.Println(err.Error())
  8135. return err.Error(), ""
  8136. }
  8137. reader := bytes.NewReader(bytesData)
  8138. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  8139. gdyb_url := beego.AppConfig.String("gdyb_url")
  8140. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  8141. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  8142. url := gdyb_url + "3512"
  8143. request, err := http.NewRequest("POST", url, reader)
  8144. if err != nil {
  8145. fmt.Println(err.Error())
  8146. return err.Error(), ""
  8147. }
  8148. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  8149. request.Header.Set("x-tif-paasid", gdyb_paasid)
  8150. request.Header.Set("x-tif-signature", signature)
  8151. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  8152. request.Header.Set("x-tif-nonce", nonce)
  8153. client := http.Client{}
  8154. resp, err := client.Do(request)
  8155. if err != nil {
  8156. fmt.Println(err.Error())
  8157. return err.Error(), ""
  8158. }
  8159. respBytes, err := ioutil.ReadAll(resp.Body)
  8160. if err != nil {
  8161. fmt.Println(err.Error())
  8162. return err.Error(), ""
  8163. }
  8164. str := string(respBytes)
  8165. fmt.Println(str)
  8166. return str, string(bytesData)
  8167. }
  8168. func Gzyb3513(struct3513 models.Struct3513, secret_key string) (string, string) {
  8169. // 生成签名
  8170. nonce := GetRandomString(32)
  8171. timestamp := time.Now().Unix()
  8172. signature := setSignature(timestamp, nonce, secret_key)
  8173. // 生成输入报文
  8174. //inputMessage := SetGdInputMessage(timestamp, struct3513.OrgName, struct3513.Opter, struct3513.FixmedinsCode, struct3513.InsuplcAdmdvs, struct3513.MdtrtareaAdmvs, struct3513.Cainfo)
  8175. sign := GetSignInInfo(struct3513.FixmedinsCode)
  8176. inputMessage := SetGZInputMessage(nonce, timestamp, struct3513.OrgName, struct3513.Opter, struct3513.FixmedinsCode, struct3513.InsuplcAdmdvs, struct3513.MdtrtareaAdmvs, sign)
  8177. input := make(map[string]interface{})
  8178. inputData := make(map[string]interface{})
  8179. inputMessage["infno"] = "3513"
  8180. inputData["fixmedins_code"] = struct3513.FixmedinsCode
  8181. //inputData["medins_list_codg"] = struct3513.MedinsListCodg
  8182. inputData["medins_list_codg"] = struct3513.MedListCodg
  8183. inputData["fixmedins_bchno"] = ""
  8184. inputData["begndate"] = struct3513.Begndate
  8185. inputData["enddate"] = struct3513.Enddate
  8186. inputData["medins_prod_inv_no"] = ""
  8187. inputData["med_list_codg"] = ""
  8188. inputData["medins_list_name"] = ""
  8189. inputData["rx_flag"] = ""
  8190. inputData["list_sp_item_flag"] = ""
  8191. inputData["trdn_flag"] = ""
  8192. inputData["invdate"] = ""
  8193. inputData["manu_lotnum"] = ""
  8194. inputData["manu_date"] = ""
  8195. inputData["expy_end"] = ""
  8196. inputData["memo"] = ""
  8197. inputData["vali_flag"] = ""
  8198. inputData["rid"] = ""
  8199. inputData["crter_id"] = ""
  8200. inputData["crter_name"] = ""
  8201. inputData["crte_optins_no"] = ""
  8202. inputData["opter_id"] = ""
  8203. inputData["opter_name"] = ""
  8204. inputData["optins_no"] = ""
  8205. inputData["poolarea_no"] = ""
  8206. inputData["fixmedins_bchno"] = ""
  8207. inputData["inv_data_type"] = ""
  8208. input["data"] = inputData
  8209. inputMessage["input"] = input //交易输入
  8210. bytesData, err := json.Marshal(inputMessage)
  8211. fmt.Println(string(bytesData))
  8212. if err != nil {
  8213. fmt.Println(err.Error())
  8214. return err.Error(), ""
  8215. }
  8216. reader := bytes.NewReader(bytesData)
  8217. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  8218. gdyb_url := beego.AppConfig.String("gdyb_url")
  8219. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  8220. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  8221. url := gdyb_url + "3513"
  8222. request, err := http.NewRequest("POST", url, reader)
  8223. if err != nil {
  8224. fmt.Println(err.Error())
  8225. return err.Error(), ""
  8226. }
  8227. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  8228. request.Header.Set("x-tif-paasid", gdyb_paasid)
  8229. request.Header.Set("x-tif-signature", signature)
  8230. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  8231. request.Header.Set("x-tif-nonce", nonce)
  8232. client := http.Client{}
  8233. resp, err := client.Do(request)
  8234. if err != nil {
  8235. fmt.Println(err.Error())
  8236. return err.Error(), ""
  8237. }
  8238. respBytes, err := ioutil.ReadAll(resp.Body)
  8239. if err != nil {
  8240. fmt.Println(err.Error())
  8241. return err.Error(), ""
  8242. }
  8243. str := string(respBytes)
  8244. fmt.Println(str)
  8245. return str, string(bytesData)
  8246. }
  8247. // 生成基础报文
  8248. 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{} {
  8249. // 生成签名
  8250. tempTime := time.Unix(timestamp, 0)
  8251. //timeFormat := tempTime.Format("20060102150405")
  8252. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  8253. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  8254. month := time.Unix(1557042972, 0).Format("1")
  8255. year := time.Now().Format("2006")
  8256. month = time.Now().Format("01")
  8257. day := time.Now().Format("02")
  8258. hour := time.Now().Format("15")
  8259. min := time.Now().Format("04")
  8260. sec := time.Now().Format("05")
  8261. msec := time.Now().Format("000")
  8262. // 生成输入报文
  8263. inputMessage := make(map[string]interface{})
  8264. inputMessage["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  8265. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  8266. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  8267. inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  8268. inputMessage["dev_no"] = "" // 设备编号
  8269. inputMessage["dev_safe_info"] = "" // 设备安全信息
  8270. inputMessage["cainfo"] = "" // 数字签名信息
  8271. inputMessage["signtype"] = "SM3" // 签名类型
  8272. inputMessage["infver"] = "V1.0" // 接收方系统代码
  8273. inputMessage["opter_type"] = "1" // 经办人类别
  8274. inputMessage["opter"] = doctor // 经办人
  8275. inputMessage["opter_name"] = doctor // 经办人姓名
  8276. inputMessage["inf_time"] = timeFormatOne // 交易时间
  8277. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  8278. inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  8279. inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号
  8280. //inputMessage["sign_no"] = "GZYBCS4101A20220202"
  8281. return inputMessage
  8282. }