gdyb_service.go 310KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898
  1. package service
  2. import (
  3. "bytes"
  4. //"crypto/md5"
  5. "crypto/sha256"
  6. "encoding/hex"
  7. "encoding/json"
  8. "fmt"
  9. "gdyb/models"
  10. //"strings"
  11. //"gdyb/utils"
  12. "github.com/astaxie/beego"
  13. "github.com/axgle/mahonia"
  14. "io"
  15. "io/ioutil"
  16. "math/rand"
  17. "mime/multipart"
  18. "net"
  19. "net/http"
  20. "os"
  21. "os/exec"
  22. "path/filepath"
  23. "strconv"
  24. "syscall"
  25. "time"
  26. "unsafe"
  27. )
  28. const (
  29. SceretKey = "RhaDw4H0RUbWYyTxmRKM1eSeN0qyGLds" // secretKey 私钥
  30. )
  31. // 机构信息
  32. func Gdyb1201(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, card_sn string) string {
  33. // 生成签名
  34. nonce := GetRandomString(32)
  35. timestamp := time.Now().Unix()
  36. signature := setSignature(timestamp, nonce, secret_key)
  37. // 生成输入报文
  38. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  39. input := make(map[string]interface{})
  40. inputData := make(map[string]interface{})
  41. inputMessage["infno"] = "1201" // 交易编码
  42. inputData["fixmedins_type"] = "1"
  43. inputData["fixmedins_name"] = org_name
  44. inputData["fixmedins_code"] = fixmedins_code
  45. input["medinsinfo"] = inputData
  46. inputMessage["input"] = input //交易输入
  47. bytesData, err := json.Marshal(inputMessage)
  48. fmt.Println(string(bytesData))
  49. if err != nil {
  50. fmt.Println(err.Error())
  51. return err.Error()
  52. }
  53. reader := bytes.NewReader(bytesData)
  54. gdyb_url := beego.AppConfig.String("gdyb_url")
  55. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  56. url := gdyb_url + "1201"
  57. request, err := http.NewRequest("POST", url, reader)
  58. if err != nil {
  59. fmt.Println(err.Error())
  60. return err.Error()
  61. }
  62. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  63. request.Header.Set("x-tif-paasid", gdyb_paasid)
  64. request.Header.Set("x-tif-signature", signature)
  65. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  66. request.Header.Set("x-tif-nonce", nonce)
  67. client := http.Client{}
  68. resp, err := client.Do(request)
  69. if err != nil {
  70. fmt.Println(err.Error())
  71. return err.Error()
  72. }
  73. respBytes, err := ioutil.ReadAll(resp.Body)
  74. if err != nil {
  75. fmt.Println(err.Error())
  76. return err.Error()
  77. }
  78. fmt.Println(string(respBytes))
  79. str2 := string(respBytes)
  80. return str2
  81. }
  82. // 人员基本信息
  83. func Gdyb1101(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, card_sn string, certificates string, psn_name string) (string, string) {
  84. //生成签名
  85. nonce := GetRandomString(32)
  86. timestamp := time.Now().Unix()
  87. signature := setSignature(timestamp, nonce, secret_key)
  88. //生成输入报文
  89. inputMessage := SetInputMessagenosign(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  90. input := make(map[string]interface{})
  91. inputData := make(map[string]interface{})
  92. inputMessage["infno"] = "1101" // 交易编码
  93. if certificates == "3" {
  94. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  95. inputData["certno"] = certNo // 证件号码
  96. inputData["psn_cert_type"] = "06" // 人员证件类型
  97. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  98. } else {
  99. if id_card_type == 1 {
  100. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  101. inputData["card_sn"] = card_sn // 卡识别码
  102. inputData["certno"] = certNo // 证件号码
  103. inputData["psn_cert_type"] = "" // 人员证件类型
  104. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  105. } else {
  106. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  107. inputData["card_sn"] = "" // 卡识别码
  108. inputData["certno"] = certNo // 证件号码
  109. inputData["psn_cert_type"] = "" // 人员证件类型
  110. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  111. }
  112. }
  113. inputData["begntime"] = "" // 开始时间
  114. inputData["psn_name"] = "" // 人员姓名
  115. input["data"] = inputData
  116. inputMessage["input"] = input //交易输入
  117. var inputLog string
  118. bytesData, err := json.Marshal(inputMessage)
  119. inputLog = string(bytesData)
  120. fmt.Println(string(bytesData))
  121. if err != nil {
  122. fmt.Println(err.Error())
  123. return err.Error(), ""
  124. }
  125. reader := bytes.NewReader(bytesData)
  126. gdyb_url := beego.AppConfig.String("gdyb_url")
  127. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  128. var url string
  129. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  130. url = gdyb_url
  131. } else {
  132. url = gdyb_url + "1101"
  133. }
  134. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  135. request, err := http.NewRequest("POST", url, reader)
  136. if err != nil {
  137. fmt.Println(err.Error())
  138. return err.Error(), ""
  139. }
  140. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  141. request.Header.Set("x-tif-paasid", gdyb_paasid)
  142. request.Header.Set("x-tif-signature", signature)
  143. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  144. request.Header.Set("x-tif-nonce", nonce)
  145. client := http.Client{}
  146. resp, err := client.Do(request)
  147. if err != nil {
  148. fmt.Println(err.Error())
  149. return err.Error(), ""
  150. }
  151. respBytes, err := ioutil.ReadAll(resp.Body)
  152. if err != nil {
  153. fmt.Println(err.Error())
  154. return err.Error(), ""
  155. }
  156. fmt.Println(string(respBytes))
  157. str := string(respBytes)
  158. return str, inputLog
  159. }
  160. func Gdyb1101A(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, name string) string {
  161. //生成签名
  162. nonce := GetRandomString(32)
  163. timestamp := time.Now().Unix()
  164. signature := setSignature(timestamp, nonce, secret_key)
  165. //生成输入报文
  166. inputMessage := SetInputMessagenosign(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  167. input := make(map[string]interface{})
  168. inputData := make(map[string]interface{})
  169. inputMessage["infno"] = "1101" // 交易编码
  170. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  171. inputData["card_sn"] = "" // 卡识别码
  172. inputData["certno"] = certNo // 证件号码
  173. inputData["psn_cert_type"] = "01" // 人员证件类型
  174. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  175. inputData["begntime"] = "" // 开始时间
  176. inputData["psn_name"] = name // 人员姓名
  177. input["data"] = inputData
  178. inputMessage["input"] = input //交易输入
  179. bytesData, err := json.Marshal(inputMessage)
  180. fmt.Println(string(bytesData))
  181. if err != nil {
  182. fmt.Println(err.Error())
  183. return err.Error()
  184. }
  185. reader := bytes.NewReader(bytesData)
  186. gdyb_url := beego.AppConfig.String("gdyb_url")
  187. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  188. var url string
  189. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721"{
  190. url = gdyb_url
  191. } else {
  192. url = gdyb_url + "1101"
  193. }
  194. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  195. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  196. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  197. if insuplc_admdvs == "421300" {
  198. var json2 string
  199. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101A", string(bytesData), json2)
  200. out, err := cmd.Output()
  201. if err != nil {
  202. fmt.Println("error:", err.Error())
  203. }
  204. fmt.Println(string(out))
  205. return hex.EncodeToString(out)
  206. } else {
  207. request, err := http.NewRequest("POST", url, reader)
  208. if err != nil {
  209. fmt.Println(err.Error())
  210. return err.Error()
  211. }
  212. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  213. request.Header.Set("x-tif-paasid", gdyb_paasid)
  214. request.Header.Set("x-tif-signature", signature)
  215. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  216. request.Header.Set("x-tif-nonce", nonce)
  217. client := http.Client{}
  218. resp, err := client.Do(request)
  219. if err != nil {
  220. fmt.Println(err.Error())
  221. return err.Error()
  222. }
  223. respBytes, err := ioutil.ReadAll(resp.Body)
  224. if err != nil {
  225. fmt.Println(err.Error())
  226. return err.Error()
  227. }
  228. fmt.Println(string(respBytes))
  229. str := string(respBytes)
  230. return str
  231. }
  232. }
  233. // 门诊挂号
  234. func Gdyb2201(psnNo string, insutype string, certNo string, org_name string, opera string, ipt_otp_no string, dept string, fixmedins_code string, dept_code string, doctor_id string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, doctor_name string) (string, string) {
  235. fmt.Println(opera)
  236. // 生成签名
  237. nonce := GetRandomString(32)
  238. timestamp := time.Now().Unix()
  239. signature := setSignature(timestamp, nonce, secret_key)
  240. tempTime := time.Unix(timestamp, 0)
  241. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  242. // 生成输入报文
  243. inputMessage := SetInputMessagenosign(nonce, timestamp, org_name, opera, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  244. input := make(map[string]interface{})
  245. inputData := make(map[string]interface{})
  246. inputMessage["infno"] = "2201" // 交易编码
  247. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  248. inputData["insutype"] = insutype // 险种类型(来自1101接口返回)
  249. inputData["begntime"] = timeFormatOne // 开始时间
  250. if id_card_type == 1 {
  251. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  252. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  253. } else {
  254. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  255. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  256. }
  257. inputData["ipt_otp_no"] = ipt_otp_no // 住院/门诊号
  258. inputData["atddr_no"] = doctor_id // 医师编码
  259. inputData["dr_name"] = doctor_name // 医师姓名
  260. inputData["dept_code"] = dept_code // 科室编码
  261. inputData["dept_name"] = dept // 科室名称
  262. inputData["caty"] = "A03.06" // 科别
  263. input["data"] = inputData
  264. inputMessage["input"] = input //交易输入
  265. var requestLog string
  266. bytesData, err := json.Marshal(inputMessage)
  267. requestLog = string(bytesData)
  268. fmt.Println(string(bytesData))
  269. if err != nil {
  270. fmt.Println(err.Error())
  271. return err.Error(), ""
  272. }
  273. reader := bytes.NewReader(bytesData)
  274. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2201"
  275. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2201"
  276. gdyb_url := beego.AppConfig.String("gdyb_url")
  277. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  278. var url string
  279. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  280. url = gdyb_url
  281. } else {
  282. url = gdyb_url + "2201"
  283. }
  284. if insuplc_admdvs == "421300" {
  285. var json2 string
  286. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2201", string(bytesData), json2)
  287. out, err := cmd.Output()
  288. if err != nil {
  289. fmt.Println("error:", err.Error())
  290. }
  291. fmt.Println(string(out))
  292. return hex.EncodeToString(out), requestLog
  293. } else {
  294. request, err := http.NewRequest("POST", url, reader)
  295. if err != nil {
  296. fmt.Println(err.Error())
  297. return err.Error(), ""
  298. }
  299. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  300. request.Header.Set("x-tif-paasid", gdyb_paasid)
  301. request.Header.Set("x-tif-signature", signature)
  302. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  303. request.Header.Set("x-tif-nonce", nonce)
  304. client := http.Client{}
  305. resp, err := client.Do(request)
  306. if err != nil {
  307. fmt.Println(err.Error())
  308. return err.Error(), ""
  309. }
  310. respBytes, err := ioutil.ReadAll(resp.Body)
  311. if err != nil {
  312. fmt.Println(err.Error())
  313. return err.Error(), ""
  314. }
  315. str := string(respBytes)
  316. fmt.Println(str)
  317. return str, requestLog
  318. }
  319. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2201"
  320. }
  321. func Gdyb2201A(psnNo string, insutype string, certNo string, org_name string, opera string, ipt_otp_no string, dept string, fixmedins_code string, dept_code string, doctor_id string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, doctor_name string, record_time string, token string,admin_user_id int64) (string, string) {
  322. fmt.Println(opera)
  323. // 生成签名
  324. nonce := GetRandomString(32)
  325. timestamp := time.Now().Unix()
  326. signature := setSignature(timestamp, nonce, secret_key)
  327. //tempTime := time.Unix(timestamp, 0)
  328. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  329. inputMessage := make(map[string]interface{})
  330. //tempTime := time.Unix(timestamp, 0)
  331. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  332. // 生成输入报文
  333. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127"{
  334. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs,opera)
  335. } else {
  336. inputMessage = SetInputMessage(nonce, timestamp, org_name, opera, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  337. }
  338. // 生成输入报文
  339. //inputMessage := SetInputMessagenosign(nonce, timestamp, org_name, opera, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  340. input := make(map[string]interface{})
  341. inputData := make(map[string]interface{})
  342. inputMessage["infno"] = "2201" // 交易编码
  343. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  344. inputData["insutype"] = insutype // 险种类型(来自1101接口返回)
  345. inputData["begntime"] = record_time // 开始时间
  346. if id_card_type == 1 {
  347. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  348. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  349. } else if id_card_type == 4 {
  350. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  351. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  352. } else {
  353. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  354. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  355. }
  356. inputData["ipt_otp_no"] = ipt_otp_no // 住院/门诊号
  357. inputData["atddr_no"] = doctor_id // 医师编码
  358. inputData["dr_name"] = doctor_name // 医师姓名
  359. inputData["dept_code"] = dept_code // 科室编码
  360. inputData["dept_name"] = dept // 科室名称
  361. inputData["caty"] = "A03.06" // 科别
  362. input["data"] = inputData
  363. inputMessage["input"] = input //交易输入
  364. var requestLog string
  365. bytesData, err := json.Marshal(inputMessage)
  366. requestLog = string(bytesData)
  367. fmt.Println(string(bytesData))
  368. if err != nil {
  369. fmt.Println(err.Error())
  370. return err.Error(), ""
  371. }
  372. reader := bytes.NewReader(bytesData)
  373. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2201"
  374. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2201"
  375. gdyb_url := beego.AppConfig.String("gdyb_url")
  376. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  377. var url string
  378. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721"{
  379. url = gdyb_url
  380. } else {
  381. url = gdyb_url + "2201"
  382. }
  383. if insuplc_admdvs == "421300" {
  384. var json2 string
  385. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2201", string(bytesData), json2)
  386. out, err := cmd.Output()
  387. if err != nil {
  388. fmt.Println("error:", err.Error())
  389. }
  390. fmt.Println(string(out))
  391. return hex.EncodeToString(out), requestLog
  392. } else {
  393. request, err := http.NewRequest("POST", url, reader)
  394. if err != nil {
  395. fmt.Println(err.Error())
  396. return err.Error(), ""
  397. }
  398. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  399. request.Header.Set("x-tif-paasid", gdyb_paasid)
  400. request.Header.Set("x-tif-signature", signature)
  401. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  402. request.Header.Set("x-tif-nonce", nonce)
  403. client := http.Client{}
  404. resp, err := client.Do(request)
  405. if err != nil {
  406. fmt.Println(err.Error())
  407. return err.Error(), ""
  408. }
  409. respBytes, err := ioutil.ReadAll(resp.Body)
  410. if err != nil {
  411. fmt.Println(err.Error())
  412. return err.Error(), ""
  413. }
  414. str := string(respBytes)
  415. fmt.Println(str)
  416. return str, requestLog
  417. }
  418. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2201"
  419. }
  420. // 门诊挂号撤销
  421. 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) {
  422. // 生成签名
  423. nonce := GetRandomString(32)
  424. timestamp := time.Now().Unix()
  425. signature := setSignature(timestamp, nonce, secret_key)
  426. // 生成输入报文
  427. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  428. inputMessage := make(map[string]interface{})
  429. //tempTime := time.Unix(timestamp, 0)
  430. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  431. // 生成输入报文
  432. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127"{
  433. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs,doctor)
  434. } else {
  435. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  436. }
  437. input := make(map[string]interface{})
  438. inputData := make(map[string]interface{})
  439. inputMessage["infno"] = "2202" // 交易编码
  440. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  441. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  442. inputData["ipt_otp_no"] = ipt_otp_no // 住院/门诊号
  443. input["data"] = inputData
  444. inputMessage["input"] = input //交易输入
  445. var requestLog string
  446. bytesData, err := json.Marshal(inputMessage)
  447. fmt.Println(string(bytesData))
  448. requestLog = string(bytesData)
  449. if err != nil {
  450. fmt.Println(err.Error())
  451. return err.Error(), ""
  452. }
  453. reader := bytes.NewReader(bytesData)
  454. gdyb_url := beego.AppConfig.String("gdyb_url")
  455. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  456. var url string
  457. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  458. url = gdyb_url
  459. } else {
  460. url = gdyb_url + "2202"
  461. }
  462. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2202"
  463. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2202"
  464. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2202"
  465. if insuplc_admdvs == "421300" {
  466. var json2 string
  467. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2202", string(bytesData), json2)
  468. out, err := cmd.Output()
  469. if err != nil {
  470. fmt.Println("error:", err.Error())
  471. }
  472. fmt.Println(string(out))
  473. return hex.EncodeToString(out), requestLog
  474. } else {
  475. request, err := http.NewRequest("POST", url, reader)
  476. if err != nil {
  477. fmt.Println(err.Error())
  478. return err.Error(), ""
  479. }
  480. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  481. request.Header.Set("x-tif-paasid", gdyb_paasid)
  482. request.Header.Set("x-tif-signature", signature)
  483. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  484. request.Header.Set("x-tif-nonce", nonce)
  485. client := http.Client{}
  486. resp, err := client.Do(request)
  487. if err != nil {
  488. fmt.Println(err.Error())
  489. return err.Error(), ""
  490. }
  491. respBytes, err := ioutil.ReadAll(resp.Body)
  492. if err != nil {
  493. fmt.Println(err.Error())
  494. return err.Error(), ""
  495. }
  496. str := string(respBytes)
  497. fmt.Println(str)
  498. return str, requestLog
  499. }
  500. }
  501. // 门诊就诊信息上传
  502. 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) {
  503. // 生成签名
  504. nonce := GetRandomString(32)
  505. timestamp := time.Now().Unix()
  506. signature := setSignature(timestamp, nonce, secret_key)
  507. inputMessage := make(map[string]interface{})
  508. //tempTime := time.Unix(timestamp, 0)
  509. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  510. // 生成输入报文
  511. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127"{
  512. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, op_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs,op_name)
  513. } else {
  514. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  515. }
  516. //inputMessage := SetInputMessage1111(nonce, timestamp, org_name, op_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs,op_name)
  517. input := make(map[string]interface{})
  518. inputData := make(map[string]interface{})
  519. diseinfo := make([]map[string]interface{}, 0)
  520. if med_type == "1111" || med_type == "1112" {
  521. med_type = "11"
  522. }
  523. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  524. inputMessage["infno"] = "2203" // 交易编码
  525. } else {
  526. inputMessage["infno"] = "2203" // 交易编码
  527. }
  528. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  529. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  530. inputData["med_type"] = med_type // 医疗类别 16门诊特殊病
  531. inputData["begntime"] = begin_time // 开始时间
  532. //inputData["begntime"] = // 开始时间
  533. inputData["main_cond_dscr"] = "" // 主要病情描述
  534. inputData["dise_codg"] = sick_code // 病种编码
  535. inputData["dise_name"] = sick_name // 病种名称
  536. if med_type == "12" {
  537. inputData["dise_codg"] = "" // 病种编码
  538. inputData["dise_name"] = "" // 病种名称
  539. }
  540. inputData["birctrl_type"] = "" // 计划生育手术类别
  541. inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
  542. for index, item := range config {
  543. diseinfo_sun := make(map[string]interface{})
  544. diseinfo_sun["diag_type"] = "1" // 诊断类别
  545. diseinfo_sun["diag_srt_no"] = index + 1 // 诊断排序号
  546. diseinfo_sun["diag_code"] = item.CountryCode // 诊断代码
  547. diseinfo_sun["diag_name"] = item.ClassName // 诊断名称
  548. diseinfo_sun["diag_dept"] = department // 诊断科室
  549. diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
  550. diseinfo_sun["dise_dor_name"] = doctor_name // 诊断医生姓名
  551. diseinfo_sun["diag_time"] = begin_time // 诊断时间
  552. diseinfo_sun["vali_flag"] = "1" // 有效标志
  553. diseinfo = append(diseinfo, diseinfo_sun)
  554. }
  555. input["diseinfo"] = diseinfo
  556. input["mdtrtinfo"] = inputData
  557. inputMessage["input"] = input //交易输入
  558. var requestLog string
  559. bytesData, err := json.Marshal(inputMessage)
  560. fmt.Println(string(bytesData))
  561. requestLog = string(bytesData)
  562. if err != nil {
  563. fmt.Println(err.Error())
  564. return err.Error(), ""
  565. }
  566. reader := bytes.NewReader(bytesData)
  567. gdyb_url := beego.AppConfig.String("gdyb_url")
  568. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  569. var url string
  570. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  571. url = gdyb_url
  572. } else {
  573. url = gdyb_url + "2203"
  574. }
  575. if insuplc_admdvs == "421300" {
  576. var json2 string
  577. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2203", string(bytesData), json2)
  578. out, err := cmd.Output()
  579. if err != nil {
  580. fmt.Println("error:", err.Error())
  581. }
  582. fmt.Println(string(out))
  583. return hex.EncodeToString(out), requestLog
  584. } else {
  585. request, err := http.NewRequest("POST", url, reader)
  586. if err != nil {
  587. fmt.Println(err.Error())
  588. return err.Error(), ""
  589. }
  590. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  591. request.Header.Set("x-tif-paasid", gdyb_paasid)
  592. request.Header.Set("x-tif-signature", signature)
  593. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  594. request.Header.Set("x-tif-nonce", nonce)
  595. client := http.Client{}
  596. resp, err := client.Do(request)
  597. if err != nil {
  598. fmt.Println(err.Error())
  599. return err.Error(), ""
  600. }
  601. respBytes, err := ioutil.ReadAll(resp.Body)
  602. if err != nil {
  603. fmt.Println(err.Error())
  604. return err.Error(), ""
  605. }
  606. str := string(respBytes)
  607. fmt.Println(str)
  608. return str, requestLog
  609. }
  610. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2203"
  611. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  612. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  613. }
  614. 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) {
  615. // 生成签名
  616. nonce := GetRandomString(32)
  617. timestamp := time.Now().Unix()
  618. signature := setSignature(timestamp, nonce, secret_key)
  619. //tempTime := time.Unix(timestamp, 0)
  620. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  621. // 生成输入报文
  622. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  623. input := make(map[string]interface{})
  624. inputData := make(map[string]interface{})
  625. diseinfo := make([]map[string]interface{}, 0)
  626. if med_type == "1111" || med_type == "1112" {
  627. med_type = "11"
  628. }
  629. inputMessage["infno"] = "2203" // 交易编码
  630. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  631. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  632. inputData["med_type"] = med_type // 医疗类别 16门诊特殊病
  633. inputData["begntime"] = begin_time // 开始时间
  634. //inputData["begntime"] = // 开始时间
  635. inputData["main_cond_dscr"] = "" // 主要病情描述
  636. inputData["dise_codg"] = sick_code // 病种编码
  637. inputData["dise_name"] = sick_name // 病种名称
  638. if med_type == "12" {
  639. inputData["dise_codg"] = "" // 病种编码
  640. inputData["dise_name"] = "" // 病种名称
  641. }
  642. inputData["birctrl_type"] = "" // 计划生育手术类别
  643. inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
  644. for index, item := range config {
  645. diseinfo_sun := make(map[string]interface{})
  646. diseinfo_sun["diag_type"] = "1" // 诊断类别
  647. diseinfo_sun["diag_srt_no"] = index // 诊断排序号
  648. diseinfo_sun["diag_code"] = item.CountryCode // 诊断代码
  649. diseinfo_sun["diag_name"] = item.ClassName // 诊断名称
  650. diseinfo_sun["diag_dept"] = department // 诊断科室
  651. diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
  652. diseinfo_sun["dise_dor_name"] = doctor_name // 诊断医生姓名
  653. diseinfo_sun["diag_time"] = begin_time // 诊断时间
  654. diseinfo_sun["vali_flag"] = "1" // 有效标志
  655. diseinfo = append(diseinfo, diseinfo_sun)
  656. }
  657. input["diseinfo"] = diseinfo
  658. input["mdtrtinfo"] = inputData
  659. inputMessage["input"] = input //交易输入
  660. var requestLog string
  661. bytesData, err := json.Marshal(inputMessage)
  662. fmt.Println(string(bytesData))
  663. requestLog = string(bytesData)
  664. if err != nil {
  665. fmt.Println(err.Error())
  666. return err.Error(), ""
  667. }
  668. reader := bytes.NewReader(bytesData)
  669. gdyb_url := beego.AppConfig.String("gdyb_url")
  670. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  671. var url string
  672. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  673. url = gdyb_url
  674. }else {
  675. url = gdyb_url + "2203"
  676. }
  677. if insuplc_admdvs == "421300" {
  678. var json2 string
  679. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2203", string(bytesData), json2)
  680. out, err := cmd.Output()
  681. if err != nil {
  682. fmt.Println("error:", err.Error())
  683. }
  684. fmt.Println(string(out))
  685. return hex.EncodeToString(out), requestLog
  686. } else {
  687. request, err := http.NewRequest("POST", url, reader)
  688. if err != nil {
  689. fmt.Println(err.Error())
  690. return err.Error(), ""
  691. }
  692. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  693. request.Header.Set("x-tif-paasid", gdyb_paasid)
  694. request.Header.Set("x-tif-signature", signature)
  695. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  696. request.Header.Set("x-tif-nonce", nonce)
  697. client := http.Client{}
  698. resp, err := client.Do(request)
  699. if err != nil {
  700. fmt.Println(err.Error())
  701. return err.Error(), ""
  702. }
  703. respBytes, err := ioutil.ReadAll(resp.Body)
  704. if err != nil {
  705. fmt.Println(err.Error())
  706. return err.Error(), ""
  707. }
  708. str := string(respBytes)
  709. fmt.Println(str)
  710. return str, requestLog
  711. }
  712. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2203"
  713. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  714. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  715. }
  716. // 门诊就诊信息上传
  717. 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) {
  718. // 生成签名
  719. nonce := GetRandomString(32)
  720. timestamp := time.Now().Unix()
  721. signature := setSignature(timestamp, nonce, secret_key)
  722. tempTime := time.Unix(timestamp, 0)
  723. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  724. // 生成输入报文
  725. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  726. input := make(map[string]interface{})
  727. inputData := make(map[string]interface{})
  728. diseinfo := make([]map[string]interface{}, 0)
  729. if med_type == "1111" || med_type == "1112" {
  730. med_type = "11"
  731. }
  732. inputMessage["infno"] = "2203A" // 交易编码
  733. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  734. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  735. inputData["med_type"] = med_type // 医疗类别 16门诊特殊病
  736. inputData["begntime"] = begin_time // 开始时间
  737. inputData["main_cond_dscr"] = "" // 主要病情描述
  738. inputData["dise_codg"] = sick_code // 病种编码
  739. inputData["dise_name"] = sick_name // 病种名称
  740. inputData["birctrl_type"] = "" // 计划生育手术类别
  741. inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
  742. inputData["matn_type"] = "" // 生育类别
  743. inputData["geso_val"] = "" // 孕周数
  744. for index, item := range config {
  745. diseinfo_sun := make(map[string]interface{})
  746. diseinfo_sun["diag_type"] = "1" // 诊断类别
  747. diseinfo_sun["diag_srt_no"] = index // 诊断排序号
  748. diseinfo_sun["diag_code"] = item.CountryCode // 诊断代码
  749. diseinfo_sun["diag_name"] = item.ClassName // 诊断名称
  750. diseinfo_sun["diag_dept"] = department // 诊断科室
  751. diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
  752. diseinfo_sun["dise_dor_name"] = doctor // 诊断医生姓名
  753. diseinfo_sun["diag_time"] = timeFormatOne // 诊断时间
  754. diseinfo_sun["vali_flag"] = "1" // 有效标志
  755. diseinfo = append(diseinfo, diseinfo_sun)
  756. }
  757. input["diseinfo"] = diseinfo
  758. input["mdtrtinfo"] = inputData
  759. inputMessage["input"] = input //交易输入
  760. var requestLog string
  761. bytesData, err := json.Marshal(inputMessage)
  762. fmt.Println(string(bytesData))
  763. requestLog = string(bytesData)
  764. if err != nil {
  765. fmt.Println(err.Error())
  766. return err.Error(), ""
  767. }
  768. reader := bytes.NewReader(bytesData)
  769. gdyb_url := beego.AppConfig.String("gdyb_url")
  770. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  771. var url string
  772. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  773. url = gdyb_url
  774. } else {
  775. url = gdyb_url + "2203"
  776. }
  777. if insuplc_admdvs == "421300" {
  778. var json2 string
  779. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2203A", string(bytesData), json2)
  780. out, err := cmd.Output()
  781. if err != nil {
  782. fmt.Println("error:", err.Error())
  783. }
  784. fmt.Println(string(out))
  785. return hex.EncodeToString(out), requestLog
  786. } else {
  787. request, err := http.NewRequest("POST", url, reader)
  788. if err != nil {
  789. fmt.Println(err.Error())
  790. return err.Error(), ""
  791. }
  792. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  793. request.Header.Set("x-tif-paasid", gdyb_paasid)
  794. request.Header.Set("x-tif-signature", signature)
  795. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  796. request.Header.Set("x-tif-nonce", nonce)
  797. client := http.Client{}
  798. resp, err := client.Do(request)
  799. if err != nil {
  800. fmt.Println(err.Error())
  801. return err.Error(), ""
  802. }
  803. respBytes, err := ioutil.ReadAll(resp.Body)
  804. if err != nil {
  805. fmt.Println(err.Error())
  806. return err.Error(), ""
  807. }
  808. str := string(respBytes)
  809. fmt.Println(str)
  810. return str, requestLog
  811. }
  812. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2203A"
  813. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  814. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  815. }
  816. 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) {
  817. // 生成签名
  818. nonce := GetRandomString(32)
  819. timestamp := time.Now().Unix()
  820. signature := setSignature(timestamp, nonce, secret_key)
  821. tempTime := time.Unix(timestamp, 0)
  822. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  823. // 生成输入报文
  824. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  825. input := make(map[string]interface{})
  826. inputData := make(map[string]interface{})
  827. diseinfo := make([]map[string]interface{}, 0)
  828. inputMessage["infno"] = "2203" // 交易编码
  829. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  830. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  831. inputData["med_type"] = "14" // 医疗类别 16门诊特殊病
  832. inputData["begntime"] = begin_time // 开始时间
  833. inputData["main_cond_dscr"] = "" // 主要病情描述
  834. inputData["dise_codg"] = sick_code // 病种编码
  835. inputData["dise_name"] = sick_name // 病种名称
  836. inputData["birctrl_type"] = "" // 计划生育手术类别
  837. inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
  838. inputData["matn_type"] = "" // 生育类别
  839. inputData["geso_val"] = "" // 孕周数
  840. for index, item := range config {
  841. diseinfo_sun := make(map[string]interface{})
  842. diseinfo_sun["diag_type"] = "1" // 诊断类别
  843. diseinfo_sun["diag_srt_no"] = index // 诊断排序号
  844. diseinfo_sun["diag_code"] = item.CountryCode // 诊断代码
  845. diseinfo_sun["diag_name"] = item.ClassName // 诊断名称
  846. diseinfo_sun["diag_dept"] = department // 诊断科室
  847. diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
  848. diseinfo_sun["dise_dor_name"] = doctor // 诊断医生姓名
  849. diseinfo_sun["diag_time"] = timeFormatOne // 诊断时间
  850. diseinfo_sun["vali_flag"] = "1" // 有效标志
  851. diseinfo = append(diseinfo, diseinfo_sun)
  852. }
  853. input["diseinfo"] = diseinfo
  854. input["mdtrtinfo"] = inputData
  855. inputMessage["input"] = input //交易输入
  856. var requestLog string
  857. bytesData, err := json.Marshal(inputMessage)
  858. fmt.Println(string(bytesData))
  859. requestLog = string(bytesData)
  860. if err != nil {
  861. fmt.Println(err.Error())
  862. return err.Error(), ""
  863. }
  864. reader := bytes.NewReader(bytesData)
  865. gdyb_url := beego.AppConfig.String("gdyb_url")
  866. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  867. var url string
  868. url = gdyb_url + "2203"
  869. if insuplc_admdvs == "421300" {
  870. var json2 string
  871. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2203A", string(bytesData), json2)
  872. out, err := cmd.Output()
  873. if err != nil {
  874. fmt.Println("error:", err.Error())
  875. }
  876. fmt.Println(string(out))
  877. return hex.EncodeToString(out), requestLog
  878. } else {
  879. request, err := http.NewRequest("POST", url, reader)
  880. if err != nil {
  881. fmt.Println(err.Error())
  882. return err.Error(), ""
  883. }
  884. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  885. request.Header.Set("x-tif-paasid", gdyb_paasid)
  886. request.Header.Set("x-tif-signature", signature)
  887. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  888. request.Header.Set("x-tif-nonce", nonce)
  889. client := http.Client{}
  890. resp, err := client.Do(request)
  891. if err != nil {
  892. fmt.Println(err.Error())
  893. return err.Error(), ""
  894. }
  895. respBytes, err := ioutil.ReadAll(resp.Body)
  896. if err != nil {
  897. fmt.Println(err.Error())
  898. return err.Error(), ""
  899. }
  900. str := string(respBytes)
  901. fmt.Println(str)
  902. return str, requestLog
  903. }
  904. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2203A"
  905. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  906. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  907. }
  908. type Custom struct {
  909. DetItemFeeSumamt string
  910. Cut string
  911. FeedetlSn string
  912. Price string
  913. MedListCodg string
  914. LmtUsedFlag int64
  915. HospApprFlag int64
  916. DoctorNumber string
  917. DoctorName string
  918. ProvinceDrugMedListCodg string
  919. ProvinceGoodMedListCodg string
  920. IsUser int64
  921. FeeOcurTime string
  922. Unit string
  923. }
  924. type RequestResult struct {
  925. Output Output `json:"output" form:"output"`
  926. Infcode int64 `gorm:"column:infcode" json:"infcode" form:"infcode"`
  927. WarnMsg string `gorm:"column:warn_msg" json:"warn_msg" form:"warn_msg"`
  928. Cainfo string `gorm:"column:cainfo" json:"cainfo" form:"cainfo"`
  929. ErrMsg string `gorm:"column:err_msg" json:"err_msg" form:"err_msg"`
  930. RespondTime string `gorm:"column:respond_time" json:"respond_time" form:"respond_time"`
  931. InfRefmsgid string `gorm:"column:inf_refmsgid" json:"inf_refmsgid" form:"inf_refmsgid"`
  932. }
  933. type Output struct {
  934. Result Result `json:"result" form:"result"`
  935. }
  936. type Result struct {
  937. BasMednFlag string `json:"bas_medn_flag" form:"bas_medn_flag"`
  938. MedChrgitmType string `json:"med_chrgitm_type" form:"med_chrgitm_type"`
  939. DetItemFeeSumamt int64 `json:"det_item_fee_sumamt" form:"det_item_fee_sumamt"`
  940. HiNegoDrugFlag string `json:"hi_nego_drug_flag" form:"hi_nego_drug_flag"`
  941. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
  942. FeedtlSn int64 `json:"feedtl_sn" form:"feedtl_sn"`
  943. UploadDate int64 `json:"upload_date" form:"upload_date"`
  944. AdviceId int64 `json:"advice_id" form:"advice_id"`
  945. Cnt int64 `json:"cnt" form:"cnt"`
  946. Pric float64 `json:"pric" form:"pric"`
  947. PatientId int64 `json:"patient_id" form:"patient_id"`
  948. PricUplmtAmt float64 `json:"pric_uplmt_amt" form:"pric_uplmt_amt"`
  949. SelfpayProp float64 `json:"selfpay_prop" form:"selfpay_prop"`
  950. OverlmtAmt float64 `json:"overlmt_amt" form:"overlmt_amt"`
  951. PreselfpayAmt float64 `json:"preselfpay_amt" form:"preselfpay_amt"`
  952. Status int64 `json:"status" form:"status"`
  953. Memo string `json:"memo" form:"memo"`
  954. FeedetlSn string `json:"feedetl_sn" form:"feedetl_sn"`
  955. Mtime int64 `json:"mtime" form:"mtime"`
  956. InscpScpAmt float64 `json:"inscp_scp_amt" form:"inscp_scp_amt"`
  957. DrtReimFlag string `json:"drt_reim_flag" form:"drt_reim_flag"`
  958. Ctime int64 `json:"ctime" form:"ctime"`
  959. ListSpItemFlag string `json:"list_sp_item_flag" form:"list_sp_item_flag"`
  960. ChldMedcFlag string `json:"chld_medc_flag" form:"chld_medc_flag"`
  961. LmtUsedFlag string `json:"lmt_used_flag" form:"lmt_used_flag"`
  962. ChrgitmLv string `json:"chrgitm_lv" form:"chrgitm_lv"`
  963. UserOrgId int64 `json:"user_org_id" form:"user_org_id"`
  964. HisPatientId int64 `json:"his_patient_id" form:"his_patient_id"`
  965. OrderId int64 `json:"order_id" form:"order_id"`
  966. }
  967. // 门诊费用明细信息上传
  968. 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) {
  969. // 生成签名
  970. nonce := GetRandomString(32)
  971. timestamp := time.Now().Unix()
  972. signature := setSignature(timestamp, nonce, secret_key)
  973. //tempTime := time.Unix(timestamp, 0)
  974. //timeFormat := tempTime.Format("20060102150405")
  975. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  976. //chrgBchno := rand.Intn(100000) + 10000
  977. var customs []*Custom
  978. inputMessage := make(map[string]interface{})
  979. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127"{
  980. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs,doctor)
  981. } else {
  982. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  983. }
  984. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  985. for _, item := range hisPrescription {
  986. role, _ := GetAdminUserInfoByID(item.UserOrgId, new_doctor_id)
  987. tm := time.Unix(item.PreTime, 0)
  988. if item.Type == 1 { //药品
  989. for _, subItem := range item.HisDoctorAdviceInfo {
  990. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 && subItem.BaseDrugLib.IsUser != 1 {
  991. //var randNum int
  992. //randNum = rand.Intn(10000) + 1000
  993. role, _ := GetAdminUserInfoByID(item.UserOrgId, new_doctor_id)
  994. cus := &Custom{
  995. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber),
  996. Cut: fmt.Sprintf("%.4f", subItem.PrescribingNumber),
  997. FeedetlSn: subItem.FeedetlSn,
  998. Price: fmt.Sprintf("%.4f", subItem.Price),
  999. MedListCodg: subItem.BaseDrugLib.MedicalInsuranceNumber,
  1000. HospApprFlag: subItem.HospApprFlag,
  1001. DoctorNumber: role.DoctorNumber,
  1002. DoctorName: role.UserName,
  1003. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  1004. }
  1005. customs = append(customs, cus)
  1006. }
  1007. }
  1008. }
  1009. if item.Type == 2 { //项目
  1010. for _, subItem := range item.HisPrescriptionProject {
  1011. //var randNum int
  1012. //randNum = rand.Intn(10000) + 1000
  1013. if subItem.Type == 2 {
  1014. if len(subItem.HisProject.MedicalCode) > 0 {
  1015. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1016. cus := &Custom{
  1017. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  1018. Cut: fmt.Sprintf("%.4f", cnt),
  1019. FeedetlSn: subItem.FeedetlSn,
  1020. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  1021. MedListCodg: subItem.HisProject.MedicalCode,
  1022. DoctorNumber: role.DoctorNumber,
  1023. DoctorName: role.UserName,
  1024. HospApprFlag: -1,
  1025. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  1026. }
  1027. customs = append(customs, cus)
  1028. }
  1029. } else if subItem.Type == 3 {
  1030. if len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  1031. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1032. cus := &Custom{
  1033. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  1034. Cut: fmt.Sprintf("%.4f", cnt),
  1035. FeedetlSn: subItem.FeedetlSn,
  1036. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  1037. MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
  1038. HospApprFlag: -1,
  1039. DoctorNumber: role.DoctorNumber,
  1040. DoctorName: role.UserName,
  1041. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  1042. }
  1043. customs = append(customs, cus)
  1044. }
  1045. }
  1046. }
  1047. }
  1048. for _, subItem := range item.HisAdditionalCharge {
  1049. if len(subItem.XtHisAddtionConfig.Code) > 0 {
  1050. cus := &Custom{
  1051. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*float64(subItem.Count)),
  1052. Cut: fmt.Sprintf("%.4f", float64(subItem.Count)),
  1053. FeedetlSn: subItem.FeedetlSn,
  1054. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  1055. MedListCodg: subItem.XtHisAddtionConfig.Code,
  1056. HospApprFlag: -1,
  1057. DoctorNumber: role.DoctorNumber,
  1058. DoctorName: role.UserName,
  1059. }
  1060. customs = append(customs, cus)
  1061. }
  1062. }
  1063. }
  1064. // 生成输入报文
  1065. input := make(map[string]interface{})
  1066. feedetail := make([]map[string]interface{}, 0)
  1067. inputMessage["infno"] = "2204" // 交易编码
  1068. //chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  1069. for _, item := range customs {
  1070. feedetailInfo := make(map[string]interface{})
  1071. feedetailInfo["feedetl_sn"] = item.FeedetlSn
  1072. feedetailInfo["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1073. feedetailInfo["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1074. feedetailInfo["chrg_bchno"] = chrg_bchno // 收费批次号
  1075. feedetailInfo["dise_codg"] = diag_code // 病种编码
  1076. feedetailInfo["rxno"] = "" // 处方号
  1077. feedetailInfo["rx_circ_flag"] = "0" // 外购处方标志
  1078. feedetailInfo["fee_ocur_time"] = item.FeeOcurTime // 费用发生时间
  1079. feedetailInfo["med_list_codg"] = item.MedListCodg // 医疗目录编码
  1080. feedetailInfo["medins_list_codg"] = item.MedListCodg // 医药机构目录编码
  1081. feedetailInfo["det_item_fee_sumamt"] = item.DetItemFeeSumamt // 明细项目费用总额
  1082. feedetailInfo["cnt"] = item.Cut // 数量
  1083. feedetailInfo["pric"] = item.Price // 单价
  1084. feedetailInfo["sin_dos_dscr"] = "1" // 单次剂量描述
  1085. feedetailInfo["used_frqu_dscr"] = "" // 使用频次描述
  1086. feedetailInfo["prd_days"] = "0" // 周期天数
  1087. feedetailInfo["medc_way_dscr"] = "" // 用药途径描述
  1088. feedetailInfo["bilg_dept_codg"] = dept_code // 开单科室编码
  1089. feedetailInfo["bilg_dept_name"] = dept // 开单科室名称
  1090. feedetailInfo["bilg_dr_codg"] = item.DoctorNumber // 开单医生编码
  1091. feedetailInfo["bilg_dr_name"] = item.DoctorName // 开单医师姓名
  1092. feedetailInfo["acord_dept_codg"] = "" // 受单科室编码
  1093. feedetailInfo["acord_dept_name"] = "" // 受单科室名称
  1094. feedetailInfo["orders_dr_code"] = item.DoctorNumber // 受单医生编码
  1095. feedetailInfo["orders_dr_name"] = item.DoctorName // 受单医生姓名
  1096. if balance_accounts_type == "8" {
  1097. feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
  1098. } else {
  1099. if item.HospApprFlag != -1 {
  1100. if item.HospApprFlag == 1 {
  1101. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  1102. } else if item.HospApprFlag == 2 {
  1103. feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
  1104. } else if item.HospApprFlag == 3 {
  1105. feedetailInfo["hosp_appr_flag"] = "0" // 医院审批标志
  1106. } else {
  1107. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  1108. }
  1109. } else {
  1110. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  1111. }
  1112. }
  1113. //feedetailInfo["tcmdrug_used_way"] = "" // 中药使用方式
  1114. feedetailInfo["etip_flag"] = "0" // 外检标志
  1115. feedetailInfo["etip_hosp_code"] = "" // 外检医院编码
  1116. feedetailInfo["dscg_tkdrug_flag"] = "" // 出院带药标志
  1117. feedetailInfo["matn_fee_flag"] = "" // 生育费用标志
  1118. feedetail = append(feedetail, feedetailInfo)
  1119. }
  1120. input["feedetail"] = feedetail
  1121. inputMessage["input"] = input //交易输入
  1122. var requestLog string
  1123. bytesData, err := json.Marshal(inputMessage)
  1124. fmt.Println("----------")
  1125. fmt.Println(string(bytesData))
  1126. fmt.Println("----------")
  1127. requestLog = string(bytesData)
  1128. if err != nil {
  1129. fmt.Println(err.Error())
  1130. return "", ""
  1131. }
  1132. reader := bytes.NewReader(bytesData)
  1133. gdyb_url := beego.AppConfig.String("gdyb_url")
  1134. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1135. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1136. var url string
  1137. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  1138. url = gdyb_url
  1139. } else {
  1140. url = gdyb_url + "2204"
  1141. }
  1142. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2204"
  1143. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2204"
  1144. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2204"
  1145. if insuplc_admdvs == "421300" {
  1146. var json2 string
  1147. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2204", string(bytesData), json2)
  1148. out, err := cmd.Output()
  1149. if err != nil {
  1150. fmt.Println("error:", err.Error())
  1151. }
  1152. fmt.Println(string(out))
  1153. return hex.EncodeToString(out), requestLog
  1154. } else {
  1155. request, err := http.NewRequest("POST", url, reader)
  1156. if err != nil {
  1157. fmt.Println(err.Error())
  1158. return "", ""
  1159. }
  1160. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1161. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1162. request.Header.Set("x-tif-signature", signature)
  1163. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1164. request.Header.Set("x-tif-nonce", nonce)
  1165. client := http.Client{}
  1166. resp, err := client.Do(request)
  1167. if err != nil {
  1168. fmt.Println(err.Error())
  1169. return "", ""
  1170. }
  1171. respBytes, err := ioutil.ReadAll(resp.Body)
  1172. if err != nil {
  1173. fmt.Println(err.Error())
  1174. return "", ""
  1175. }
  1176. return string(respBytes), requestLog
  1177. }
  1178. //var result RequestResult
  1179. //json.Unmarshal(respBytes, &result)
  1180. //return &result
  1181. }
  1182. 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) {
  1183. // 生成签名
  1184. nonce := GetRandomString(32)
  1185. timestamp := time.Now().Unix()
  1186. signature := setSignature(timestamp, nonce, secret_key)
  1187. //tempTime := time.Unix(timestamp, 0)
  1188. //timeFormat := tempTime.Format("20060102150405")
  1189. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  1190. //chrgBchno := rand.Intn(100000) + 10000
  1191. var customs []*Custom
  1192. for _, item := range hisPrescription {
  1193. tm := time.Unix(item.PreTime, 0)
  1194. if item.Type == 1 { //药品
  1195. for _, subItem := range item.HisDoctorAdviceInfo {
  1196. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 && subItem.BaseDrugLib.IsUser != 1 {
  1197. //var randNum int
  1198. //randNum = rand.Intn(10000) + 1000
  1199. cus := &Custom{
  1200. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber),
  1201. Cut: fmt.Sprintf("%.4f", subItem.PrescribingNumber),
  1202. FeedetlSn: subItem.FeedetlSn,
  1203. Price: fmt.Sprintf("%.4f", subItem.Price),
  1204. MedListCodg: subItem.BaseDrugLib.MedicalInsuranceNumber,
  1205. HospApprFlag: subItem.HospApprFlag,
  1206. DoctorNumber: new_doctor_id,
  1207. DoctorName: new_doctor_name,
  1208. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  1209. }
  1210. customs = append(customs, cus)
  1211. }
  1212. }
  1213. }
  1214. if item.Type == 2 { //项目
  1215. for _, subItem := range item.HisPrescriptionProject {
  1216. //var randNum int
  1217. //randNum = rand.Intn(10000) + 1000
  1218. if subItem.Type == 2 {
  1219. if len(subItem.HisProject.MedicalCode) > 0 {
  1220. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1221. cus := &Custom{
  1222. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  1223. Cut: fmt.Sprintf("%.4f", cnt),
  1224. FeedetlSn: subItem.FeedetlSn,
  1225. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  1226. MedListCodg: subItem.HisProject.MedicalCode,
  1227. DoctorNumber: new_doctor_id,
  1228. DoctorName: new_doctor_name,
  1229. HospApprFlag: -1,
  1230. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  1231. }
  1232. customs = append(customs, cus)
  1233. }
  1234. } else if subItem.Type == 3 {
  1235. if len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  1236. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1237. cus := &Custom{
  1238. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  1239. Cut: fmt.Sprintf("%.4f", cnt),
  1240. FeedetlSn: subItem.FeedetlSn,
  1241. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  1242. MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
  1243. HospApprFlag: -1,
  1244. DoctorNumber: new_doctor_id,
  1245. DoctorName: new_doctor_name,
  1246. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  1247. }
  1248. customs = append(customs, cus)
  1249. }
  1250. }
  1251. }
  1252. }
  1253. for _, subItem := range item.HisAdditionalCharge {
  1254. if len(subItem.XtHisAddtionConfig.Code) > 0 {
  1255. cus := &Custom{
  1256. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*float64(subItem.Count)),
  1257. Cut: fmt.Sprintf("%.4f", float64(subItem.Count)),
  1258. FeedetlSn: subItem.FeedetlSn,
  1259. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  1260. MedListCodg: subItem.XtHisAddtionConfig.Code,
  1261. HospApprFlag: -1,
  1262. DoctorNumber: new_doctor_id,
  1263. DoctorName: new_doctor_name,
  1264. }
  1265. customs = append(customs, cus)
  1266. }
  1267. }
  1268. }
  1269. // 生成输入报文
  1270. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1271. input := make(map[string]interface{})
  1272. feedetail := make([]map[string]interface{}, 0)
  1273. inputMessage["infno"] = "2204" // 交易编码
  1274. //chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  1275. for _, item := range customs {
  1276. feedetailInfo := make(map[string]interface{})
  1277. feedetailInfo["feedetl_sn"] = item.FeedetlSn
  1278. feedetailInfo["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1279. feedetailInfo["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1280. feedetailInfo["chrg_bchno"] = chrg_bchno // 收费批次号
  1281. feedetailInfo["dise_codg"] = diag_code // 病种编码
  1282. feedetailInfo["rxno"] = "" // 处方号
  1283. feedetailInfo["rx_circ_flag"] = "0" // 外购处方标志
  1284. feedetailInfo["fee_ocur_time"] = item.FeeOcurTime // 费用发生时间
  1285. feedetailInfo["med_list_codg"] = item.MedListCodg // 医疗目录编码
  1286. feedetailInfo["medins_list_codg"] = fixmedins_code // 医药机构目录编码
  1287. feedetailInfo["det_item_fee_sumamt"] = item.DetItemFeeSumamt // 明细项目费用总额
  1288. feedetailInfo["cnt"] = item.Cut // 数量
  1289. feedetailInfo["pric"] = item.Price // 单价
  1290. feedetailInfo["sin_dos_dscr"] = "" // 单次剂量描述
  1291. feedetailInfo["used_frqu_dscr"] = "" // 使用频次描述
  1292. feedetailInfo["prd_days"] = "0" // 周期天数
  1293. feedetailInfo["medc_way_dscr"] = "" // 用药途径描述
  1294. feedetailInfo["bilg_dept_codg"] = dept_code // 开单科室编码
  1295. feedetailInfo["bilg_dept_name"] = dept // 开单科室名称
  1296. feedetailInfo["bilg_dr_codg"] = item.DoctorNumber // 开单医生编码
  1297. feedetailInfo["bilg_dr_name"] = item.DoctorName // 开单医师姓名
  1298. feedetailInfo["acord_dept_codg"] = "" // 受单科室编码
  1299. feedetailInfo["acord_dept_name"] = "" // 受单科室名称
  1300. feedetailInfo["orders_dr_code"] = item.DoctorNumber // 受单医生编码
  1301. feedetailInfo["orders_dr_name"] = item.DoctorName // 受单医生姓名
  1302. if balance_accounts_type == "8" {
  1303. feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
  1304. } else {
  1305. if item.HospApprFlag != -1 {
  1306. if item.HospApprFlag == 1 {
  1307. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  1308. } else if item.HospApprFlag == 2 {
  1309. feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
  1310. } else if item.HospApprFlag == 3 {
  1311. feedetailInfo["hosp_appr_flag"] = "0" // 医院审批标志
  1312. } else {
  1313. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  1314. }
  1315. } else {
  1316. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  1317. }
  1318. }
  1319. //feedetailInfo["tcmdrug_used_way"] = "" // 中药使用方式
  1320. feedetailInfo["etip_flag"] = "" // 外检标志
  1321. feedetailInfo["etip_hosp_code"] = "" // 外检医院编码
  1322. feedetailInfo["dscg_tkdrug_flag"] = "" // 出院带药标志
  1323. feedetailInfo["matn_fee_flag"] = "" // 生育费用标志
  1324. feedetail = append(feedetail, feedetailInfo)
  1325. }
  1326. input["feedetail"] = feedetail
  1327. inputMessage["input"] = input //交易输入
  1328. var requestLog string
  1329. bytesData, err := json.Marshal(inputMessage)
  1330. fmt.Println("----------")
  1331. fmt.Println(string(bytesData))
  1332. fmt.Println("----------")
  1333. requestLog = string(bytesData)
  1334. if err != nil {
  1335. fmt.Println(err.Error())
  1336. return "", ""
  1337. }
  1338. reader := bytes.NewReader(bytesData)
  1339. gdyb_url := beego.AppConfig.String("gdyb_url")
  1340. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1341. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1342. var url string
  1343. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721"{
  1344. url = gdyb_url
  1345. } else {
  1346. url = gdyb_url + "2204"
  1347. }
  1348. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2204"
  1349. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2204"
  1350. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2204"
  1351. if insuplc_admdvs == "421300" {
  1352. var json2 string
  1353. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2204", string(bytesData), json2)
  1354. out, err := cmd.Output()
  1355. if err != nil {
  1356. fmt.Println("error:", err.Error())
  1357. }
  1358. fmt.Println(string(out))
  1359. return hex.EncodeToString(out), requestLog
  1360. } else {
  1361. request, err := http.NewRequest("POST", url, reader)
  1362. if err != nil {
  1363. fmt.Println(err.Error())
  1364. return "", ""
  1365. }
  1366. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1367. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1368. request.Header.Set("x-tif-signature", signature)
  1369. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1370. request.Header.Set("x-tif-nonce", nonce)
  1371. client := http.Client{}
  1372. resp, err := client.Do(request)
  1373. if err != nil {
  1374. fmt.Println(err.Error())
  1375. return "", ""
  1376. }
  1377. respBytes, err := ioutil.ReadAll(resp.Body)
  1378. if err != nil {
  1379. fmt.Println(err.Error())
  1380. return "", ""
  1381. }
  1382. return string(respBytes), requestLog
  1383. }
  1384. //var result RequestResult
  1385. //json.Unmarshal(respBytes, &result)
  1386. //return &result
  1387. }
  1388. // 门诊费用明细信息撤销
  1389. 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) {
  1390. // 生成签名
  1391. nonce := GetRandomString(32)
  1392. timestamp := time.Now().Unix()
  1393. signature := setSignature(timestamp, nonce, secret_key)
  1394. inputMessage := make(map[string]interface{})
  1395. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127"{
  1396. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs,doctor)
  1397. } else {
  1398. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1399. }
  1400. // 生成输入报文
  1401. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1402. input := make(map[string]interface{})
  1403. inputData := make(map[string]interface{})
  1404. inputMessage["infno"] = "2205" // 交易编码
  1405. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1406. inputData["chrg_bchno"] = "0000" // 收费批次号(来自2204生成的)
  1407. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1408. input["data"] = inputData
  1409. inputMessage["input"] = input //交易输入
  1410. bytesData, err := json.Marshal(inputMessage)
  1411. fmt.Println(string(bytesData))
  1412. var requestLog string
  1413. requestLog = string(bytesData)
  1414. if err != nil {
  1415. fmt.Println(err.Error())
  1416. return err.Error(), ""
  1417. }
  1418. reader := bytes.NewReader(bytesData)
  1419. gdyb_url := beego.AppConfig.String("gdyb_url")
  1420. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1421. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1422. //url := gdyb_url + "2205"
  1423. var url string
  1424. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721"{
  1425. url = gdyb_url
  1426. } else {
  1427. url = gdyb_url + "2205"
  1428. }
  1429. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2205"
  1430. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2205"
  1431. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2205"
  1432. if insuplc_admdvs == "421300" {
  1433. var json2 string
  1434. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2205", string(bytesData), json2)
  1435. out, err := cmd.Output()
  1436. if err != nil {
  1437. fmt.Println("error:", err.Error())
  1438. }
  1439. fmt.Println(string(out))
  1440. return hex.EncodeToString(out), requestLog
  1441. } else {
  1442. request, err := http.NewRequest("POST", url, reader)
  1443. fmt.Println(err)
  1444. fmt.Println(request)
  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. //
  1472. // func Gdyb2206(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string, total string, org_name string, doctor string, secret_key string) string {
  1473. 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) {
  1474. // 生成签名
  1475. nonce := GetRandomString(32)
  1476. timestamp := time.Now().Unix()
  1477. signature := setSignature(timestamp, nonce, secret_key)
  1478. inputMessage := make(map[string]interface{})
  1479. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127"{
  1480. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs,doctor)
  1481. } else {
  1482. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1483. }
  1484. // 生成输入报文
  1485. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1486. input := make(map[string]interface{})
  1487. inputData := make(map[string]interface{})
  1488. inputMessage["infno"] = "2206" // 交易编码
  1489. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1490. if certificates == 3 {
  1491. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  1492. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1493. } else {
  1494. if id_card_type == 1 {
  1495. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  1496. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1497. } else if id_card_type == 4 {
  1498. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  1499. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1500. } else {
  1501. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  1502. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1503. }
  1504. }
  1505. if insuplc_admdvs == "421300" {
  1506. if med_type == "11" || med_type == "1112" || med_type == "1111" {
  1507. inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
  1508. } else if med_type == "14" {
  1509. inputData["med_type"] = "140110" // 医疗类别 11 普通门诊 12 门诊挂号
  1510. }
  1511. } else {
  1512. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  1513. }
  1514. inputData["medfee_sumamt"] = total // 医疗费总额
  1515. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  1516. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1517. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  1518. inputData["acct_used_flag"] = "0" // 个人账户使用标志 0否 1是
  1519. inputData["insutype"] = insutype // 险种类型
  1520. inputData["invono"] = "" // 发票号
  1521. input["data"] = inputData
  1522. inputMessage["input"] = input //交易输入
  1523. var requestLog string
  1524. bytesData, err := json.Marshal(inputMessage)
  1525. requestLog = string(bytesData)
  1526. fmt.Println(string(bytesData))
  1527. if err != nil {
  1528. fmt.Println(err.Error())
  1529. return err.Error(), ""
  1530. }
  1531. reader := bytes.NewReader(bytesData)
  1532. gdyb_url := beego.AppConfig.String("gdyb_url")
  1533. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1534. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1535. //url := gdyb_url + "2206"
  1536. var url string
  1537. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  1538. url = gdyb_url
  1539. } else {
  1540. url = gdyb_url + "2206"
  1541. }
  1542. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2206"
  1543. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2206"
  1544. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2206"
  1545. if insuplc_admdvs == "421300" {
  1546. var json2 string
  1547. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2206", string(bytesData), json2)
  1548. out, err := cmd.Output()
  1549. if err != nil {
  1550. fmt.Println("error:", err.Error())
  1551. }
  1552. fmt.Println(string(out))
  1553. return hex.EncodeToString(out), requestLog
  1554. } else {
  1555. request, err := http.NewRequest("POST", url, reader)
  1556. if err != nil {
  1557. fmt.Println(err.Error())
  1558. return err.Error(), ""
  1559. }
  1560. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1561. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1562. request.Header.Set("x-tif-signature", signature)
  1563. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1564. request.Header.Set("x-tif-nonce", nonce)
  1565. client := http.Client{}
  1566. resp, err := client.Do(request)
  1567. if err != nil {
  1568. fmt.Println(err.Error())
  1569. return err.Error(), ""
  1570. }
  1571. respBytes, err := ioutil.ReadAll(resp.Body)
  1572. if err != nil {
  1573. fmt.Println(err.Error())
  1574. return err.Error(), ""
  1575. }
  1576. str := string(respBytes)
  1577. fmt.Println(str)
  1578. return str, requestLog
  1579. }
  1580. }
  1581. // 门诊结算
  1582. 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) {
  1583. // 生成签名
  1584. nonce := GetRandomString(32)
  1585. timestamp := time.Now().Unix()
  1586. signature := setSignature(timestamp, nonce, secret_key)
  1587. // 生成输入报文
  1588. inputMessage := make(map[string]interface{})
  1589. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127"{
  1590. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs,doctor)
  1591. } else {
  1592. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1593. }
  1594. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1595. input := make(map[string]interface{})
  1596. inputData := make(map[string]interface{})
  1597. inputMessage["infno"] = "2207" // 交易编码
  1598. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1599. if certificates == 3 {
  1600. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  1601. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1602. } else {
  1603. if id_card_type == 1 {
  1604. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  1605. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1606. } else if id_card_type == 4 {
  1607. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  1608. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  1609. } else {
  1610. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  1611. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1612. }
  1613. }
  1614. if med_type == "1111" || med_type == "1112" {
  1615. med_type = "11"
  1616. }
  1617. if insuplc_admdvs == "421300" {
  1618. if med_type == "11" {
  1619. inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
  1620. } else if med_type == "14" {
  1621. inputData["med_type"] = "140101" // 医疗类别 11 普通门诊 12 门诊挂号
  1622. }
  1623. } else {
  1624. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  1625. }
  1626. inputData["medfee_sumamt"] = total // 医疗费总额
  1627. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  1628. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1629. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  1630. inputData["acct_used_flag"] = acct_used_flag // 个人账户使用标志 0否 1是
  1631. inputData["insutype"] = insutype // 险种类型
  1632. inputData["invono"] = "" // 发票号
  1633. inputData["fulamt_ownpay_amt"] = fulamt_ownpay_amt //
  1634. inputData["overlmt_selfpay"] = overlmt_selfpay //
  1635. inputData["preselfpay_amt"] = preselfpay_amt //
  1636. inputData["inscp_scp_amt"] = inscp_scp_amt //
  1637. input["data"] = inputData
  1638. inputMessage["input"] = input //交易输入
  1639. bytesData, err := json.Marshal(inputMessage)
  1640. fmt.Println(string(bytesData))
  1641. if err != nil {
  1642. fmt.Println(err.Error())
  1643. return err.Error(), ""
  1644. }
  1645. reader := bytes.NewReader(bytesData)
  1646. gdyb_url := beego.AppConfig.String("gdyb_url")
  1647. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1648. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1649. //url := gdyb_url + "2207"
  1650. var url string
  1651. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  1652. url = gdyb_url
  1653. } else {
  1654. url = gdyb_url + "2207"
  1655. }
  1656. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2207"
  1657. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  1658. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  1659. if insuplc_admdvs == "421300" {
  1660. var json2 string
  1661. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2207", string(bytesData), json2)
  1662. out, err := cmd.Output()
  1663. if err != nil {
  1664. fmt.Println("error:", err.Error())
  1665. }
  1666. mjson, _ := json.Marshal(inputMessage)
  1667. str2 := string(mjson)
  1668. fmt.Println(string(out))
  1669. return hex.EncodeToString(out), str2
  1670. } else {
  1671. request, err := http.NewRequest("POST", url, reader)
  1672. if err != nil {
  1673. fmt.Println(err.Error())
  1674. return err.Error(), ""
  1675. }
  1676. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1677. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1678. request.Header.Set("x-tif-signature", signature)
  1679. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1680. request.Header.Set("x-tif-nonce", nonce)
  1681. client := http.Client{}
  1682. resp, err := client.Do(request)
  1683. if err != nil {
  1684. fmt.Println(err.Error())
  1685. return err.Error(), ""
  1686. }
  1687. respBytes, err := ioutil.ReadAll(resp.Body)
  1688. if err != nil {
  1689. fmt.Println(err.Error())
  1690. return err.Error(), ""
  1691. }
  1692. str := string(respBytes)
  1693. fmt.Println(str)
  1694. mjson, _ := json.Marshal(inputMessage)
  1695. str2 := string(mjson)
  1696. return str, str2
  1697. }
  1698. }
  1699. 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) {
  1700. // 生成签名
  1701. nonce := GetRandomString(32)
  1702. timestamp := time.Now().Unix()
  1703. signature := setSignature(timestamp, nonce, secret_key)
  1704. // 生成输入报文
  1705. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1706. input := make(map[string]interface{})
  1707. inputData := make(map[string]interface{})
  1708. inputMessage["infno"] = "2207A" // 交易编码
  1709. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1710. if certificates == 3 {
  1711. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  1712. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1713. } else {
  1714. if id_card_type == 1 {
  1715. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  1716. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1717. } else {
  1718. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  1719. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1720. }
  1721. }
  1722. if med_type == "1111" || med_type == "1112" {
  1723. med_type = "11"
  1724. }
  1725. if insuplc_admdvs == "421300" {
  1726. if med_type == "11" {
  1727. inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
  1728. } else if med_type == "14" {
  1729. inputData["med_type"] = "140101" // 医疗类别 11 普通门诊 12 门诊挂号
  1730. }
  1731. } else {
  1732. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  1733. }
  1734. inputData["medfee_sumamt"] = total // 医疗费总额
  1735. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  1736. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1737. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  1738. inputData["acct_used_flag"] = acct_used_flag // 个人账户使用标志 0否 1是
  1739. inputData["insutype"] = insutype // 险种类型
  1740. inputData["invono"] = "" // 发票号
  1741. inputData["fulamt_ownpay_amt"] = fulamt_ownpay_amt //
  1742. inputData["overlmt_selfpay"] = overlmt_selfpay //
  1743. inputData["preselfpay_amt"] = preselfpay_amt //
  1744. inputData["inscp_scp_amt"] = inscp_scp_amt //
  1745. input["data"] = inputData
  1746. inputMessage["input"] = input //交易输入
  1747. bytesData, err := json.Marshal(inputMessage)
  1748. fmt.Println(string(bytesData))
  1749. if err != nil {
  1750. fmt.Println(err.Error())
  1751. return err.Error(), ""
  1752. }
  1753. reader := bytes.NewReader(bytesData)
  1754. gdyb_url := beego.AppConfig.String("gdyb_url")
  1755. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1756. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1757. //url := gdyb_url + "2207"
  1758. var url string
  1759. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  1760. url = gdyb_url
  1761. } else {
  1762. url = gdyb_url + "2207"
  1763. }
  1764. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2207"
  1765. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  1766. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  1767. if insuplc_admdvs == "421300" {
  1768. var json2 string
  1769. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2207", string(bytesData), json2)
  1770. out, err := cmd.Output()
  1771. if err != nil {
  1772. fmt.Println("error:", err.Error())
  1773. }
  1774. mjson, _ := json.Marshal(inputMessage)
  1775. str2 := string(mjson)
  1776. fmt.Println(string(out))
  1777. return hex.EncodeToString(out), str2
  1778. } else {
  1779. request, err := http.NewRequest("POST", url, reader)
  1780. if err != nil {
  1781. fmt.Println(err.Error())
  1782. return err.Error(), ""
  1783. }
  1784. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1785. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1786. request.Header.Set("x-tif-signature", signature)
  1787. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1788. request.Header.Set("x-tif-nonce", nonce)
  1789. client := http.Client{}
  1790. resp, err := client.Do(request)
  1791. if err != nil {
  1792. fmt.Println(err.Error())
  1793. return err.Error(), ""
  1794. }
  1795. respBytes, err := ioutil.ReadAll(resp.Body)
  1796. if err != nil {
  1797. fmt.Println(err.Error())
  1798. return err.Error(), ""
  1799. }
  1800. str := string(respBytes)
  1801. fmt.Println(str)
  1802. mjson, _ := json.Marshal(inputMessage)
  1803. str2 := string(mjson)
  1804. return str, str2
  1805. }
  1806. }
  1807. // 门诊结算撤销
  1808. 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) {
  1809. // 生成签名
  1810. nonce := GetRandomString(32)
  1811. timestamp := time.Now().Unix()
  1812. signature := setSignature(timestamp, nonce, secret_key)
  1813. inputMessage := make(map[string]interface{})
  1814. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127"{
  1815. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs,doctor)
  1816. } else {
  1817. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1818. }
  1819. // 生成输入报文
  1820. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1821. input := make(map[string]interface{})
  1822. inputData := make(map[string]interface{})
  1823. inputMessage["infno"] = "2208" // 交易编码
  1824. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1825. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1826. inputData["setl_id"] = setlId // 结算 ID
  1827. input["data"] = inputData
  1828. inputMessage["input"] = input //交易输入
  1829. bytesData, err := json.Marshal(inputMessage)
  1830. fmt.Println(string(bytesData))
  1831. if err != nil {
  1832. fmt.Println(err.Error())
  1833. return err.Error(), ""
  1834. }
  1835. reader := bytes.NewReader(bytesData)
  1836. gdyb_url := beego.AppConfig.String("gdyb_url")
  1837. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1838. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1839. //url := gdyb_url + "2208"
  1840. var url string
  1841. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  1842. url = gdyb_url
  1843. } else {
  1844. url = gdyb_url + "2208"
  1845. }
  1846. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2208"
  1847. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2208"
  1848. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2208"
  1849. if insuplc_admdvs == "421300" {
  1850. var json2 string
  1851. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2208", string(bytesData), json2)
  1852. out, err := cmd.Output()
  1853. if err != nil {
  1854. fmt.Println("error:", err.Error())
  1855. }
  1856. mjson, _ := json.Marshal(inputMessage)
  1857. str2 := string(mjson)
  1858. fmt.Println(string(out))
  1859. return hex.EncodeToString(out), str2
  1860. } else {
  1861. request, err := http.NewRequest("POST", url, reader)
  1862. if err != nil {
  1863. fmt.Println(err.Error())
  1864. return err.Error(), ""
  1865. }
  1866. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1867. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1868. request.Header.Set("x-tif-signature", signature)
  1869. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1870. request.Header.Set("x-tif-nonce", nonce)
  1871. client := http.Client{}
  1872. resp, err := client.Do(request)
  1873. if err != nil {
  1874. fmt.Println(err.Error())
  1875. return err.Error(), ""
  1876. }
  1877. respBytes, err := ioutil.ReadAll(resp.Body)
  1878. if err != nil {
  1879. fmt.Println(err.Error())
  1880. return err.Error(), ""
  1881. }
  1882. str := string(respBytes)
  1883. fmt.Println(str)
  1884. mjson, _ := json.Marshal(inputMessage)
  1885. str2 := string(mjson)
  1886. return str, str2
  1887. }
  1888. }
  1889. // 确认订单
  1890. func Gdyb6201(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, order models.HisOrder) string {
  1891. // 生成签名
  1892. nonce := GetRandomString(32)
  1893. timestamp := time.Now().Unix()
  1894. signature := setSignature(timestamp, nonce, secret_key)
  1895. // 生成输入报文
  1896. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1897. input := make(map[string]interface{})
  1898. inputData := make(map[string]interface{})
  1899. inputMessage["infno"] = "6201" // 交易编码
  1900. inputData["mdtrt_id"] = order.MdtrtId
  1901. inputData["chrg_bchno"] = order.Number
  1902. inputData["psn_no"] = order.PsnNo
  1903. inputData["psn_name"] = order.PsnName
  1904. inputData["psn_cert_type"] = order.PsnCertType
  1905. inputData["certno"] = order.Certno
  1906. inputData["insutype"] = order.Insutype
  1907. inputData["med_type"] = order.MedType
  1908. inputData["medfee_sumamt"] = order.MedfeeSumamt
  1909. inputData["fulamt_ownpay_amt"] = order.FulamtOwnpayAmt
  1910. inputData["overlmt_selfpay"] = order.OverlmtSelfPay
  1911. inputData["preselfpay_amt"] = order.PreselfpayAmt
  1912. inputData["inscp_scp_amt"] = order.InscpScpAmt
  1913. inputData["act_pay_dedc"] = order.ActPayDedc
  1914. inputData["hifp_pay"] = order.HifpPay
  1915. inputData["pool_prop_selfpay"] = order.PoolPropSelfpay
  1916. inputData["cvlserv_pay"] = order.CvlservPay
  1917. inputData["hifes_pay"] = order.HifesPay
  1918. inputData["hifmi_pay"] = order.HifmiPay
  1919. inputData["hifob_pay"] = order.HifobPay
  1920. inputData["maf_pay"] = order.MafPay
  1921. inputData["oth_pay"] = order.OthPay
  1922. inputData["fund_pay_sumamt"] = order.FundPaySumamt
  1923. inputData["psn_part_amt"] = order.PsnPartAmt
  1924. inputData["acct_pay"] = order.AcctPay
  1925. inputData["psn_cash_pay"] = order.PsnCashPay
  1926. inputData["hosp_part_amt"] = order.HospPartAmt
  1927. inputData["acct_mulaid_pay"] = order.AcctMulaidPay
  1928. input["data"] = inputData
  1929. inputMessage["input"] = input //交易输入
  1930. bytesData, err := json.Marshal(inputMessage)
  1931. fmt.Println(string(bytesData))
  1932. if err != nil {
  1933. fmt.Println(err.Error())
  1934. return err.Error()
  1935. }
  1936. reader := bytes.NewReader(bytesData)
  1937. gdyb_url := beego.AppConfig.String("gdyb_url")
  1938. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1939. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1940. url := gdyb_url + "6201"
  1941. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/6201"
  1942. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/6201"
  1943. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  1944. request, err := http.NewRequest("POST", url, reader)
  1945. if err != nil {
  1946. fmt.Println(err.Error())
  1947. return err.Error()
  1948. }
  1949. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1950. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1951. request.Header.Set("x-tif-signature", signature)
  1952. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1953. request.Header.Set("x-tif-nonce", nonce)
  1954. client := http.Client{}
  1955. resp, err := client.Do(request)
  1956. if err != nil {
  1957. fmt.Println(err.Error())
  1958. return err.Error()
  1959. }
  1960. respBytes, err := ioutil.ReadAll(resp.Body)
  1961. if err != nil {
  1962. fmt.Println(err.Error())
  1963. return err.Error()
  1964. }
  1965. str := string(respBytes)
  1966. fmt.Println(str)
  1967. return str
  1968. }
  1969. // 医药机构费用结算对总账 func Gdyb3201( org_name string, doctor string, secret_key string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) string {
  1970. func Gdyb3201(baseParams models.BaseParams, businessParams models.BusinessParams, admin_user_id int64) string {
  1971. fmt.Println("11222333-----")
  1972. fmt.Println(baseParams)
  1973. fmt.Println(businessParams)
  1974. // 生成签名
  1975. nonce := GetRandomString(32)
  1976. timestamp := time.Now().Unix()
  1977. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1978. inputMessage := make(map[string]interface{})
  1979. if baseParams.MdtrtareaAdmvs == "450721" || baseParams.MdtrtareaAdmvs == "450127"{
  1980. inputMessage = SetInputMessage1111(nonce, timestamp, baseParams.OrgName, admin_user_id, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs,baseParams.Doctor)
  1981. } else {
  1982. inputMessage = SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1983. //inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1984. }
  1985. // 生成输入报文
  1986. input := make(map[string]interface{})
  1987. inputData := make(map[string]interface{})
  1988. inputMessage["infno"] = "3201" // 交易编码
  1989. inputData["insutype"] = businessParams.Insutype // 险种
  1990. if baseParams.MdtrtareaAdmvs == "450721"{
  1991. if businessParams.Insutype == "390"{
  1992. inputData["clr_type"] = "99971" // 就诊 ID(来自2201接口返回)
  1993. }else{
  1994. inputData["clr_type"] = "99970" // 就诊 ID(来自2201接口返回)
  1995. }
  1996. }else{
  1997. inputData["clr_type"] = businessParams.ClrType // 就诊 ID(来自2201接口返回)
  1998. }
  1999. inputData["setl_optins"] = businessParams.SetlOptins // 结算经办机构
  2000. inputData["stmt_begndate"] = businessParams.StmtBegndate // 对帐开始时间
  2001. inputData["stmt_enddate"] = businessParams.StmtEnddate //对帐结束时间
  2002. inputData["medfee_sumamt"] = businessParams.MedfeeSumamt //医疗费总额
  2003. inputData["fund_pay_sumamt"] = businessParams.FundPaySumamt //基金支付总额
  2004. inputData["acct_pay"] = businessParams.AcctPay //个人账户支付金额
  2005. inputData["fixmedins_setl_cnt"] = businessParams.FixmedinsSetlCnt //定点医药机构结算笔数
  2006. inputData["refd_setl_flag"] = 0 // 就诊 ID(来自2201接口返回)
  2007. input["data"] = inputData
  2008. inputMessage["input"] = input //交易输入
  2009. bytesData, err := json.Marshal(inputMessage)
  2010. fmt.Println(string(bytesData))
  2011. if err != nil {
  2012. fmt.Println(err.Error())
  2013. return err.Error()
  2014. }
  2015. reader := bytes.NewReader(bytesData)
  2016. gdyb_url := beego.AppConfig.String("gdyb_url")
  2017. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2018. var url string
  2019. if baseParams.MdtrtareaAdmvs == "150499" || baseParams.MdtrtareaAdmvs == "450721"{
  2020. url = gdyb_url
  2021. } else {
  2022. url = gdyb_url + "3201"
  2023. }
  2024. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2025. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3201"
  2026. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3201"
  2027. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3201"
  2028. request, err := http.NewRequest("POST", url, reader)
  2029. if err != nil {
  2030. fmt.Println(err.Error())
  2031. return err.Error()
  2032. }
  2033. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2034. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2035. request.Header.Set("x-tif-signature", signature)
  2036. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2037. request.Header.Set("x-tif-nonce", nonce)
  2038. client := http.Client{}
  2039. resp, err := client.Do(request)
  2040. if err != nil {
  2041. fmt.Println(err.Error())
  2042. return err.Error()
  2043. }
  2044. respBytes, err := ioutil.ReadAll(resp.Body)
  2045. if err != nil {
  2046. fmt.Println(err.Error())
  2047. return err.Error()
  2048. }
  2049. str := string(respBytes)
  2050. fmt.Println(str)
  2051. return str
  2052. }
  2053. type Params struct {
  2054. FileName string `json:"file_name"` //产品ID
  2055. In []byte `json:"in"` //
  2056. FixmedinsCode string `json:"fixmedins_code"` //调用环境生产为1 沙盒2
  2057. }
  2058. // 文件上传
  2059. func Gdyb9101(baseParams models.BaseParams, file_name string, file_byte []byte) string {
  2060. // 生成签名
  2061. nonce := GetRandomString(32)
  2062. timestamp := time.Now().Unix()
  2063. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  2064. //buf := new(bytes.Buffer)
  2065. //buf.ReadFrom(strings.NewReader(string(file_byte)))
  2066. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  2067. input := make(map[string]interface{})
  2068. inputData := make(map[string]interface{})
  2069. inputMessage["infno"] = "9101" // 交易编码
  2070. inputData["file_name"] = file_name //文件名
  2071. inputData["in"] = file_byte //文件数据
  2072. inputData["fixmedins_code"] = baseParams.FixmedinsCode //编码
  2073. input["fsUploadIn"] = inputData
  2074. inputMessage["input"] = input //交易输入
  2075. bytesData, err := json.Marshal(inputMessage)
  2076. fmt.Println(string(bytesData))
  2077. if err != nil {
  2078. fmt.Println(err.Error())
  2079. return err.Error()
  2080. }
  2081. reader := bytes.NewReader(bytesData)
  2082. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/9101"
  2083. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9101"
  2084. gdyb_url := beego.AppConfig.String("gdyb_url")
  2085. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2086. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2087. url := gdyb_url + "9101"
  2088. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9101"
  2089. request, err := http.NewRequest("POST", url, reader)
  2090. if err != nil {
  2091. fmt.Println(err.Error())
  2092. return err.Error()
  2093. }
  2094. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2095. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2096. request.Header.Set("x-tif-signature", signature)
  2097. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2098. request.Header.Set("x-tif-nonce", nonce)
  2099. client := http.Client{}
  2100. resp, err := client.Do(request)
  2101. if err != nil {
  2102. fmt.Println(err.Error())
  2103. return err.Error()
  2104. }
  2105. respBytes, err := ioutil.ReadAll(resp.Body)
  2106. if err != nil {
  2107. fmt.Println(err.Error())
  2108. return err.Error()
  2109. }
  2110. str := string(respBytes)
  2111. fmt.Println(str)
  2112. return str
  2113. }
  2114. func Gdyb9102(baseParams models.BaseParams, file_name string, file_qury_no string) string {
  2115. // 生成签名
  2116. nonce := GetRandomString(32)
  2117. timestamp := time.Now().Unix()
  2118. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  2119. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  2120. input := make(map[string]interface{})
  2121. inputData := make(map[string]interface{})
  2122. inputMessage["infno"] = "9102" // 交易编码
  2123. inputData["file_name"] = file_name //文件名
  2124. inputData["file_qury_no"] = file_qury_no //文件数据
  2125. inputData["fixmedins_code"] = baseParams.FixmedinsCode //编码
  2126. input["fsDownloadIn"] = inputData
  2127. inputMessage["input"] = input //交易输入
  2128. bytesData, err := json.Marshal(inputMessage)
  2129. fmt.Println(string(bytesData))
  2130. if err != nil {
  2131. fmt.Println(err.Error())
  2132. return err.Error()
  2133. }
  2134. reader := bytes.NewReader(bytesData)
  2135. gdyb_url := beego.AppConfig.String("gdyb_url")
  2136. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2137. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2138. url := gdyb_url + "9102"
  2139. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/9102"
  2140. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9102"
  2141. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9102"
  2142. request, err := http.NewRequest("POST", url, reader)
  2143. if err != nil {
  2144. fmt.Println(err.Error())
  2145. return err.Error()
  2146. }
  2147. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2148. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2149. request.Header.Set("x-tif-signature", signature)
  2150. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2151. request.Header.Set("x-tif-nonce", nonce)
  2152. client := http.Client{}
  2153. resp, err := client.Do(request)
  2154. if err != nil {
  2155. fmt.Println(err.Error())
  2156. return err.Error()
  2157. }
  2158. respBytes, err := ioutil.ReadAll(resp.Body)
  2159. if err != nil {
  2160. fmt.Println(err.Error())
  2161. return err.Error()
  2162. }
  2163. str := string(respBytes)
  2164. enc := mahonia.NewEncoder("gbk")
  2165. //output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  2166. fmt.Println(enc.ConvertString(str))
  2167. return str
  2168. }
  2169. func Gdyb3202(baseParams models.BaseParams, businessParams models.BusinessParams) string {
  2170. // 生成签名
  2171. nonce := GetRandomString(32)
  2172. timestamp := time.Now().Unix()
  2173. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  2174. // 生成输入报文
  2175. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  2176. input := make(map[string]interface{})
  2177. inputData := make(map[string]interface{})
  2178. inputMessage["infno"] = "3202" // 交易编码
  2179. inputData["file_qury_no"] = businessParams.FileQuryNo // 险种
  2180. inputData["setl_optins"] = baseParams.InsuplcAdmdvs // 结算经办机构
  2181. inputData["stmt_begndate"] = businessParams.StmtBegndate // 对帐开始时间
  2182. inputData["stmt_enddate"] = businessParams.StmtEnddate //对帐结束时间
  2183. inputData["medfee_sumamt"] = businessParams.MedfeeSumamt //医疗费总额
  2184. inputData["fund_pay_sumamt"] = businessParams.FundPaySumamt //基金支付总额
  2185. inputData["cash_payamt"] = businessParams.CashPayamt //现金支付金额
  2186. inputData["fixmedins_setl_cnt"] = businessParams.FixmedinsSetlCnt //定点医药机构结算笔数
  2187. inputData["clr_type"] = "11" // 就诊 ID(来自2201接口返回)
  2188. inputData["refd_setl_flag"] = 1 // 就诊 ID(来自2201接口返回)
  2189. input["data"] = inputData
  2190. inputMessage["input"] = input //交易输入
  2191. bytesData, err := json.Marshal(inputMessage)
  2192. fmt.Println(string(bytesData))
  2193. if err != nil {
  2194. fmt.Println(err.Error())
  2195. return err.Error()
  2196. }
  2197. reader := bytes.NewReader(bytesData)
  2198. gdyb_url := beego.AppConfig.String("gdyb_url")
  2199. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2200. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2201. url := gdyb_url + "3202"
  2202. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3202"
  2203. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3202"
  2204. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3202"
  2205. request, err := http.NewRequest("POST", url, reader)
  2206. if err != nil {
  2207. fmt.Println(err.Error())
  2208. return err.Error()
  2209. }
  2210. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2211. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2212. request.Header.Set("x-tif-signature", signature)
  2213. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2214. request.Header.Set("x-tif-nonce", nonce)
  2215. client := http.Client{}
  2216. resp, err := client.Do(request)
  2217. if err != nil {
  2218. fmt.Println(err.Error())
  2219. return err.Error()
  2220. }
  2221. respBytes, err := ioutil.ReadAll(resp.Body)
  2222. if err != nil {
  2223. fmt.Println(err.Error())
  2224. return err.Error()
  2225. }
  2226. str := string(respBytes)
  2227. fmt.Println(str)
  2228. return str
  2229. }
  2230. func Gdyb5203(baseParams models.BaseParams, businessParams models.BusinessParams) string {
  2231. fmt.Println("~~~~~~1")
  2232. fmt.Println(baseParams)
  2233. fmt.Println(businessParams)
  2234. // 生成签名
  2235. nonce := GetRandomString(32)
  2236. timestamp := time.Now().Unix()
  2237. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  2238. fmt.Println("~~~~~~2")
  2239. // 生成输入报文
  2240. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  2241. input := make(map[string]interface{})
  2242. inputData := make(map[string]interface{})
  2243. inputMessage["infno"] = "5203" // 交易编码
  2244. inputData["psn_no"] = businessParams.PsnNo
  2245. inputData["setl_id"] = businessParams.SetlId
  2246. inputData["mdtrt_id"] = businessParams.MdtrtId
  2247. input["data"] = inputData
  2248. inputMessage["input"] = input //交易输入
  2249. bytesData, err := json.Marshal(inputMessage)
  2250. fmt.Println(string(bytesData))
  2251. fmt.Println("~~~~~~")
  2252. fmt.Println("~~~~~~")
  2253. fmt.Println(string(bytesData))
  2254. if err != nil {
  2255. fmt.Println(err.Error())
  2256. return err.Error()
  2257. }
  2258. reader := bytes.NewReader(bytesData)
  2259. gdyb_url := beego.AppConfig.String("gdyb_url")
  2260. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2261. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2262. //url := gdyb_url + "5203"
  2263. var url string
  2264. if baseParams.FixmedinsCode == "H15049901371" || baseParams.MdtrtareaAdmvs == "450127" || baseParams.MdtrtareaAdmvs == "450721" {
  2265. url = gdyb_url
  2266. }else {
  2267. url = gdyb_url + "5203"
  2268. }
  2269. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5203"
  2270. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
  2271. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
  2272. request, err := http.NewRequest("POST", url, reader)
  2273. if err != nil {
  2274. fmt.Println(err.Error())
  2275. return err.Error()
  2276. }
  2277. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2278. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2279. request.Header.Set("x-tif-signature", signature)
  2280. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2281. request.Header.Set("x-tif-nonce", nonce)
  2282. client := http.Client{}
  2283. resp, err := client.Do(request)
  2284. if err != nil {
  2285. fmt.Println(err.Error())
  2286. return err.Error()
  2287. }
  2288. respBytes, err := ioutil.ReadAll(resp.Body)
  2289. if err != nil {
  2290. fmt.Println(err.Error())
  2291. return err.Error()
  2292. }
  2293. str := string(respBytes)
  2294. fmt.Println(str)
  2295. return str
  2296. }
  2297. func Gdyb5204(baseParams models.BaseParams, businessParams models.BusinessParams) string {
  2298. // 生成签名
  2299. nonce := GetRandomString(32)
  2300. timestamp := time.Now().Unix()
  2301. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  2302. // 生成输入报文
  2303. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  2304. input := make(map[string]interface{})
  2305. inputData := make(map[string]interface{})
  2306. inputMessage["infno"] = "5204" // 交易编码
  2307. inputData["psn_no"] = businessParams.PsnNo
  2308. inputData["setl_id"] = businessParams.SetlId
  2309. inputData["mdtrt_id"] = businessParams.MdtrtId
  2310. input["data"] = inputData
  2311. inputMessage["input"] = input //交易输入
  2312. bytesData, err := json.Marshal(inputMessage)
  2313. fmt.Println(string(bytesData))
  2314. if err != nil {
  2315. fmt.Println(err.Error())
  2316. return err.Error()
  2317. }
  2318. reader := bytes.NewReader(bytesData)
  2319. gdyb_url := beego.AppConfig.String("gdyb_url")
  2320. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2321. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2322. //url := gdyb_url + "5203"
  2323. var url string
  2324. if baseParams.FixmedinsCode == "H15049901371" || baseParams.MdtrtareaAdmvs == "450127" || baseParams.MdtrtareaAdmvs == "450721" {
  2325. url = gdyb_url
  2326. } else {
  2327. url = gdyb_url + "5204"
  2328. }
  2329. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5203"
  2330. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
  2331. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
  2332. request, err := http.NewRequest("POST", url, reader)
  2333. if err != nil {
  2334. fmt.Println(err.Error())
  2335. return err.Error()
  2336. }
  2337. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2338. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2339. request.Header.Set("x-tif-signature", signature)
  2340. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2341. request.Header.Set("x-tif-nonce", nonce)
  2342. client := http.Client{}
  2343. resp, err := client.Do(request)
  2344. if err != nil {
  2345. fmt.Println(err.Error())
  2346. return err.Error()
  2347. }
  2348. respBytes, err := ioutil.ReadAll(resp.Body)
  2349. if err != nil {
  2350. fmt.Println(err.Error())
  2351. return err.Error()
  2352. }
  2353. str := string(respBytes)
  2354. fmt.Println(str)
  2355. return str
  2356. }
  2357. func Gdyb2001(baseParams models.BaseParams, psn_no string, insutype string, med_type string) string {
  2358. if med_type == "1111" || med_type == "1112" {
  2359. med_type = "11"
  2360. }
  2361. // 生成签名
  2362. nonce := GetRandomString(32)
  2363. timestamp := time.Now().Unix()
  2364. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  2365. // 生成输入报文
  2366. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  2367. input := make(map[string]interface{})
  2368. inputData := make(map[string]interface{})
  2369. inputMessage["infno"] = "2001" // 交易编码
  2370. inputData["psn_no"] = psn_no
  2371. inputData["insutype"] = insutype
  2372. inputData["fixmedins_code"] = baseParams.FixmedinsCode
  2373. inputData["med_type"] = med_type
  2374. inputData["begntime"] = "2021-01-01 00:00:00"
  2375. input["data"] = inputData
  2376. inputMessage["input"] = input //交易输入
  2377. bytesData, err := json.Marshal(inputMessage)
  2378. fmt.Println(string(bytesData))
  2379. if err != nil {
  2380. fmt.Println(err.Error())
  2381. return err.Error()
  2382. }
  2383. reader := bytes.NewReader(bytesData)
  2384. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3301"
  2385. gdyb_url := beego.AppConfig.String("gdyb_url")
  2386. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2387. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2388. url := gdyb_url
  2389. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3301"
  2390. request, err := http.NewRequest("POST", url, reader)
  2391. if err != nil {
  2392. fmt.Println(err.Error())
  2393. return err.Error()
  2394. }
  2395. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2396. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2397. request.Header.Set("x-tif-signature", signature)
  2398. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2399. request.Header.Set("x-tif-nonce", nonce)
  2400. client := http.Client{}
  2401. resp, err := client.Do(request)
  2402. if err != nil {
  2403. fmt.Println(err.Error())
  2404. return err.Error()
  2405. }
  2406. respBytes, err := ioutil.ReadAll(resp.Body)
  2407. if err != nil {
  2408. fmt.Println(err.Error())
  2409. return err.Error()
  2410. }
  2411. str := string(respBytes)
  2412. fmt.Println(str)
  2413. return str
  2414. }
  2415. 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 {
  2416. // 生成签名
  2417. nonce := GetRandomString(32)
  2418. timestamp := time.Now().Unix()
  2419. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  2420. inputMessage := make(map[string]interface{})
  2421. if baseParams.MdtrtareaAdmvs == "450721" {
  2422. inputMessage = SetInputMessage1111(nonce, timestamp, baseParams.OrgName, admin_user_id, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs,baseParams.Doctor)
  2423. //inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs,doctor)
  2424. } else {
  2425. inputMessage = SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  2426. //inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2427. }
  2428. // 生成输入报文
  2429. input := make(map[string]interface{})
  2430. //input2 := make([]map[string]interface{})
  2431. feedetail := make([]map[string]interface{}, 0)
  2432. inputData := make(map[string]interface{})
  2433. inputMessage["infno"] = "3301A" // 交易编码
  2434. inputData["fixmedins_hilist_id"] = codg
  2435. inputData["fixmedins_hilist_name"] = name
  2436. inputData["list_type"] = list_type
  2437. inputData["med_list_codg"] = codg
  2438. inputData["begndate"] = start_time
  2439. inputData["enddate"] = ent_time
  2440. inputData["aprvno"] = ""
  2441. inputData["dosform"] = ""
  2442. inputData["exct_cont"] = ""
  2443. inputData["item_cont"] = ""
  2444. inputData["prcunt"] = ""
  2445. inputData["spec"] = ""
  2446. inputData["pacspec"] = ""
  2447. inputData["memo"] = ""
  2448. feedetail = append(feedetail,inputData)
  2449. input["data"] = feedetail
  2450. inputMessage["input"] = input //交易输入
  2451. bytesData, err := json.Marshal(inputMessage)
  2452. fmt.Println(string(bytesData))
  2453. if err != nil {
  2454. fmt.Println(err.Error())
  2455. return err.Error()
  2456. }
  2457. reader := bytes.NewReader(bytesData)
  2458. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3301"
  2459. //
  2460. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3301"
  2461. gdyb_url := beego.AppConfig.String("gdyb_url")
  2462. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2463. url := ""
  2464. if baseParams.MdtrtareaAdmvs == "450721" {
  2465. url = gdyb_url
  2466. }else{
  2467. url = gdyb_url + "3301"
  2468. }
  2469. request, err := http.NewRequest("POST", url, reader)
  2470. if err != nil {
  2471. fmt.Println(err.Error())
  2472. return err.Error()
  2473. }
  2474. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2475. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2476. request.Header.Set("x-tif-signature", signature)
  2477. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2478. request.Header.Set("x-tif-nonce", nonce)
  2479. client := http.Client{}
  2480. resp, err := client.Do(request)
  2481. if err != nil {
  2482. fmt.Println(err.Error())
  2483. return err.Error()
  2484. }
  2485. respBytes, err := ioutil.ReadAll(resp.Body)
  2486. if err != nil {
  2487. fmt.Println(err.Error())
  2488. return err.Error()
  2489. }
  2490. str := string(respBytes)
  2491. fmt.Println(str)
  2492. return str
  2493. }
  2494. func Gdyb3302(baseParams *models.BaseParams, name string, codg string, list_type_code string) string {
  2495. // 生成签名
  2496. nonce := GetRandomString(32)
  2497. timestamp := time.Now().Unix()
  2498. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  2499. // 生成输入报文
  2500. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  2501. input := make(map[string]interface{})
  2502. inputData := make(map[string]interface{})
  2503. inputMessage["infno"] = "3302" // 交易编码
  2504. inputData["fixmedins_code"] = baseParams.FixmedinsCode
  2505. inputData["fixmedins_hilist_id"] = codg
  2506. inputData["list_type"] = list_type_code
  2507. inputData["med_list_codg"] = codg
  2508. input["data"] = inputData
  2509. inputMessage["input"] = input //交易输入
  2510. bytesData, err := json.Marshal(inputMessage)
  2511. fmt.Println(string(bytesData))
  2512. if err != nil {
  2513. fmt.Println(err.Error())
  2514. return err.Error()
  2515. }
  2516. reader := bytes.NewReader(bytesData)
  2517. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3302"
  2518. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3302"
  2519. gdyb_url := beego.AppConfig.String("gdyb_url")
  2520. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2521. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2522. url := gdyb_url + "3302"
  2523. request, err := http.NewRequest("POST", url, reader)
  2524. if err != nil {
  2525. fmt.Println(err.Error())
  2526. return err.Error()
  2527. }
  2528. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2529. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2530. request.Header.Set("x-tif-signature", signature)
  2531. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2532. request.Header.Set("x-tif-nonce", nonce)
  2533. client := http.Client{}
  2534. resp, err := client.Do(request)
  2535. if err != nil {
  2536. fmt.Println(err.Error())
  2537. return err.Error()
  2538. }
  2539. respBytes, err := ioutil.ReadAll(resp.Body)
  2540. if err != nil {
  2541. fmt.Println(err.Error())
  2542. return err.Error()
  2543. }
  2544. str := string(respBytes)
  2545. fmt.Println(str)
  2546. return str
  2547. }
  2548. 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 {
  2549. // 生成签名
  2550. nonce := GetRandomString(32)
  2551. timestamp := time.Now().Unix()
  2552. signature := setSignature(timestamp, nonce, secret_key)
  2553. inputMessage := make(map[string]interface{})
  2554. //tempTime := time.Unix(timestamp, 0)
  2555. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2556. // 生成输入报文
  2557. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127"{
  2558. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs,doctor)
  2559. } else {
  2560. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2561. }
  2562. // 生成输入报文
  2563. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2564. input := make(map[string]interface{})
  2565. inputData := make(map[string]interface{})
  2566. inputMessage["infno"] = "2505"
  2567. inputData["psn_no"] = psnNo
  2568. inputData["biz_appy_type"] = "01"
  2569. inputData["begndate"] = start_time
  2570. inputData["enddate"] = end_time
  2571. inputData["fixmedins_code"] = fixmedins_code
  2572. inputData["fixmedins_name"] = org_name
  2573. inputData["tel"] = ""
  2574. inputData["addr"] = ""
  2575. inputData["agnter_name"] = ""
  2576. inputData["agnter_cert_type"] = ""
  2577. inputData["agnter_certno"] = ""
  2578. inputData["agnter_tel"] = ""
  2579. inputData["agnter_addr"] = ""
  2580. inputData["agnter_rlts"] = ""
  2581. inputData["fix_srt_no"] = "1"
  2582. inputData["memo"] = ""
  2583. input["data"] = inputData
  2584. inputMessage["input"] = input //交易输入
  2585. bytesData, err := json.Marshal(inputMessage)
  2586. if err != nil {
  2587. fmt.Println(err.Error())
  2588. return err.Error()
  2589. }
  2590. reader := bytes.NewReader(bytesData)
  2591. //fmt.Println(String(bytesData))
  2592. fmt.Println(string(bytesData))
  2593. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2505"
  2594. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2505"
  2595. gdyb_url := beego.AppConfig.String("gdyb_url")
  2596. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2597. url := ""
  2598. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127"{
  2599. url = gdyb_url
  2600. }else{
  2601. url = gdyb_url+ "2505"
  2602. }
  2603. request, err := http.NewRequest("POST", url, reader)
  2604. if err != nil {
  2605. fmt.Println(err.Error())
  2606. return err.Error()
  2607. }
  2608. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2609. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2610. request.Header.Set("x-tif-signature", signature)
  2611. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2612. request.Header.Set("x-tif-nonce", nonce)
  2613. client := http.Client{}
  2614. resp, err := client.Do(request)
  2615. if err != nil {
  2616. fmt.Println(err.Error())
  2617. return err.Error()
  2618. }
  2619. respBytes, err := ioutil.ReadAll(resp.Body)
  2620. if err != nil {
  2621. fmt.Println(err.Error())
  2622. return err.Error()
  2623. }
  2624. str := string(respBytes)
  2625. fmt.Println(str)
  2626. return str
  2627. }
  2628. 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 {
  2629. // 生成签名
  2630. nonce := GetRandomString(32)
  2631. timestamp := time.Now().Unix()
  2632. signature := setSignature(timestamp, nonce, secret_key)
  2633. // 生成输入报文
  2634. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2635. input := make(map[string]interface{})
  2636. inputData := make(map[string]interface{})
  2637. inputMessage["infno"] = "2506"
  2638. inputData["psn_no"] = psnNo
  2639. inputData["trt_dcla_detl_sn"] = trt_dcla_detl_sn
  2640. inputData["memo"] = ""
  2641. input["data"] = inputData
  2642. inputMessage["input"] = input //交易输入
  2643. bytesData, err := json.Marshal(inputMessage)
  2644. fmt.Println(string(bytesData))
  2645. if err != nil {
  2646. fmt.Println(err.Error())
  2647. return err.Error()
  2648. }
  2649. reader := bytes.NewReader(bytesData)
  2650. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2506"
  2651. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2506"
  2652. gdyb_url := beego.AppConfig.String("gdyb_url")
  2653. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2654. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2655. url := gdyb_url + "2506"
  2656. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  2657. request, err := http.NewRequest("POST", url, reader)
  2658. if err != nil {
  2659. fmt.Println(err.Error())
  2660. return err.Error()
  2661. }
  2662. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2663. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2664. request.Header.Set("x-tif-signature", signature)
  2665. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2666. request.Header.Set("x-tif-nonce", nonce)
  2667. client := http.Client{}
  2668. resp, err := client.Do(request)
  2669. if err != nil {
  2670. fmt.Println(err.Error())
  2671. return err.Error()
  2672. }
  2673. respBytes, err := ioutil.ReadAll(resp.Body)
  2674. if err != nil {
  2675. fmt.Println(err.Error())
  2676. return err.Error()
  2677. }
  2678. str := string(respBytes)
  2679. fmt.Println(str)
  2680. return str
  2681. }
  2682. 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 {
  2683. // 生成签名
  2684. nonce := GetRandomString(32)
  2685. timestamp := time.Now().Unix()
  2686. signature := setSignature(timestamp, nonce, secret_key)
  2687. //tempTime := time.Unix(timestamp, 0)
  2688. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2689. //timeFormatTwo := tempTime.Format("2006-01-02")
  2690. //t := time.Now()
  2691. //last := time.Date(t.Year(), time.December, 31, 0, 0, 0, 0, time.UTC)
  2692. //tm := time.Unix(last.Unix(), 0)
  2693. // 生成输入报文
  2694. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2695. input := make(map[string]interface{})
  2696. inputData := make(map[string]interface{})
  2697. inputMessage["infno"] = "2503" // 交易编码
  2698. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  2699. inputData["insutype"] = insutype // 险种类型(来自1101接口返回)
  2700. inputData["opsp_dise_code"] = sick_code // 险种类型(来自1101接口返回)
  2701. inputData["opsp_dise_name"] = sick_name // 险种类型(来自1101接口返回)
  2702. inputData["insu_optins"] = insuplc_admdvs // 险种类型(来自1101接口返回)
  2703. inputData["ide_fixmedins_no"] = hospital_code // 险种类型(来自1101接口返回)
  2704. inputData["ide_fixmedins_name"] = hospital_name // 险种类型(来自1101接口返回)
  2705. inputData["hosp_ide_date"] = check_time // 险种类型(来自1101接口返回)
  2706. inputData["diag_dr_codg"] = doctor_id // 开始时间
  2707. inputData["diag_dr_name"] = doctor // 开始时间
  2708. inputData["begndate"] = start_time // 医师编码
  2709. inputData["tel"] = "" // 医师编码
  2710. inputData["addr"] = "" // 医师编码
  2711. inputData["enddate"] = end_time // 医师编码
  2712. input["data"] = inputData
  2713. inputMessage["input"] = input //交易输入
  2714. bytesData, err := json.Marshal(inputMessage)
  2715. fmt.Println(string(bytesData))
  2716. if err != nil {
  2717. fmt.Println(err.Error())
  2718. return err.Error()
  2719. }
  2720. reader := bytes.NewReader(bytesData)
  2721. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2503"
  2722. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2503"
  2723. gdyb_url := beego.AppConfig.String("gdyb_url")
  2724. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2725. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2726. //url := gdyb_url + "2503"
  2727. var url string
  2728. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  2729. url = gdyb_url
  2730. } else {
  2731. url = gdyb_url + "2503"
  2732. }
  2733. request, err := http.NewRequest("POST", url, reader)
  2734. if err != nil {
  2735. fmt.Println(err.Error())
  2736. return err.Error()
  2737. }
  2738. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2739. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2740. request.Header.Set("x-tif-signature", signature)
  2741. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2742. request.Header.Set("x-tif-nonce", nonce)
  2743. client := http.Client{}
  2744. resp, err := client.Do(request)
  2745. if err != nil {
  2746. fmt.Println(err.Error())
  2747. return err.Error()
  2748. }
  2749. respBytes, err := ioutil.ReadAll(resp.Body)
  2750. if err != nil {
  2751. fmt.Println(err.Error())
  2752. return err.Error()
  2753. }
  2754. str := string(respBytes)
  2755. fmt.Println(str)
  2756. return str
  2757. }
  2758. 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 {
  2759. // 生成签名
  2760. nonce := GetRandomString(32)
  2761. timestamp := time.Now().Unix()
  2762. signature := setSignature(timestamp, nonce, secret_key)
  2763. // 生成输入报文
  2764. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2765. input := make(map[string]interface{})
  2766. inputData := make(map[string]interface{})
  2767. inputMessage["infno"] = "2504" // 交易编码
  2768. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  2769. inputData["trt_dcla_detl_sn"] = trt_dcla_detl_sn // 人员编号 (来自1101接口返回)
  2770. inputData["memo"] = "撤销备案" // 人员编号 (来自1101接口返回)
  2771. input["data"] = inputData
  2772. inputMessage["input"] = input //交易输入
  2773. bytesData, err := json.Marshal(inputMessage)
  2774. fmt.Println(string(bytesData))
  2775. if err != nil {
  2776. fmt.Println(err.Error())
  2777. return err.Error()
  2778. }
  2779. reader := bytes.NewReader(bytesData)
  2780. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2504"
  2781. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2504"
  2782. gdyb_url := beego.AppConfig.String("gdyb_url")
  2783. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2784. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2785. url := gdyb_url + "2504"
  2786. request, err := http.NewRequest("POST", url, reader)
  2787. if err != nil {
  2788. fmt.Println(err.Error())
  2789. return err.Error()
  2790. }
  2791. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2792. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2793. request.Header.Set("x-tif-signature", signature)
  2794. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2795. request.Header.Set("x-tif-nonce", nonce)
  2796. client := http.Client{}
  2797. resp, err := client.Do(request)
  2798. if err != nil {
  2799. fmt.Println(err.Error())
  2800. return err.Error()
  2801. }
  2802. respBytes, err := ioutil.ReadAll(resp.Body)
  2803. if err != nil {
  2804. fmt.Println(err.Error())
  2805. return err.Error()
  2806. }
  2807. str := string(respBytes)
  2808. fmt.Println(str)
  2809. return str
  2810. }
  2811. //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 {
  2812. // // 生成签名
  2813. // nonce := GetRandomString(32)
  2814. // timestamp := time.Now().Unix()
  2815. // signature := setSignature(timestamp, nonce, secret_key)
  2816. // tempTime := time.Unix(timestamp, 0)
  2817. // timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2818. //
  2819. // // 生成输入报文
  2820. // inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2821. // input := make(map[string]interface{})
  2822. // inputData := make(map[string]interface{})
  2823. // diseinfo := make([]map[string]interface{}, 0)
  2824. //
  2825. // inputMessage["infno"] = "2203" // 交易编码
  2826. // inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  2827. // inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  2828. // inputData["med_type"] = med_type // 医疗类别 16门诊特殊病
  2829. // inputData["begntime"] = timeFormatOne // 开始时间
  2830. // inputData["main_cond_dscr"] = "" // 主要病情描述
  2831. // inputData["dise_codg"] = sick_code // 病种编码
  2832. // inputData["dise_name"] = sick_name // 病种名称
  2833. // inputData["birctrl_type"] = "" // 计划生育手术类别
  2834. // inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
  2835. //
  2836. // diseinfo_sun := make(map[string]interface{})
  2837. // diseinfo_sun["diag_type"] = "1" // 诊断类别
  2838. // diseinfo_sun["diag_srt_no"] = "1" // 诊断排序号
  2839. // diseinfo_sun["diag_code"] = diag_code // 诊断代码
  2840. // diseinfo_sun["diag_name"] = diag // 诊断名称
  2841. // diseinfo_sun["diag_dept"] = department // 诊断科室
  2842. // diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
  2843. // diseinfo_sun["dise_dor_name"] = doctor // 诊断医生姓名
  2844. // diseinfo_sun["diag_time"] = timeFormatOne // 诊断时间
  2845. // diseinfo_sun["vali_flag"] = "1" // 有效标志
  2846. //
  2847. // diseinfo = append(diseinfo, diseinfo_sun)
  2848. // input["diseinfo"] = diseinfo
  2849. // input["mdtrtinfo"] = inputData
  2850. // inputMessage["input"] = input //交易输入
  2851. //
  2852. // bytesData, err := json.Marshal(inputMessage)
  2853. // fmt.Println(string(bytesData))
  2854. // if err != nil {
  2855. // fmt.Println(err.Error())
  2856. // return err.Error()
  2857. // }
  2858. // reader := bytes.NewReader(bytesData)
  2859. //
  2860. // url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2203"
  2861. //
  2862. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  2863. // request, err := http.NewRequest("POST", url, reader)
  2864. // if err != nil {
  2865. // fmt.Println(err.Error())
  2866. // return err.Error()
  2867. // }
  2868. //
  2869. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2870. // request.Header.Set("x-tif-paasid", "sg03_prd")
  2871. // request.Header.Set("x-tif-signature", signature)
  2872. // request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2873. // request.Header.Set("x-tif-nonce", nonce)
  2874. //
  2875. // client := http.Client{}
  2876. // resp, err := client.Do(request)
  2877. // if err != nil {
  2878. // fmt.Println(err.Error())
  2879. // return err.Error()
  2880. // }
  2881. // respBytes, err := ioutil.ReadAll(resp.Body)
  2882. // if err != nil {
  2883. // fmt.Println(err.Error())
  2884. // return err.Error()
  2885. // }
  2886. // str := string(respBytes)
  2887. // fmt.Println(str)
  2888. // return str
  2889. //}
  2890. 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 {
  2891. // 生成签名
  2892. nonce := GetRandomString(32)
  2893. timestamp := time.Now().Unix()
  2894. //timestamp := time.Now().UnixNano() / 1e6
  2895. signature := setSignature(timestamp, nonce, secret_key)
  2896. //tempTime := time.Unix(timestamp, 0)
  2897. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2898. //timeFormatTwo := tempTime.Format("2006-01-02")
  2899. inputMessage := make(map[string]interface{})
  2900. //tempTime := time.Unix(timestamp, 0)
  2901. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2902. // 生成输入报文
  2903. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127"{
  2904. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs,doctor)
  2905. } else {
  2906. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2907. }
  2908. // 生成输入报文
  2909. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2910. input := make(map[string]interface{})
  2911. inputData := make(map[string]interface{})
  2912. inputMessage["infno"] = "5301" // 交易编码
  2913. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  2914. input["data"] = inputData
  2915. inputMessage["input"] = input //交易输入
  2916. bytesData, err := json.Marshal(inputMessage)
  2917. fmt.Println(string(bytesData))
  2918. if err != nil {
  2919. fmt.Println(err.Error())
  2920. return err.Error()
  2921. }
  2922. reader := bytes.NewReader(bytesData)
  2923. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  2924. gdyb_url := beego.AppConfig.String("gdyb_url")
  2925. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2926. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2927. var url string
  2928. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127"{
  2929. url = gdyb_url
  2930. }else{
  2931. url = gdyb_url + "5301"
  2932. }
  2933. request, err := http.NewRequest("POST", url, reader)
  2934. if err != nil {
  2935. fmt.Println(err.Error())
  2936. return err.Error()
  2937. }
  2938. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2939. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2940. request.Header.Set("x-tif-signature", signature)
  2941. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2942. request.Header.Set("x-tif-nonce", nonce)
  2943. client := http.Client{}
  2944. resp, err := client.Do(request)
  2945. if err != nil {
  2946. fmt.Println(err.Error())
  2947. return err.Error()
  2948. }
  2949. respBytes, err := ioutil.ReadAll(resp.Body)
  2950. if err != nil {
  2951. fmt.Println(err.Error())
  2952. return err.Error()
  2953. }
  2954. str := string(respBytes)
  2955. fmt.Println(str)
  2956. return str
  2957. }
  2958. func Gdyb5301Two(psnNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  2959. // 生成签名
  2960. nonce := GetRandomString(32)
  2961. timestamp := time.Now().Unix()
  2962. signature := setSignature(timestamp, nonce, secret_key)
  2963. //tempTime := time.Unix(timestamp, 0)
  2964. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2965. //timeFormatTwo := tempTime.Format("2006-01-02")
  2966. // 生成输入报文
  2967. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2968. input := make(map[string]interface{})
  2969. inputData := make(map[string]interface{})
  2970. inputMessage["infno"] = "5301" // 交易编码
  2971. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  2972. input["data"] = inputData
  2973. inputMessage["input"] = input //交易输入
  2974. bytesData, err := json.Marshal(inputMessage)
  2975. fmt.Println(string(bytesData))
  2976. if err != nil {
  2977. fmt.Println(err.Error())
  2978. return err.Error()
  2979. }
  2980. reader := bytes.NewReader(bytesData)
  2981. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  2982. gdyb_url := beego.AppConfig.String("gdyb_url")
  2983. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2984. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2985. url := gdyb_url
  2986. request, err := http.NewRequest("POST", url, reader)
  2987. if err != nil {
  2988. fmt.Println(err.Error())
  2989. return err.Error()
  2990. }
  2991. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2992. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2993. request.Header.Set("x-tif-signature", signature)
  2994. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2995. request.Header.Set("x-tif-nonce", nonce)
  2996. client := http.Client{}
  2997. resp, err := client.Do(request)
  2998. if err != nil {
  2999. fmt.Println(err.Error())
  3000. return err.Error()
  3001. }
  3002. respBytes, err := ioutil.ReadAll(resp.Body)
  3003. if err != nil {
  3004. fmt.Println(err.Error())
  3005. return err.Error()
  3006. }
  3007. str := string(respBytes)
  3008. fmt.Println(str)
  3009. return str
  3010. }
  3011. type CustomStruct struct {
  3012. FundPayType string
  3013. FundPayamt float64
  3014. }
  3015. type OpspdiseinfoStruct struct {
  3016. DiagName string
  3017. DiagCode string
  3018. OprnOprtName string
  3019. OprnOprtCode string
  3020. }
  3021. type DiaginfoStructTwo struct {
  3022. DiagType string
  3023. DiagCode string
  3024. DiagName string
  3025. MaindiagFlag string
  3026. }
  3027. type IteminfoStruct struct {
  3028. MedChrgitm string
  3029. Amt float64
  3030. ClaaSumfee float64
  3031. ClabAmt float64
  3032. FulamtOwnpayAmt float64
  3033. OthAmt float64
  3034. }
  3035. type Struct4101 struct {
  3036. PsnNo string
  3037. MdtrtId string
  3038. SetlId string
  3039. HiSetlLv string
  3040. PsnName string
  3041. Gend string
  3042. Brdy string
  3043. Ntly string
  3044. Naty string
  3045. PatnCertType string
  3046. Certno string
  3047. Prfs string
  3048. ConerName string
  3049. PatnRlts string
  3050. ConerAddr string
  3051. ConerTel string
  3052. HiType string
  3053. Insuplc string
  3054. AdmCaty string
  3055. DscgCaty string
  3056. MaindiagFlag string
  3057. BillCode string
  3058. BillNo string
  3059. BizSn string
  3060. SetlBegnDate string
  3061. SetlEndDate string
  3062. PsnSelfPay float64
  3063. PsnOwnPay float64
  3064. AcctPay float64
  3065. PsnCashpay float64
  3066. HiPaymtd string
  3067. Hsorg string
  3068. HsorgOpter string
  3069. MedinsFillDept string
  3070. MedinsFillPsn string
  3071. IptMedType string
  3072. Age int64
  3073. CustomStruct []CustomStruct
  3074. OpspdiseinfoStruct []OpspdiseinfoStruct
  3075. Diseinfo []DiaginfoStructTwo
  3076. IteminfoStruct []IteminfoStruct
  3077. AdmTime string
  3078. AdmEndTime string
  3079. HisNo string
  3080. DoctorName string
  3081. DoctorCode string
  3082. CurAddr string
  3083. }
  3084. 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) {
  3085. // 生成签名
  3086. nonce := GetRandomString(32)
  3087. timestamp := time.Now().Unix()
  3088. signature := setSignature(timestamp, nonce, secret_key)
  3089. inputMessage := make(map[string]interface{})
  3090. //tempTime := time.Unix(timestamp, 0)
  3091. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  3092. // 生成输入报文
  3093. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127"{
  3094. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs,doctor)
  3095. } else {
  3096. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3097. }
  3098. // 生成输入报文
  3099. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3100. input := make(map[string]interface{})
  3101. inputData := make(map[string]interface{})
  3102. if org_id == 10106 || org_id == 10215 || org_id == 10138 || org_id == 9504 {
  3103. inputMessage["infno"] = "4101A" // 交易编码
  3104. } else {
  3105. inputMessage["infno"] = "4101A" // 交易编码
  3106. }
  3107. year := time.Now().Format("2006")
  3108. month := time.Now().Format("01")
  3109. day := time.Now().Format("02")
  3110. inputData["mdtrt_id"] = struct4101.MdtrtId // 就诊 ID 必填(来自2201接口返回)
  3111. inputData["setl_id"] = struct4101.SetlId // 结算 ID 必填
  3112. inputData["psn_no"] = struct4101.PsnNo // 结算 ID 必填
  3113. inputData["fixmedins_name"] = org_name // 定点医药机构名称 必填
  3114. inputData["fixmedins_code"] = fixmedins_code // 定点医药机构编码 必填
  3115. inputData["hi_setl_lv"] = "" // 医保结算等级
  3116. inputData["hi_no"] = struct4101.PsnNo // 医保编号
  3117. inputData["medcasno"] = struct4101.PsnNo // 病案号 必填
  3118. inputData["dcla_time"] = year + "-" + month + "-" + day // 申报时间 必填
  3119. inputData["psn_name"] = struct4101.PsnName // 人员姓名 必填
  3120. inputData["gend"] = struct4101.Gend // 性别 必填
  3121. inputData["brdy"] = struct4101.Brdy // 出生日期 必填
  3122. inputData["age"] = struct4101.Age // 年龄 必填
  3123. inputData["ntly"] = struct4101.Ntly // 国籍 必填
  3124. inputData["nwb_age"] = "" // 年龄 必填
  3125. inputData["naty"] = struct4101.Naty // 民族 必填
  3126. inputData["dscg_way"] = "9" // 民族 必填
  3127. //inputData["resp_nurs_code"] = "N441623001432" // 民族 必填
  3128. inputData["patn_cert_type"] = struct4101.PatnCertType // 患者证件类别 必填
  3129. inputData["certno"] = struct4101.Certno // 证件号码 必填
  3130. inputData["prfs"] = struct4101.Prfs // 职业 必填
  3131. inputData["curr_addr"] = "" // 现住址 必填
  3132. inputData["emp_name"] = "" // 单位名称 必填
  3133. inputData["emp_addr"] = "" // 单位地址 必填
  3134. inputData["emp_tel"] = "" // 单位电话 必填
  3135. inputData["poscode"] = "" // 邮编 必填
  3136. inputData["coner_name"] = struct4101.ConerName // 联系人姓名 必填
  3137. inputData["patn_rlts"] = struct4101.PatnRlts // 与患者关系 必填
  3138. inputData["coner_addr"] = struct4101.ConerAddr // 联系人地址 必填
  3139. inputData["coner_tel"] = struct4101.ConerTel // 联系人电话 必填
  3140. inputData["hi_type"] = struct4101.HiType // 医保类型 必填
  3141. inputData["insuplc"] = struct4101.Insuplc // 参保地 必填
  3142. inputData["sp_psn_type"] = "" // 特殊人员类型 必填
  3143. inputData["nwb_adm_type"] = "" // 新生儿入院类型 必填
  3144. inputData["nwb_bir_wt"] = "" // 新生儿出生体重 必填
  3145. inputData["nwb_adm_wt"] = "" // 新生儿入院体重 必填
  3146. inputData["opsp_diag_caty"] = "" // 门诊慢特病诊断 必填
  3147. inputData["opsp_mdtrt_date"] = "" // 门诊慢特病就诊日期 必填
  3148. inputData["ipt_med_type"] = "" // 住院医疗类型 必填
  3149. inputData["adm_way"] = "" // 入院途径 必填
  3150. inputData["trt_type"] = "10" // 治疗类别 必填
  3151. inputData["adm_time"] = "" // 入院时间 必填
  3152. inputData["adm_caty"] = "A03.06" // 入院科别 必填
  3153. inputData["refldept_dept"] = "" // 转科科别 必填
  3154. inputData["dscg_time"] = "" // 出院时间 必填
  3155. inputData["dscg_caty"] = "A03.06" // 出院科别 必填
  3156. inputData["caty"] = "A03.06" // 出院科别 必填
  3157. inputData["act_ipt_days"] = "" // 实际住院天数 必填
  3158. inputData["otp_wm_dise"] = "" // 门(急) 诊西医诊断 必填
  3159. inputData["wm_dise_code"] = "" // 门(急) 诊中医诊断 必填
  3160. inputData["otp_tcm_dise"] = "" // 西医诊断疾病代码 必填
  3161. inputData["tcm_dise_code"] = "" // 中医诊断代码 必填
  3162. inputData["oprn_oprt_code_cnt"] = "" // 手术操作代码计数 必填
  3163. inputData["vent_used_dura"] = "" // 呼吸机使用时长 必填
  3164. inputData["pwcry_bfadm_coma_dura"] = "" // 颅脑损伤患者入院前昏迷时长 必填
  3165. inputData["pwcry_afadm_coma_dura"] = "" // 颅脑损伤患者入院后昏迷时长 必填
  3166. inputData["bld_cat"] = "" // 输血品种 必填
  3167. inputData["bld_amt"] = "" // 输血量 必填
  3168. inputData["bld_unt"] = "" // 输血计量单位 必填
  3169. inputData["spga_nurscare_days"] = "" // 特级护理天数 必填
  3170. inputData["lv1_nurscare_days"] = "" // 一级护理天数 必填
  3171. inputData["scd_nurscare_days"] = "" // 二级护理天数 必填
  3172. inputData["lv3_nurscare_days"] = "" // 三级护理天数 必填
  3173. inputData["acp_medins_name"] = "" // 拟接收机构名称 必填
  3174. inputData["acp_optins_code"] = "" // 拟接收机构代码 必填
  3175. inputData["bill_code"] = struct4101.BillCode // 票据代码 必填
  3176. inputData["bill_no"] = struct4101.BillNo // 票据号码 必填
  3177. inputData["biz_sn"] = struct4101.BizSn // 业务流水号 必填
  3178. inputData["days_rinp_flag_31"] = "" // 出院 31 天内再住院计划标志 必填
  3179. inputData["days_rinp_pup_31"] = "" // 出院 31 天内再住院目的 必填
  3180. inputData["chfpdr_name"] = struct4101.DoctorName // 主诊医师姓名 必填
  3181. inputData["chfpdr_code"] = struct4101.DoctorCode // 主诊医师代码 必填
  3182. inputData["setl_begn_date"] = struct4101.SetlBegnDate // 结算开始日期 必填
  3183. inputData["setl_end_date"] = struct4101.SetlEndDate // 结算结束日期 必填
  3184. inputData["psn_selfpay"] = struct4101.PsnSelfPay // 个人自付 必填
  3185. inputData["psn_ownpay"] = struct4101.PsnOwnPay // 个人自费 必填
  3186. inputData["acct_pay"] = struct4101.AcctPay // 个人账户支出 必填
  3187. inputData["hi_paymtd"] = struct4101.HiPaymtd // 医保支付方式 必填
  3188. inputData["hsorg"] = struct4101.Hsorg // 医保机构 必填
  3189. inputData["hsorg_opter"] = struct4101.HsorgOpter // 医保机构经办人 必填
  3190. inputData["medins_fill_dept"] = struct4101.MedinsFillDept // 医疗机构填报部门 必填
  3191. inputData["medins_fill_psn"] = struct4101.MedinsFillPsn // 医疗机构填报人 必填
  3192. inputData["psn_cashpay"] = struct4101.PsnCashpay // 医疗机构填报人 必填
  3193. payinfo := make([]map[string]interface{}, 0) // 基金支付信息
  3194. for _, item := range struct4101.CustomStruct {
  3195. payinfotemp := make(map[string]interface{})
  3196. 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" {
  3197. payinfotemp["fund_pay_type"] = item.FundPayType // 基金支付类型 必填
  3198. payinfotemp["fund_payamt"] = item.FundPayamt // 基金支付金额
  3199. payinfo = append(payinfo, payinfotemp)
  3200. }
  3201. }
  3202. opspdiseinfo := make([]map[string]interface{}, 0) // 门诊慢特病诊断信息
  3203. opspdiseinfotemp := make(map[string]interface{})
  3204. opspdiseinfotemp["diag_name"] = "慢性肾功能不全(血透治疗)" // 诊断名称 必填
  3205. opspdiseinfotemp["diag_code"] = "N18.904" // 诊断代码 必填
  3206. opspdiseinfotemp["oprn_oprt_name"] = "血液透析" // 手术操作名称 必填
  3207. opspdiseinfotemp["oprn_oprt_code"] = "39.9500" // 手术操作代码 必填
  3208. opspdiseinfo = append(opspdiseinfo, opspdiseinfotemp)
  3209. diseinfo := make([]map[string]interface{}, 0) // 住院诊断信息
  3210. for _, item := range struct4101.Diseinfo {
  3211. diseinfotemp := make(map[string]interface{})
  3212. diseinfotemp["maindiag_flag"] = item.MaindiagFlag // 手术操作代码 必填
  3213. diseinfotemp["diag_type"] = item.DiagType // 诊断类别 必填
  3214. diseinfotemp["diag_code"] = item.DiagCode // 诊断代码 必填
  3215. diseinfotemp["diag_name"] = item.DiagName // 诊断名称 必填
  3216. diseinfotemp["adm_cond_type"] = "3" // 入院病情类型 必填
  3217. diseinfo = append(diseinfo, diseinfotemp)
  3218. }
  3219. oprninfo := make([]map[string]interface{}, 0) // 手术操作信息
  3220. oprninfotemp := make(map[string]interface{})
  3221. oprninfotemp["oprn_oprt_type"] = "" // 手术操作类别 必填
  3222. oprninfotemp["oprn_oprt_name"] = "" // 手术操作名称 必填
  3223. oprninfotemp["oprn_oprt_code"] = "" // 手术操作代码 必填
  3224. oprninfotemp["oprn_oprt_date"] = "" // 手术操作日期 必填
  3225. oprninfotemp["anst_way"] = "" // 麻醉方式 必填
  3226. oprninfotemp["oper_dr_name"] = "" // 术者医师姓名 必填
  3227. oprninfotemp["oper_dr_code"] = "" // 术者医师代码 必填
  3228. oprninfotemp["anst_dr_name"] = "" // 麻醉医师姓名 必填
  3229. oprninfotemp["anst_dr_code"] = "" // 麻醉医师代码 必填
  3230. oprninfo = append(oprninfo, oprninfotemp)
  3231. icuinfo := make([]map[string]interface{}, 0) // 重症监护信息
  3232. icuinfotemp := make(map[string]interface{})
  3233. icuinfotemp["scs_cutd_ward_type"] = "" // 重症监护病房类型 必填
  3234. icuinfotemp["scs_cutd_inpool_time"] = "" // 重症监护进入时间 必填
  3235. icuinfotemp["scs_cutd_exit_time"] = "" // 重症监护退出时间 必填
  3236. icuinfotemp["scs_cutd_sum_dura"] = "" // 重症监护合计时长 必填
  3237. icuinfo = append(icuinfo, icuinfotemp)
  3238. input["setlinfo"] = inputData
  3239. input["payinfo"] = payinfo
  3240. input["opspdiseinfo"] = opspdiseinfo
  3241. input["diseinfo"] = diseinfo
  3242. inputMessage["input"] = input //交易输入
  3243. bytesData, err := json.Marshal(inputMessage)
  3244. fmt.Println(string(bytesData))
  3245. if err != nil {
  3246. fmt.Println(err.Error())
  3247. return err.Error(), ""
  3248. }
  3249. reader := bytes.NewReader(bytesData)
  3250. gdyb_url := beego.AppConfig.String("gdyb_url")
  3251. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3252. //url := gdyb_url + "4101"
  3253. var url string
  3254. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127"{
  3255. url = gdyb_url
  3256. //inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs,doctor)
  3257. } else {
  3258. //inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3259. url = gdyb_url + "4101A"
  3260. }
  3261. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/4101"
  3262. request, err := http.NewRequest("POST", url, reader)
  3263. if err != nil {
  3264. fmt.Println(err.Error())
  3265. return err.Error(), ""
  3266. }
  3267. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3268. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3269. request.Header.Set("x-tif-signature", signature)
  3270. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3271. request.Header.Set("x-tif-nonce", nonce)
  3272. client := http.Client{}
  3273. resp, err := client.Do(request)
  3274. if err != nil {
  3275. fmt.Println(err.Error())
  3276. return err.Error(), ""
  3277. }
  3278. respBytes, err := ioutil.ReadAll(resp.Body)
  3279. if err != nil {
  3280. fmt.Println(err.Error())
  3281. return err.Error(), ""
  3282. }
  3283. str := string(respBytes)
  3284. fmt.Println(str)
  3285. return str, string(bytesData)
  3286. }
  3287. 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) {
  3288. // 生成签名
  3289. nonce := GetRandomString(32)
  3290. timestamp := time.Now().Unix()
  3291. signature := setSignature(timestamp, nonce, secret_key)
  3292. inputMessage := make(map[string]interface{})
  3293. //tempTime := time.Unix(timestamp, 0)
  3294. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  3295. // 生成输入报文
  3296. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127"{
  3297. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs,doctor)
  3298. } else {
  3299. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3300. }
  3301. // 生成输入报文
  3302. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3303. input := make(map[string]interface{})
  3304. inputData := make(map[string]interface{})
  3305. if org_id == 10106 || org_id == 10215 || org_id == 10138 || org_id == 9504 {
  3306. inputMessage["infno"] = "4101A" // 交易编码
  3307. } else {
  3308. inputMessage["infno"] = "4101A" // 交易编码
  3309. }
  3310. year := time.Now().Format("2006")
  3311. month := time.Now().Format("01")
  3312. day := time.Now().Format("02")
  3313. inputData["mdtrt_id"] = struct4101.MdtrtId // 就诊 ID 必填(来自2201接口返回)
  3314. inputData["setl_id"] = struct4101.SetlId // 结算 ID 必填
  3315. inputData["psn_no"] = struct4101.PsnNo // 结算 ID 必填
  3316. inputData["fixmedins_name"] = org_name // 定点医药机构名称 必填
  3317. inputData["fixmedins_code"] = fixmedins_code // 定点医药机构编码 必填
  3318. inputData["hi_setl_lv"] = "" // 医保结算等级
  3319. inputData["hi_no"] = struct4101.PsnNo // 医保编号
  3320. inputData["medcasno"] = struct4101.PsnNo // 病案号 必填
  3321. inputData["dcla_time"] = year + "-" + month + "-" + day // 申报时间 必填
  3322. inputData["psn_name"] = struct4101.PsnName // 人员姓名 必填
  3323. inputData["gend"] = struct4101.Gend // 性别 必填
  3324. inputData["brdy"] = struct4101.Brdy // 出生日期 必填
  3325. inputData["age"] = struct4101.Age // 年龄 必填
  3326. inputData["ntly"] = struct4101.Ntly // 国籍 必填
  3327. inputData["nwb_age"] = "" // 年龄 必填
  3328. inputData["naty"] = struct4101.Naty // 民族 必填
  3329. //inputData["dscg_way"] = "9" // 民族 必填
  3330. //inputData["resp_nurs_code"] = "N441623001432" // 民族 必填
  3331. inputData["patn_cert_type"] = struct4101.PatnCertType // 患者证件类别 必填
  3332. inputData["certno"] = struct4101.Certno // 证件号码 必填
  3333. inputData["prfs"] = struct4101.Prfs // 职业 必填
  3334. inputData["curr_addr"] = "" // 现住址 必填
  3335. inputData["emp_name"] = "" // 单位名称 必填
  3336. inputData["emp_addr"] = "" // 单位地址 必填
  3337. inputData["emp_tel"] = "" // 单位电话 必填
  3338. inputData["poscode"] = "" // 邮编 必填
  3339. inputData["coner_name"] = struct4101.ConerName // 联系人姓名 必填
  3340. inputData["patn_rlts"] = struct4101.PatnRlts // 与患者关系 必填
  3341. inputData["coner_addr"] = struct4101.ConerAddr // 联系人地址 必填
  3342. inputData["coner_tel"] = struct4101.ConerTel // 联系人电话 必填
  3343. inputData["hi_type"] = struct4101.HiType // 医保类型 必填
  3344. inputData["insuplc"] = struct4101.Insuplc // 参保地 必填
  3345. inputData["sp_psn_type"] = "" // 特殊人员类型 必填
  3346. inputData["nwb_adm_type"] = "" // 新生儿入院类型 必填
  3347. inputData["nwb_bir_wt"] = "" // 新生儿出生体重 必填
  3348. inputData["nwb_adm_wt"] = "" // 新生儿入院体重 必填
  3349. inputData["opsp_diag_caty"] = "" // 门诊慢特病诊断 必填
  3350. inputData["opsp_mdtrt_date"] = "" // 门诊慢特病就诊日期 必填
  3351. inputData["ipt_med_type"] = "" // 住院医疗类型 必填
  3352. inputData["adm_way"] = "" // 入院途径 必填
  3353. inputData["trt_type"] = "10" // 治疗类别 必填
  3354. inputData["adm_time"] = "" // 入院时间 必填
  3355. inputData["adm_caty"] = "A03.06" // 入院科别 必填
  3356. inputData["refldept_dept"] = "" // 转科科别 必填
  3357. inputData["dscg_time"] = "" // 出院时间 必填
  3358. inputData["dscg_caty"] = "A03.06" // 出院科别 必填
  3359. inputData["caty"] = "A03.06" // 出院科别 必填
  3360. inputData["act_ipt_days"] = "" // 实际住院天数 必填
  3361. inputData["otp_wm_dise"] = "" // 门(急) 诊西医诊断 必填
  3362. inputData["wm_dise_code"] = "" // 门(急) 诊中医诊断 必填
  3363. inputData["otp_tcm_dise"] = "" // 西医诊断疾病代码 必填
  3364. inputData["tcm_dise_code"] = "" // 中医诊断代码 必填
  3365. inputData["oprn_oprt_code_cnt"] = "" // 手术操作代码计数 必填
  3366. inputData["vent_used_dura"] = "" // 呼吸机使用时长 必填
  3367. inputData["pwcry_bfadm_coma_dura"] = "" // 颅脑损伤患者入院前昏迷时长 必填
  3368. inputData["pwcry_afadm_coma_dura"] = "" // 颅脑损伤患者入院后昏迷时长 必填
  3369. inputData["bld_cat"] = "" // 输血品种 必填
  3370. inputData["bld_amt"] = "" // 输血量 必填
  3371. inputData["bld_unt"] = "" // 输血计量单位 必填
  3372. inputData["spga_nurscare_days"] = "" // 特级护理天数 必填
  3373. inputData["lv1_nurscare_days"] = "" // 一级护理天数 必填
  3374. inputData["scd_nurscare_days"] = "" // 二级护理天数 必填
  3375. inputData["lv3_nurscare_days"] = "" // 三级护理天数 必填
  3376. inputData["acp_medins_name"] = "" // 拟接收机构名称 必填
  3377. inputData["acp_optins_code"] = "" // 拟接收机构代码 必填
  3378. inputData["bill_code"] = struct4101.BillCode // 票据代码 必填
  3379. inputData["bill_no"] = struct4101.BillNo // 票据号码 必填
  3380. inputData["biz_sn"] = struct4101.BizSn // 业务流水号 必填
  3381. inputData["days_rinp_flag_31"] = "" // 出院 31 天内再住院计划标志 必填
  3382. inputData["days_rinp_pup_31"] = "" // 出院 31 天内再住院目的 必填
  3383. inputData["chfpdr_name"] = struct4101.DoctorName // 主诊医师姓名 必填
  3384. inputData["chfpdr_code"] = struct4101.DoctorCode // 主诊医师代码 必填
  3385. inputData["setl_begn_date"] = struct4101.SetlBegnDate // 结算开始日期 必填
  3386. inputData["setl_end_date"] = struct4101.SetlEndDate // 结算结束日期 必填
  3387. inputData["psn_selfpay"] = struct4101.PsnSelfPay // 个人自付 必填
  3388. inputData["psn_ownpay"] = struct4101.PsnOwnPay // 个人自费 必填
  3389. inputData["acct_pay"] = struct4101.AcctPay // 个人账户支出 必填
  3390. inputData["hi_paymtd"] = struct4101.HiPaymtd // 医保支付方式 必填
  3391. inputData["hsorg"] = struct4101.Hsorg // 医保机构 必填
  3392. inputData["hsorg_opter"] = struct4101.HsorgOpter // 医保机构经办人 必填
  3393. inputData["medins_fill_dept"] = struct4101.MedinsFillDept // 医疗机构填报部门 必填
  3394. inputData["medins_fill_psn"] = struct4101.MedinsFillPsn // 医疗机构填报人 必填
  3395. inputData["psn_cashpay"] = struct4101.PsnCashpay // 医疗机构填报人 必填
  3396. inputData["dscg_way"] ="1" // 医疗机构填报人 必填
  3397. payinfo := make([]map[string]interface{}, 0) // 基金支付信息
  3398. for _, item := range struct4101.CustomStruct {
  3399. payinfotemp := make(map[string]interface{})
  3400. 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" {
  3401. payinfotemp["fund_pay_type"] = item.FundPayType // 基金支付类型 必填
  3402. payinfotemp["fund_payamt"] = item.FundPayamt // 基金支付金额
  3403. payinfo = append(payinfo, payinfotemp)
  3404. }
  3405. }
  3406. opspdiseinfo := make([]map[string]interface{}, 0) // 门诊慢特病诊断信息
  3407. opspdiseinfotemp := make(map[string]interface{})
  3408. opspdiseinfotemp["diag_name"] = "慢性肾功能不全(血透治疗)" // 诊断名称 必填
  3409. opspdiseinfotemp["diag_code"] = "N18.904" // 诊断代码 必填
  3410. opspdiseinfotemp["oprn_oprt_name"] = "血液透析" // 手术操作名称 必填
  3411. opspdiseinfotemp["oprn_oprt_code"] = "39.9500" // 手术操作代码 必填
  3412. opspdiseinfo = append(opspdiseinfo, opspdiseinfotemp)
  3413. diseinfo := make([]map[string]interface{}, 0) // 住院诊断信息
  3414. for _, item := range struct4101.Diseinfo {
  3415. diseinfotemp := make(map[string]interface{})
  3416. diseinfotemp["maindiag_flag"] = item.MaindiagFlag // 手术操作代码 必填
  3417. diseinfotemp["diag_type"] = item.DiagType // 诊断类别 必填
  3418. diseinfotemp["diag_code"] = item.DiagCode // 诊断代码 必填
  3419. diseinfotemp["diag_name"] = item.DiagName // 诊断名称 必填
  3420. diseinfotemp["adm_cond_type"] = "3" // 入院病情类型 必填
  3421. diseinfo = append(diseinfo, diseinfotemp)
  3422. }
  3423. oprninfo := make([]map[string]interface{}, 0) // 手术操作信息
  3424. oprninfotemp := make(map[string]interface{})
  3425. oprninfotemp["oprn_oprt_type"] = "" // 手术操作类别 必填
  3426. oprninfotemp["oprn_oprt_name"] = "" // 手术操作名称 必填
  3427. oprninfotemp["oprn_oprt_code"] = "" // 手术操作代码 必填
  3428. oprninfotemp["oprn_oprt_date"] = "" // 手术操作日期 必填
  3429. oprninfotemp["anst_way"] = "" // 麻醉方式 必填
  3430. oprninfotemp["oper_dr_name"] = "" // 术者医师姓名 必填
  3431. oprninfotemp["oper_dr_code"] = "" // 术者医师代码 必填
  3432. oprninfotemp["anst_dr_name"] = "" // 麻醉医师姓名 必填
  3433. oprninfotemp["anst_dr_code"] = "" // 麻醉医师代码 必填
  3434. oprninfo = append(oprninfo, oprninfotemp)
  3435. icuinfo := make([]map[string]interface{}, 0) // 重症监护信息
  3436. icuinfotemp := make(map[string]interface{})
  3437. icuinfotemp["scs_cutd_ward_type"] = "" // 重症监护病房类型 必填
  3438. icuinfotemp["scs_cutd_inpool_time"] = "" // 重症监护进入时间 必填
  3439. icuinfotemp["scs_cutd_exit_time"] = "" // 重症监护退出时间 必填
  3440. icuinfotemp["scs_cutd_sum_dura"] = "" // 重症监护合计时长 必填
  3441. icuinfo = append(icuinfo, icuinfotemp)
  3442. input["setlinfo"] = inputData
  3443. input["payinfo"] = payinfo
  3444. input["opspdiseinfo"] = opspdiseinfo
  3445. input["diseinfo"] = diseinfo
  3446. inputMessage["input"] = input //交易输入
  3447. bytesData, err := json.Marshal(inputMessage)
  3448. fmt.Println(string(bytesData))
  3449. if err != nil {
  3450. fmt.Println(err.Error())
  3451. return err.Error(), ""
  3452. }
  3453. reader := bytes.NewReader(bytesData)
  3454. gdyb_url := beego.AppConfig.String("gdyb_url")
  3455. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3456. //url := gdyb_url + "4101"
  3457. var url string
  3458. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127"{
  3459. url = gdyb_url
  3460. //inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs,doctor)
  3461. } else {
  3462. //inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3463. url = gdyb_url
  3464. }
  3465. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/4101"
  3466. request, err := http.NewRequest("POST", url, reader)
  3467. if err != nil {
  3468. fmt.Println(err.Error())
  3469. return err.Error(), ""
  3470. }
  3471. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3472. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3473. request.Header.Set("x-tif-signature", signature)
  3474. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3475. request.Header.Set("x-tif-nonce", nonce)
  3476. client := http.Client{}
  3477. resp, err := client.Do(request)
  3478. if err != nil {
  3479. fmt.Println(err.Error())
  3480. return err.Error(), ""
  3481. }
  3482. respBytes, err := ioutil.ReadAll(resp.Body)
  3483. if err != nil {
  3484. fmt.Println(err.Error())
  3485. return err.Error(), ""
  3486. }
  3487. str := string(respBytes)
  3488. fmt.Println(str)
  3489. return str, string(bytesData)
  3490. }
  3491. 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) {
  3492. // 生成签名
  3493. nonce := GetRandomString(32)
  3494. timestamp := time.Now().Unix()
  3495. signature := setSignature(timestamp, nonce, secret_key)
  3496. // 生成输入报文
  3497. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3498. input := make(map[string]interface{})
  3499. inputData := make(map[string]interface{})
  3500. inputMessage["infno"] = "4101A" // 交易编码
  3501. year := time.Now().Format("2006")
  3502. month := time.Now().Format("01")
  3503. day := time.Now().Format("02")
  3504. inputData["mdtrt_id"] = struct4101.MdtrtId // 就诊 ID 必填(来自2201接口返回)
  3505. inputData["setl_id"] = struct4101.SetlId // 结算 ID 必填
  3506. inputData["psn_no"] = struct4101.PsnNo // 结算 ID 必填
  3507. inputData["fixmedins_name"] = org_name // 定点医药机构名称 必填
  3508. inputData["fixmedins_code"] = fixmedins_code // 定点医药机构编码 必填
  3509. inputData["hi_setl_lv"] = "" // 医保结算等级
  3510. inputData["hi_no"] = struct4101.PsnNo // 医保编号
  3511. inputData["medcasno"] = struct4101.PsnNo // 病案号 必填
  3512. inputData["dcla_time"] = year + "-" + month + "-" + day // 申报时间 必填
  3513. inputData["psn_name"] = struct4101.PsnName // 人员姓名 必填
  3514. inputData["gend"] = struct4101.Gend // 性别 必填
  3515. inputData["brdy"] = struct4101.Brdy // 出生日期 必填
  3516. inputData["age"] = struct4101.Age // 年龄 必填
  3517. inputData["ntly"] = struct4101.Ntly // 国籍 必填
  3518. inputData["nwb_age"] = "" // 年龄 必填
  3519. inputData["naty"] = struct4101.Naty // 民族 必填
  3520. inputData["patn_cert_type"] = struct4101.PatnCertType // 患者证件类别 必填
  3521. inputData["certno"] = struct4101.Certno // 证件号码 必填
  3522. inputData["prfs"] = struct4101.Prfs // 职业 必填
  3523. inputData["curr_addr"] = "" // 现住址 必填
  3524. inputData["emp_name"] = "" // 单位名称 必填
  3525. inputData["emp_addr"] = "" // 单位地址 必填
  3526. inputData["emp_tel"] = "" // 单位电话 必填
  3527. inputData["poscode"] = "" // 邮编 必填
  3528. inputData["coner_name"] = struct4101.ConerName // 联系人姓名 必填
  3529. inputData["patn_rlts"] = struct4101.PatnRlts // 与患者关系 必填
  3530. inputData["coner_addr"] = struct4101.ConerAddr // 联系人地址 必填
  3531. inputData["coner_tel"] = struct4101.ConerTel // 联系人电话 必填
  3532. inputData["hi_type"] = struct4101.HiType // 医保类型 必填
  3533. inputData["insuplc"] = struct4101.Insuplc // 参保地 必填
  3534. inputData["sp_psn_type"] = "" // 特殊人员类型 必填
  3535. inputData["nwb_adm_type"] = "" // 新生儿入院类型 必填
  3536. inputData["nwb_bir_wt"] = "" // 新生儿出生体重 必填
  3537. inputData["nwb_adm_wt"] = "" // 新生儿入院体重 必填
  3538. inputData["opsp_diag_caty"] = "" // 门诊慢特病诊断 必填
  3539. inputData["opsp_mdtrt_date"] = "" // 门诊慢特病就诊日期 必填
  3540. inputData["ipt_med_type"] = "" // 住院医疗类型 必填
  3541. inputData["adm_way"] = "" // 入院途径 必填
  3542. inputData["trt_type"] = "10" // 治疗类别 必填
  3543. inputData["adm_time"] = struct4101.AdmTime // 入院时间 必填
  3544. inputData["adm_caty"] = struct4101.AdmCaty // 入院科别 必填
  3545. inputData["refldept_dept"] = "" // 转科科别 必填
  3546. inputData["dscg_time"] = struct4101.AdmEndTime // 出院时间 必填
  3547. inputData["dscg_caty"] = struct4101.DscgCaty // 出院科别 必填
  3548. inputData["act_ipt_days"] = "" // 实际住院天数 必填
  3549. inputData["otp_wm_dise"] = "" // 门(急) 诊西医诊断 必填
  3550. inputData["wm_dise_code"] = "" // 门(急) 诊中医诊断 必填
  3551. inputData["otp_tcm_dise"] = "" // 西医诊断疾病代码 必填
  3552. inputData["tcm_dise_code"] = "" // 中医诊断代码 必填
  3553. inputData["oprn_oprt_code_cnt"] = "" // 手术操作代码计数 必填
  3554. inputData["vent_used_dura"] = "" // 呼吸机使用时长 必填
  3555. inputData["pwcry_bfadm_coma_dura"] = "" // 颅脑损伤患者入院前昏迷时长 必填
  3556. inputData["pwcry_afadm_coma_dura"] = "" // 颅脑损伤患者入院后昏迷时长 必填
  3557. inputData["bld_cat"] = "" // 输血品种 必填
  3558. inputData["bld_amt"] = "" // 输血量 必填
  3559. inputData["bld_unt"] = "" // 输血计量单位 必填
  3560. inputData["spga_nurscare_days"] = "" // 特级护理天数 必填
  3561. inputData["lv1_nurscare_days"] = "" // 一级护理天数 必填
  3562. inputData["scd_nurscare_days"] = "" // 二级护理天数 必填
  3563. inputData["lv3_nurscare_days"] = "" // 三级护理天数 必填
  3564. inputData["acp_medins_name"] = "" // 拟接收机构名称 必填
  3565. inputData["acp_optins_code"] = "" // 拟接收机构代码 必填
  3566. inputData["bill_code"] = struct4101.BillCode // 票据代码 必填
  3567. inputData["bill_no"] = struct4101.BillNo // 票据号码 必填
  3568. inputData["biz_sn"] = struct4101.BizSn // 业务流水号 必填
  3569. inputData["days_rinp_flag_31"] = "" // 出院 31 天内再住院计划标志 必填
  3570. inputData["days_rinp_pup_31"] = "" // 出院 31 天内再住院目的 必填
  3571. inputData["chfpdr_name"] = struct4101.DoctorName // 主诊医师姓名 必填
  3572. inputData["chfpdr_code"] = struct4101.DoctorCode // 主诊医师代码 必填
  3573. inputData["setl_begn_date"] = struct4101.SetlBegnDate // 结算开始日期 必填
  3574. inputData["setl_end_date"] = struct4101.SetlEndDate // 结算结束日期 必填
  3575. inputData["psn_selfpay"] = struct4101.PsnSelfPay // 个人自付 必填
  3576. inputData["psn_ownpay"] = struct4101.PsnOwnPay // 个人自费 必填
  3577. inputData["acct_pay"] = struct4101.AcctPay // 个人账户支出 必填
  3578. inputData["hi_paymtd"] = struct4101.HiPaymtd // 医保支付方式 必填
  3579. inputData["hsorg"] = struct4101.Hsorg // 医保机构 必填
  3580. inputData["hsorg_opter"] = struct4101.HsorgOpter // 医保机构经办人 必填
  3581. inputData["medins_fill_dept"] = struct4101.MedinsFillDept // 医疗机构填报部门 必填
  3582. inputData["medins_fill_psn"] = struct4101.MedinsFillPsn // 医疗机构填报人 必填
  3583. inputData["psn_cashpay"] = struct4101.PsnCashpay // 医疗机构填报人 必填
  3584. payinfo := make([]map[string]interface{}, 0) // 基金支付信息
  3585. for _, item := range struct4101.CustomStruct {
  3586. payinfotemp := make(map[string]interface{})
  3587. 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" {
  3588. payinfotemp["fund_pay_type"] = item.FundPayType // 基金支付类型 必填
  3589. payinfotemp["fund_payamt"] = item.FundPayamt // 基金支付金额
  3590. payinfo = append(payinfo, payinfotemp)
  3591. }
  3592. }
  3593. opspdiseinfo := make([]map[string]interface{}, 0) // 门诊慢特病诊断信息
  3594. opspdiseinfotemp := make(map[string]interface{})
  3595. opspdiseinfotemp["diag_name"] = struct4101.Diseinfo[len(struct4101.Diseinfo)-1].DiagName // 诊断名称 必填
  3596. opspdiseinfotemp["diag_code"] = struct4101.Diseinfo[len(struct4101.Diseinfo)-1].DiagCode // 诊断代码 必填
  3597. opspdiseinfotemp["oprn_oprt_name"] = "血液透析" // 手术操作名称 必填
  3598. opspdiseinfotemp["oprn_oprt_code"] = "39.9500" // 手术操作代码 必填
  3599. opspdiseinfo = append(opspdiseinfo, opspdiseinfotemp)
  3600. diseinfo := make([]map[string]interface{}, 0) // 住院诊断信息
  3601. for _, item := range struct4101.Diseinfo {
  3602. diseinfotemp := make(map[string]interface{})
  3603. diseinfotemp["maindiag_flag"] = item.MaindiagFlag // 手术操作代码 必填
  3604. diseinfotemp["diag_type"] = item.DiagType // 诊断类别 必填
  3605. diseinfotemp["diag_code"] = item.DiagCode // 诊断代码 必填
  3606. diseinfotemp["diag_name"] = item.DiagName // 诊断名称 必填
  3607. diseinfotemp["adm_cond_type"] = "3" // 入院病情类型 必填
  3608. diseinfo = append(diseinfo, diseinfotemp)
  3609. }
  3610. iteminfo := make([]map[string]interface{}, 0)
  3611. for _, item := range struct4101.IteminfoStruct {
  3612. iteminfotemp := make(map[string]interface{})
  3613. iteminfotemp["med_chrgitm"] = item.MedChrgitm // 医疗收费项目 必填
  3614. iteminfotemp["amt"] = item.Amt // 金额 必填
  3615. iteminfotemp["claa_sumfee"] = item.ClaaSumfee // 甲类费用合计 必填
  3616. iteminfotemp["clab_amt"] = item.ClabAmt // 乙类金额 必填
  3617. iteminfotemp["fulamt_ownpay_amt"] = item.FulamtOwnpayAmt // 全自费金额 必填
  3618. iteminfotemp["oth_amt"] = item.OthAmt // 其他金额 必填
  3619. iteminfo = append(iteminfo, iteminfotemp)
  3620. }
  3621. oprninfo := make([]map[string]interface{}, 0) // 手术操作信息
  3622. oprninfotemp := make(map[string]interface{})
  3623. oprninfotemp["oprn_oprt_type"] = "" // 手术操作类别 必填
  3624. oprninfotemp["oprn_oprt_name"] = "" // 手术操作名称 必填
  3625. oprninfotemp["oprn_oprt_code"] = "" // 手术操作代码 必填
  3626. oprninfotemp["oprn_oprt_date"] = "" // 手术操作日期 必填
  3627. oprninfotemp["anst_way"] = "" // 麻醉方式 必填
  3628. oprninfotemp["oper_dr_name"] = "" // 术者医师姓名 必填
  3629. oprninfotemp["oper_dr_code"] = "" // 术者医师代码 必填
  3630. oprninfotemp["anst_dr_name"] = "" // 麻醉医师姓名 必填
  3631. oprninfotemp["anst_dr_code"] = "" // 麻醉医师代码 必填
  3632. oprninfo = append(oprninfo, oprninfotemp)
  3633. icuinfo := make([]map[string]interface{}, 0) // 重症监护信息
  3634. icuinfotemp := make(map[string]interface{})
  3635. icuinfotemp["scs_cutd_ward_type"] = "" // 重症监护病房类型 必填
  3636. icuinfotemp["scs_cutd_inpool_time"] = "" // 重症监护进入时间 必填
  3637. icuinfotemp["scs_cutd_exit_time"] = "" // 重症监护退出时间 必填
  3638. icuinfotemp["scs_cutd_sum_dura"] = "" // 重症监护合计时长 必填
  3639. icuinfo = append(icuinfo, icuinfotemp)
  3640. input["setlinfo"] = inputData
  3641. input["payinfo"] = payinfo
  3642. input["opspdiseinfo"] = opspdiseinfo
  3643. input["diseinfo"] = diseinfo
  3644. input["iteminfo"] = iteminfo
  3645. inputMessage["input"] = input //交易输入
  3646. bytesData, err := json.Marshal(inputMessage)
  3647. fmt.Println(string(bytesData))
  3648. if err != nil {
  3649. fmt.Println(err.Error())
  3650. return err.Error(), ""
  3651. }
  3652. reader := bytes.NewReader(bytesData)
  3653. gdyb_url := beego.AppConfig.String("gdyb_url")
  3654. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3655. //url := gdyb_url + "4101"
  3656. var url string
  3657. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  3658. url = gdyb_url
  3659. } else {
  3660. url = gdyb_url + "4101A"
  3661. }
  3662. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/4101"
  3663. request, err := http.NewRequest("POST", url, reader)
  3664. if err != nil {
  3665. fmt.Println(err.Error())
  3666. return err.Error(), ""
  3667. }
  3668. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3669. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3670. request.Header.Set("x-tif-signature", signature)
  3671. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3672. request.Header.Set("x-tif-nonce", nonce)
  3673. client := http.Client{}
  3674. resp, err := client.Do(request)
  3675. if err != nil {
  3676. fmt.Println(err.Error())
  3677. return err.Error(), ""
  3678. }
  3679. respBytes, err := ioutil.ReadAll(resp.Body)
  3680. if err != nil {
  3681. fmt.Println(err.Error())
  3682. return err.Error(), ""
  3683. }
  3684. str := string(respBytes)
  3685. fmt.Println(str)
  3686. return str, string(bytesData)
  3687. }
  3688. 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) {
  3689. // 生成签名
  3690. nonce := GetRandomString(32)
  3691. timestamp := time.Now().Unix()
  3692. signature := setSignature(timestamp, nonce, secret_key)
  3693. // 生成输入报文
  3694. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3695. input := make(map[string]interface{})
  3696. inputData := make(map[string]interface{})
  3697. inputMessage["infno"] = "4101A" // 交易编码
  3698. year := time.Now().Format("2006")
  3699. month := time.Now().Format("01")
  3700. day := time.Now().Format("02")
  3701. inputData["psn_no"] = struct4101.PsnNo // 结算 ID 必填
  3702. inputData["mdtrt_id"] = struct4101.MdtrtId // 就诊 ID 必填(来自2201接口返回)
  3703. inputData["setl_id"] = struct4101.SetlId // 结算 ID 必填
  3704. inputData["hi_no"] = struct4101.PsnNo // 医保编号
  3705. inputData["medcasno"] = struct4101.PsnNo // 病案号 必填
  3706. inputData["dcla_time"] = year + "-" + month + "-" + day // 申报时间 必填
  3707. inputData["ntly"] = struct4101.Ntly // 国籍 必填
  3708. inputData["prfs"] = struct4101.Prfs // 职业 必填
  3709. inputData["curr_addr"] = struct4101.CurAddr // 现住址 必填
  3710. inputData["emp_name"] = "" // 单位名称 必填
  3711. inputData["emp_addr"] = "" // 单位地址 必填
  3712. inputData["emp_tel"] = ""
  3713. inputData["poscode"] = "" // 邮编 必填
  3714. inputData["coner_name"] = "" // 联系人姓名 必填
  3715. inputData["patn_rlts"] = "" // 与患者关系 必填
  3716. inputData["coner_addr"] = "" // 联系人地址 必填
  3717. inputData["coner_tel"] = ""
  3718. inputData["nwb_adm_type"] = "" // 新生儿入院类型 必填
  3719. inputData["nwb_bir_wt"] = "" // 新生儿出生体重 必填
  3720. inputData["nwb_adm_wt"] = "" // 新生儿入院体重 必填
  3721. inputData["mul_nwb_bir_wt"] = "" // 新生儿入院体重 必填
  3722. inputData["mul_nwb_adm_wt"] = "" // 新生儿入院体重 必填
  3723. inputData["opsp_diag_caty"] = "" // 门诊慢特病诊断 必填
  3724. inputData["opsp_mdtrt_date"] = "" // 门诊慢特病就诊日期 必填
  3725. inputData["adm_way"] = "" // 入院途径 必填
  3726. inputData["trt_type"] = "" // 治疗类别 必填
  3727. inputData["adm_time"] = "" // 入院时间 必填
  3728. inputData["refldept_dept"] = "" // 转科科别 必填
  3729. inputData["dscg_time"] = "" // 出院时间 必填
  3730. inputData["dscg_caty"] = "" // 出院科别 必填
  3731. inputData["otp_wm_dise"] = "" // 门(急) 诊西医诊断 必填
  3732. inputData["wm_dise_code"] = "" // 门(急) 诊中医诊断 必填
  3733. inputData["otp_tcm_dise"] = "" // 西医诊断疾病代码 必填
  3734. inputData["tcm_dise_code"] = "" // 中医诊断代码 必填
  3735. inputData["vent_used_dura"] = "" // 呼吸机使用时长 必填
  3736. inputData["pwcry_bfadm_coma_dura"] = "" // 颅脑损伤患者入院前昏迷时长 必填
  3737. inputData["pwcry_afadm_coma_dura"] = "" // 颅脑损伤患者入院后昏迷时长 必填
  3738. inputData["spga_nurscare_days"] = "" // 特级护理天数 必填
  3739. inputData["lv1_nurscare_days"] = "" // 一级护理天数 必填
  3740. inputData["scd_nurscare_days"] = "" // 二级护理天数 必填
  3741. inputData["lv3_nurscare_days"] = "" // 三级护理天数 必填
  3742. inputData["acp_medins_name"] = "" // 拟接收机构名称 必填
  3743. inputData["acp_optins_code"] = "" // 拟接收机构代码 必填
  3744. inputData["bill_code"] = struct4101.BillCode // 票据代码 必填
  3745. inputData["bill_no"] = struct4101.BillNo // 票据号码 必填
  3746. inputData["biz_sn"] = struct4101.BizSn // 业务流水号 必填
  3747. inputData["hi_paymtd"] = "1" // 业务流水号 必填
  3748. inputData["days_rinp_flag_31"] = "" // 出院 31 天内再住院计划标志 必填
  3749. inputData["days_rinp_pup_31"] = "" // 出院 31 天内再住院目的 必填
  3750. //inputData["chfpdr_name"] = struct4101.DoctorName // 主诊医师姓名 必填
  3751. //inputData["chfpdr_code"] = struct4101.DoctorCode // 主诊医师代码 必填
  3752. inputData["setl_begn_date"] = struct4101.SetlBegnDate // 结算开始日期 必填
  3753. inputData["setl_end_date"] = struct4101.SetlEndDate // 结算结束日期 必填
  3754. inputData["medins_fill_dept"] = struct4101.MedinsFillDept // 医疗机构填报部门 必填
  3755. inputData["medins_fill_psn"] = struct4101.MedinsFillPsn // 医疗机构填报人 必填
  3756. //payinfo := make([]map[string]interface{}, 0) // 基金支付信息
  3757. //for _, item := range struct4101.CustomStruct {
  3758. // payinfotemp := make(map[string]interface{})
  3759. // 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" {
  3760. // payinfotemp["fund_pay_type"] = item.FundPayType // 基金支付类型 必填
  3761. // payinfotemp["fund_payamt"] = item.FundPayamt // 基金支付金额
  3762. // payinfo = append(payinfo, payinfotemp)
  3763. // }
  3764. //}
  3765. opspdiseinfo := make([]map[string]interface{}, 0) // 门诊慢特病诊断信息
  3766. opspdiseinfotemp := make(map[string]interface{})
  3767. opspdiseinfotemp["diag_name"] = "慢性肾脏病5期" // 诊断名称 必填
  3768. opspdiseinfotemp["diag_code"] = "N18.500" // 诊断代码 必填
  3769. opspdiseinfotemp["oprn_oprt_name"] = "血液透析" // 手术操作名称 必填
  3770. opspdiseinfotemp["oprn_oprt_code"] = "39.9500" // 手术操作代码 必填
  3771. opspdiseinfo = append(opspdiseinfo, opspdiseinfotemp)
  3772. diseinfo := make([]map[string]interface{}, 0) // 住院诊断信息
  3773. for _, item := range struct4101.Diseinfo {
  3774. diseinfotemp := make(map[string]interface{})
  3775. diseinfotemp["maindiag_flag"] = item.MaindiagFlag // 手术操作代码 必填
  3776. diseinfotemp["diag_type"] = item.DiagType // 诊断类别 必填
  3777. diseinfotemp["diag_code"] = item.DiagCode // 诊断代码 必填
  3778. diseinfotemp["diag_name"] = item.DiagName // 诊断名称 必填
  3779. diseinfotemp["adm_cond_type"] = "3" // 入院病情类型 必填
  3780. diseinfo = append(diseinfo, diseinfotemp)
  3781. }
  3782. //iteminfo := make([]map[string]interface{}, 0)
  3783. //for _, item := range struct4101.IteminfoStruct {
  3784. // iteminfotemp := make(map[string]interface{})
  3785. // iteminfotemp["med_chrgitm"] = item.MedChrgitm // 医疗收费项目 必填
  3786. // iteminfotemp["amt"] = item.Amt // 金额 必填
  3787. // iteminfotemp["claa_sumfee"] = item.ClaaSumfee // 甲类费用合计 必填
  3788. // iteminfotemp["clab_amt"] = item.ClabAmt // 乙类金额 必填
  3789. // iteminfotemp["fulamt_ownpay_amt"] = item.FulamtOwnpayAmt // 全自费金额 必填
  3790. // iteminfotemp["oth_amt"] = item.OthAmt // 其他金额 必填
  3791. // iteminfo = append(iteminfo, iteminfotemp)
  3792. //}
  3793. oprninfo := make([]map[string]interface{}, 0) // 手术操作信息
  3794. oprninfotemp := make(map[string]interface{})
  3795. oprninfotemp["oprn_oprt_type"] = "" // 手术操作类别 必填
  3796. oprninfotemp["oprn_oprt_name"] = "" // 手术操作名称 必填
  3797. oprninfotemp["oprn_oprt_code"] = "" // 手术操作代码 必填
  3798. oprninfotemp["oprn_oprt_date"] = "" // 手术操作日期 必填
  3799. oprninfotemp["anst_way"] = "" // 麻醉方式 必填
  3800. oprninfotemp["oper_dr_name"] = "" // 术者医师姓名 必填
  3801. oprninfotemp["oper_dr_code"] = "" // 术者医师代码 必填
  3802. oprninfotemp["anst_dr_name"] = "" // 麻醉医师姓名 必填
  3803. oprninfotemp["anst_dr_code"] = "" // 麻醉医师代码 必填
  3804. oprninfo = append(oprninfo, oprninfotemp)
  3805. icuinfo := make([]map[string]interface{}, 0) // 重症监护信息
  3806. icuinfotemp := make(map[string]interface{})
  3807. icuinfotemp["scs_cutd_ward_type"] = "" // 重症监护病房类型 必填
  3808. icuinfotemp["scs_cutd_inpool_time"] = "" // 重症监护进入时间 必填
  3809. icuinfotemp["scs_cutd_exit_time"] = "" // 重症监护退出时间 必填
  3810. icuinfotemp["scs_cutd_sum_dura"] = "" // 重症监护合计时长 必填
  3811. icuinfo = append(icuinfo, icuinfotemp)
  3812. input["setlinfo"] = inputData
  3813. input["opspdiseinfo"] = opspdiseinfo
  3814. //input["diseinfo"] = diseinfo
  3815. //input["oprninfo"] = payinfo
  3816. //input["icuinfo"] = payinfo
  3817. //input["bldinfo"] = payinfo
  3818. inputMessage["input"] = input //交易输入
  3819. bytesData, err := json.Marshal(inputMessage)
  3820. fmt.Println(string(bytesData))
  3821. if err != nil {
  3822. fmt.Println(err.Error())
  3823. return err.Error(), ""
  3824. }
  3825. reader := bytes.NewReader(bytesData)
  3826. gdyb_url := beego.AppConfig.String("gdyb_url")
  3827. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3828. //url := gdyb_url + "4101"
  3829. var url string
  3830. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  3831. url = gdyb_url
  3832. } else {
  3833. url = gdyb_url + "4101A"
  3834. }
  3835. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/4101"
  3836. request, err := http.NewRequest("POST", url, reader)
  3837. if err != nil {
  3838. fmt.Println(err.Error())
  3839. return err.Error(), ""
  3840. }
  3841. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3842. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3843. request.Header.Set("x-tif-signature", signature)
  3844. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3845. request.Header.Set("x-tif-nonce", nonce)
  3846. client := http.Client{}
  3847. resp, err := client.Do(request)
  3848. if err != nil {
  3849. fmt.Println(err.Error())
  3850. return err.Error(), ""
  3851. }
  3852. respBytes, err := ioutil.ReadAll(resp.Body)
  3853. if err != nil {
  3854. fmt.Println(err.Error())
  3855. return err.Error(), ""
  3856. }
  3857. str := string(respBytes)
  3858. fmt.Println(str)
  3859. return str, string(bytesData)
  3860. }
  3861. //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 {
  3862. // // 生成签名
  3863. // nonce := GetRandomString(32)
  3864. // timestamp := time.Now().Unix()
  3865. // signature := setSignature(timestamp, nonce, secret_key)
  3866. // tempTime := time.Unix(timestamp, 0)
  3867. // //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  3868. //
  3869. // timeFormatTwo := tempTime.Format("2006-01-02")
  3870. //
  3871. // t := time.Now()
  3872. // last := time.Date(t.Year(), time.December, 31, 0, 0, 0, 0, time.UTC)
  3873. // tm := time.Unix(last.Unix(), 0)
  3874. //
  3875. // // 生成输入报文
  3876. // inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3877. // input := make(map[string]interface{})
  3878. // inputData := make(map[string]interface{})
  3879. //
  3880. // inputData2 := make(map[string]interface{})
  3881. //
  3882. // inputMessage["infno"] = "7101" // 交易编码
  3883. // inputData["hosp_rxno"] = psnNo // 人员编号 (来自1101接口返回)
  3884. // inputData["init_rxno"] = insutype // 险种类型(来自1101接口返回)
  3885. // inputData["rx_type_code"] = sick_code // 险种类型(来自1101接口返回)
  3886. // inputData["prsc_time"] = sick_name // 险种类型(来自1101接口返回)
  3887. // inputData["rx_drug_nums"] = insuplc_admdvs // 险种类型(来自1101接口返回)
  3888. // inputData["rx_way_codg"] = fixmedins_code // 险种类型(来自1101接口返回)
  3889. // inputData["rx_way_name"] = org_name // 险种类型(来自1101接口返回)
  3890. // inputData["rx_freq_codg"] = timeFormatTwo // 险种类型(来自1101接口返回)
  3891. // inputData["rx_freq_name"] = doctor_id // 开始时间
  3892. // inputData["rx_dosunt"] = doctor // 开始时间
  3893. // inputData["rx_doscnt"] = timeFormatTwo // 医师编码
  3894. // inputData["rx_drord_dscr"] = "" // 医师编码
  3895. // inputData["valid_days"] = "" // 医师编码
  3896. // inputData["valid_end_time"] = tm.Format("2006-01-02") // 医师编码
  3897. // inputData["rept_flag"] = tm.Format("2006-01-02") // 医师编码
  3898. // inputData["max_rept_cnt"] = tm.Format("2006-01-02") // 医师编码
  3899. // inputData["reptd_cnt"] = tm.Format("2006-01-02") // 医师编码
  3900. // inputData["min_inrv_days"] = tm.Format("2006-01-02") // 医师编码
  3901. // inputData["dr_sign_info"] = tm.Format("2006-01-02") // 医师编码
  3902. // inputData["phar_sign_info"] = tm.Format("2006-01-02") // 医师编码
  3903. // inputData["fixmedins_sign_info"] = tm.Format("2006-01-02") // 医师编码
  3904. // inputData["rx_cotn_flag"] = tm.Format("2006-01-02") // 医师编码
  3905. // inputData["rx_file"] = tm.Format("2006-01-02") // 医师编码
  3906. // input["data"] = inputData
  3907. //
  3908. //
  3909. // inputData2["med_list_codg"] = psnNo // 人员编号 (来自1101接口返回)
  3910. // inputData2["fixmedins_hilist_id"] = insutype // 险种类型(来自1101接口返回)
  3911. // inputData["hosp_prep_flag"] = sick_code // 险种类型(来自1101接口返回)
  3912. // inputData["rx_item_type_code"] = sick_name // 险种类型(来自1101接口返回)
  3913. // inputData["rx_item_type_name"] = insuplc_admdvs // 险种类型(来自1101接口返回)
  3914. // inputData["tcmdrug_type_name"] = fixmedins_code // 险种类型(来自1101接口返回)
  3915. // inputData["tcmdrug_type_code"] = org_name // 险种类型(来自1101接口返回)
  3916. // inputData["tcmherb_foote"] = timeFormatTwo // 险种类型(来自1101接口返回)
  3917. // inputData["medn_type_code"] = doctor_id // 开始时间
  3918. // inputData["medn_type_name"] = doctor // 开始时间
  3919. // inputData["main_medc_flag"] = timeFormatTwo // 医师编码
  3920. // inputData["urgt_flag"] = "" // 医师编码
  3921. // inputData["bas_medn_flag"] = "" // 医师编码
  3922. // inputData["imp_drug_flag"] = tm.Format("2006-01-02") // 医师编码
  3923. // inputData["prod_barc"] = tm.Format("2006-01-02") // 医师编码
  3924. // inputData["drug_prodname"] = tm.Format("2006-01-02") // 医师编码
  3925. //
  3926. // inputData["genname_codg"] = tm.Format("2006-01-02") // 医师编码
  3927. // inputData["drug_genname"] = tm.Format("2006-01-02") // 医师编码
  3928. // inputData["chemname"] = tm.Format("2006-01-02") // 医师编码
  3929. //
  3930. // inputData["drugstdcode"] = tm.Format("2006-01-02") // 医师编码
  3931. // inputData["drug_dosform"] = tm.Format("2006-01-02") // 医师编码
  3932. //
  3933. //
  3934. // inputData["drug_spec"] = tm.Format("2006-01-02") // 医师编码
  3935. // inputData["prdr_name"] = tm.Format("2006-01-02") // 医师编码
  3936. //
  3937. //
  3938. // inputData["drug_pric"] = tm.Format("2006-01-02") // 医师编码
  3939. // inputData["drug_cnt"] = tm.Format("2006-01-02") // 医师编码
  3940. // inputData["drug_cnt_unit"] = tm.Format("2006-01-02") // 医师编码
  3941. // inputData["drug_sumamt"] = tm.Format("2006-01-02") // 医师编码
  3942. // inputData["medc_way_codg"] = tm.Format("2006-01-02") // 医师编码
  3943. // inputData["medc_way_dscr"] = tm.Format("2006-01-02") // 医师编码
  3944. // inputData["medc_starttime"] = tm.Format("2006-01-02") // 医师编码
  3945. //
  3946. // inputData["medc_endtime"] = tm.Format("2006-01-02") // 医师编码
  3947. //
  3948. //
  3949. // inputData["medc_days"] = tm.Format("2006-01-02") // 医师编码
  3950. // inputData["drug_dosunt"] = tm.Format("2006-01-02") // 医师编码
  3951. // inputData["sin_doscnt"] = tm.Format("2006-01-02") // 医师编码
  3952. // inputData["sin_dosunt"] = tm.Format("2006-01-02") // 医师编码
  3953. // inputData["used_frqu_codg"] = tm.Format("2006-01-02") // 医师编码
  3954. //
  3955. //
  3956. // inputData["used_frqu_name"] = tm.Format("2006-01-02") // 医师编码
  3957. // inputData["drug_totlnt"] = tm.Format("2006-01-02") // 医师编码
  3958. //
  3959. // inputData["drug_totlnt_emp"] = tm.Format("2006-01-02") // 医师编码
  3960. // inputData["dise_codg"] = tm.Format("2006-01-02") // 医师编码
  3961. // inputData["drug_res"] = tm.Format("2006-01-02") // 医师编码
  3962. // inputData["drug_limit"] = tm.Format("2006-01-02") // 医师编码
  3963. //
  3964. //
  3965. //
  3966. //
  3967. //
  3968. //
  3969. //
  3970. //
  3971. //
  3972. // input["rxdrugdetail"] = inputData2
  3973. //
  3974. //
  3975. //
  3976. //
  3977. // inputMessage["input"] = input //交易输入
  3978. // bytesData, err := json.Marshal(inputMessage)
  3979. // fmt.Println(string(bytesData))
  3980. // if err != nil {
  3981. // fmt.Println(err.Error())
  3982. // return err.Error()
  3983. // }
  3984. // reader := bytes.NewReader(bytesData)
  3985. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2503"
  3986. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2503"
  3987. // gdyb_url := beego.AppConfig.String("gdyb_url")
  3988. // gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3989. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  3990. // url := gdyb_url + "2503"
  3991. //
  3992. // request, err := http.NewRequest("POST", url, reader)
  3993. // if err != nil {
  3994. // fmt.Println(err.Error())
  3995. // return err.Error()
  3996. // }
  3997. //
  3998. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3999. // request.Header.Set("x-tif-paasid", gdyb_paasid)
  4000. // request.Header.Set("x-tif-signature", signature)
  4001. // request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4002. // request.Header.Set("x-tif-nonce", nonce)
  4003. //
  4004. // client := http.Client{}
  4005. // resp, err := client.Do(request)
  4006. // if err != nil {
  4007. // fmt.Println(err.Error())
  4008. // return err.Error()
  4009. // }
  4010. // respBytes, err := ioutil.ReadAll(resp.Body)
  4011. // if err != nil {
  4012. // fmt.Println(err.Error())
  4013. // return err.Error()
  4014. // }
  4015. // str := string(respBytes)
  4016. // fmt.Println(str)
  4017. // return str
  4018. //}
  4019. // 生成签名
  4020. func setSignature(timestamp int64, nonce string, secret_key string) string {
  4021. fmt.Println(timestamp)
  4022. fmt.Println(nonce)
  4023. fmt.Println(secret_key)
  4024. fmt.Println(strconv.FormatInt(timestamp, 10))
  4025. fmt.Println(time.Now().UnixNano() / 1e6)
  4026. str := strconv.FormatInt(timestamp, 10) + secret_key + nonce + strconv.FormatInt(timestamp, 10)
  4027. hash := sha256.New()
  4028. //输入数据
  4029. hash.Write([]byte(str))
  4030. //计算哈希值
  4031. bytes := hash.Sum(nil)
  4032. //将字符串编码为16进制格式,返回字符串
  4033. hashCode := hex.EncodeToString(bytes)
  4034. //返回哈希值
  4035. return hashCode
  4036. }
  4037. const charset = "abcdefghijklmnopqrstuvwxyz" +
  4038. "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
  4039. var seededRand *rand.Rand = rand.New(
  4040. rand.NewSource(time.Now().UnixNano()))
  4041. // 生成随机字符串
  4042. func GetRandomString(l int) string {
  4043. //str := "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
  4044. //bytes := []byte(str)
  4045. //result := []byte{}
  4046. //r := rand.New(rand.NewSource(time.Now().UnixNano()))
  4047. //for i := 0; i < l; i++ {
  4048. // result = append(result, bytes[r.Intn(len(bytes))])
  4049. //}
  4050. return String(32)
  4051. }
  4052. func StringWithCharset(length int, charset string) string {
  4053. b := make([]byte, length)
  4054. for i := range b {
  4055. b[i] = charset[seededRand.Intn(len(charset))]
  4056. }
  4057. return string(b)
  4058. }
  4059. func String(length int) string {
  4060. return StringWithCharset(length, charset)
  4061. }
  4062. // 生成基础报文
  4063. 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{} {
  4064. // 生成签名
  4065. tempTime := time.Unix(timestamp, 0)
  4066. //timeFormat := tempTime.Format("20060102150405")
  4067. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  4068. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  4069. month := time.Unix(1557042972, 0).Format("1")
  4070. year := time.Now().Format("2006")
  4071. month = time.Now().Format("01")
  4072. day := time.Now().Format("02")
  4073. hour := time.Now().Format("15")
  4074. min := time.Now().Format("04")
  4075. sec := time.Now().Format("05")
  4076. msec := time.Now().Format("000")
  4077. // 生成输入报文
  4078. inputMessage := make(map[string]interface{})
  4079. inputMessage["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  4080. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  4081. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  4082. inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  4083. inputMessage["dev_no"] = "" // 设备编号
  4084. inputMessage["dev_safe_info"] = "" // 设备安全信息
  4085. inputMessage["cainfo"] = "" // 数字签名信息
  4086. inputMessage["signtype"] = "MOCK" // 签名类型
  4087. inputMessage["infver"] = "V1.0" // 接收方系统代码
  4088. inputMessage["opter_type"] = "1" // 经办人类别
  4089. inputMessage["opter"] = doctor // 经办人
  4090. inputMessage["opter_name"] = op_name // 经办人姓名
  4091. inputMessage["inf_time"] = timeFormatOne // 交易时间
  4092. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  4093. inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  4094. if mdtrtarea_admvs == "440100" {
  4095. inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号
  4096. } else {
  4097. inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号 //交易签到流水号
  4098. }
  4099. return inputMessage
  4100. }
  4101. func SetInputMessage(nonce string, timestamp int64, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) map[string]interface{} {
  4102. // 生成签名
  4103. tempTime := time.Unix(timestamp, 0)
  4104. //timeFormat := tempTime.Format("20060102150405")
  4105. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  4106. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  4107. month := time.Unix(1557042972, 0).Format("1")
  4108. year := time.Now().Format("2006")
  4109. month = time.Now().Format("01")
  4110. day := time.Now().Format("02")
  4111. hour := time.Now().Format("15")
  4112. min := time.Now().Format("04")
  4113. sec := time.Now().Format("05")
  4114. msec := time.Now().Format("000")
  4115. // 生成输入报文
  4116. inputMessage := make(map[string]interface{})
  4117. inputMessage["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  4118. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  4119. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  4120. inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  4121. inputMessage["dev_no"] = "" // 设备编号
  4122. inputMessage["dev_safe_info"] = "" // 设备安全信息
  4123. inputMessage["cainfo"] = "" // 数字签名信息
  4124. inputMessage["signtype"] = "MOCK" // 签名类型
  4125. inputMessage["infver"] = "V1.0" // 接收方系统代码
  4126. inputMessage["opter_type"] = "1" // 经办人类别
  4127. inputMessage["opter"] = doctor // 经办人
  4128. inputMessage["opter_name"] = doctor // 经办人姓名
  4129. inputMessage["inf_time"] = timeFormatOne // 交易时间
  4130. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  4131. inputMessage["fixmedins_name"] = org_name
  4132. inputMessage["sign_no"] = "" //交易签到流水号
  4133. //定点医药机构名称
  4134. //if mdtrtarea_admvs == "440100" {
  4135. // inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号
  4136. //} else {
  4137. // inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号 //交易签到流水号
  4138. //}
  4139. return inputMessage
  4140. }
  4141. func SetInputMessagenosign(nonce string, timestamp int64, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) map[string]interface{} {
  4142. // 生成签名
  4143. tempTime := time.Unix(timestamp, 0)
  4144. //timeFormat := tempTime.Format("20060102150405")
  4145. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  4146. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  4147. month := time.Unix(1557042972, 0).Format("1")
  4148. year := time.Now().Format("2006")
  4149. month = time.Now().Format("01")
  4150. day := time.Now().Format("02")
  4151. hour := time.Now().Format("15")
  4152. min := time.Now().Format("04")
  4153. sec := time.Now().Format("05")
  4154. msec := time.Now().Format("000")
  4155. // 生成输入报文
  4156. inputMessage := make(map[string]interface{})
  4157. inputMessage["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  4158. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  4159. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  4160. inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  4161. inputMessage["dev_no"] = "" // 设备编号
  4162. inputMessage["dev_safe_info"] = "" // 设备安全信息
  4163. inputMessage["cainfo"] = "" // 数字签名信息
  4164. inputMessage["signtype"] = "MOCK" // 签名类型
  4165. inputMessage["infver"] = "V1.0" // 接收方系统代码
  4166. inputMessage["opter_type"] = "1" // 经办人类别
  4167. inputMessage["opter"] = doctor // 经办人
  4168. inputMessage["opter_name"] = doctor // 经办人姓名
  4169. inputMessage["inf_time"] = timeFormatOne // 交易时间
  4170. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  4171. inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  4172. if mdtrtarea_admvs == "440100" {
  4173. inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号
  4174. } else {
  4175. inputMessage["sign_no"] = ""
  4176. }
  4177. return inputMessage
  4178. }
  4179. //func GetSignInInfo(code string) string {
  4180. // var sign models.HisSignIn
  4181. // err = readDb.Model(&models.HisSignIn{}).Where("fixmedins_code = ? AND status = 1", code).Last(&sign).Error
  4182. // return sign.SignNo
  4183. //}
  4184. 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{} {
  4185. // 生成签名
  4186. tempTime := time.Unix(timestamp, 0)
  4187. //timeFormat := tempTime.Format("20060102150405")
  4188. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  4189. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  4190. // 生成输入报文
  4191. inputMessage := make(map[string]interface{})
  4192. inputMessage["msgid"] = msg_id // 发送方报文 ID
  4193. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  4194. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  4195. inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  4196. inputMessage["dev_no"] = "" // 设备编号
  4197. inputMessage["dev_safe_info"] = "" // 设备安全信息
  4198. inputMessage["cainfo"] = "" // 数字签名信息
  4199. inputMessage["signtype"] = "SM3" // 签名类型
  4200. inputMessage["infver"] = "V1.0" // 接收方系统代码
  4201. inputMessage["opter_type"] = "1" // 经办人类别
  4202. inputMessage["opter"] = doctor // 经办人
  4203. inputMessage["opter_name"] = doctor // 经办人姓名
  4204. inputMessage["inf_time"] = timeFormatOne // 交易时间
  4205. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  4206. inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  4207. if mdtrtarea_admvs == "440100" {
  4208. inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号
  4209. } else {
  4210. inputMessage["sign_no"] = "" //交易签到流水号
  4211. }
  4212. return inputMessage
  4213. }
  4214. 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{} {
  4215. // 生成签名
  4216. tempTime := time.Unix(timestamp, 0)
  4217. //timeFormat := tempTime.Format("20060102150405")
  4218. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  4219. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  4220. month := time.Unix(1557042972, 0).Format("1")
  4221. year := time.Now().Format("2006")
  4222. month = time.Now().Format("01")
  4223. day := time.Now().Format("02")
  4224. hour := time.Now().Format("15")
  4225. min := time.Now().Format("04")
  4226. sec := time.Now().Format("05")
  4227. msec := time.Now().Format("000")
  4228. // 生成输入报文
  4229. inputMessage := make(map[string]interface{})
  4230. inputMessage["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  4231. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  4232. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  4233. inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  4234. inputMessage["dev_no"] = "" // 设备编号
  4235. inputMessage["dev_safe_info"] = "" // 设备安全信息
  4236. inputMessage["cainfo"] = "" // 数字签名信息
  4237. inputMessage["signtype"] = "SM3" // 签名类型
  4238. inputMessage["infver"] = "V1.0" // 接收方系统代码
  4239. inputMessage["opter_type"] = "1" // 经办人类别
  4240. inputMessage["opter"] = doctor // 经办人
  4241. inputMessage["opter_name"] = doctor // 经办人姓名
  4242. inputMessage["inf_time"] = timeFormatOne // 交易时间
  4243. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  4244. inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  4245. if mdtrtarea_admvs == "440100" {
  4246. inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号
  4247. } else {
  4248. inputMessage["sign_no"] = sign_no //交易签到流水号
  4249. }
  4250. return inputMessage
  4251. }
  4252. func postFile(filename string, target_url string) (*http.Response, error) {
  4253. body_buf := bytes.NewBufferString("")
  4254. body_writer := multipart.NewWriter(body_buf)
  4255. // use the body_writer to write the Part headers to the buffer
  4256. _, err := body_writer.CreateFormFile("userfile", filename)
  4257. if err != nil {
  4258. fmt.Println("error writing to buffer")
  4259. return nil, err
  4260. }
  4261. // the file data will be the second part of the body
  4262. fh, err := os.Open(filename)
  4263. if err != nil {
  4264. fmt.Println("error opening file")
  4265. return nil, err
  4266. }
  4267. // need to know the boundary to properly close the part myself.
  4268. boundary := body_writer.Boundary()
  4269. //close_string := fmt.Sprintf("\r\n--%s--\r\n", boundary)
  4270. close_buf := bytes.NewBufferString(fmt.Sprintf("\r\n--%s--\r\n", boundary))
  4271. // use multi-reader to defer the reading of the file data until
  4272. // writing to the socket buffer.
  4273. request_reader := io.MultiReader(body_buf, fh, close_buf)
  4274. fi, err := fh.Stat()
  4275. if err != nil {
  4276. fmt.Printf("Error Stating file: %s", filename)
  4277. return nil, err
  4278. }
  4279. req, err := http.NewRequest("POST", target_url, request_reader)
  4280. if err != nil {
  4281. return nil, err
  4282. }
  4283. // Set headers for multipart, and Content Length
  4284. req.Header.Add("Content-Type", "multipart/form-data; boundary="+boundary)
  4285. req.ContentLength = fi.Size() + int64(body_buf.Len()) + int64(close_buf.Len())
  4286. return http.DefaultClient.Do(req)
  4287. }
  4288. //func Gdyb1201(psnNo string, org_name string, doctor string) string {
  4289. // // 生成签名
  4290. // nonce := GetRandomString(32)
  4291. // timestamp := time.Now().Unix()
  4292. // signature := setSignature(timestamp, nonce)
  4293. //
  4294. // // 生成输入报文
  4295. // inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, "")
  4296. // input := make(map[string]interface{})
  4297. // inputData := make(map[string]interface{})
  4298. // inputMessage["infno"] = "1201" // 交易编码
  4299. // inputData["fixmedins_type"] = psnNo // 人员编号 (来自1101接口返回)
  4300. // inputData["fixmedins_name"] = org_name // 人员编号 (来自1101接口返回)
  4301. // inputData["fixmedins_code"] = "" // 人员编号 (来自1101接口返回)
  4302. //
  4303. // input["medinsinfo"] = inputData
  4304. // inputMessage["input"] = input //交易输入
  4305. //
  4306. // bytesData, err := json.Marshal(inputMessage)
  4307. // fmt.Println(string(bytesData))
  4308. // if err != nil {
  4309. // fmt.Println(err.Error())
  4310. // return err.Error()
  4311. // }
  4312. // reader := bytes.NewReader(bytesData)
  4313. //
  4314. // url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1201"
  4315. // request, err := http.NewRequest("POST", url, reader)
  4316. // if err != nil {
  4317. // fmt.Println(err.Error())
  4318. // return err.Error()
  4319. // }
  4320. //
  4321. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4322. // request.Header.Set("x-tif-paasid", "test_hosp")
  4323. // request.Header.Set("x-tif-signature", signature)
  4324. // request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4325. // request.Header.Set("x-tif-nonce", nonce)
  4326. //
  4327. // client := http.Client{}
  4328. // resp, err := client.Do(request)
  4329. // if err != nil {
  4330. // fmt.Println(err.Error())
  4331. // return err.Error()
  4332. // }
  4333. // respBytes, err := ioutil.ReadAll(resp.Body)
  4334. // if err != nil {
  4335. // fmt.Println(err.Error())
  4336. // return err.Error()
  4337. // }
  4338. // str := string(respBytes)
  4339. // fmt.Println(str)
  4340. // return str
  4341. //}
  4342. func newfileUploadRequest(uri string, params map[string]string, paramName, path string) (*http.Request, error) {
  4343. file, err := os.Open(path)
  4344. if err != nil {
  4345. return nil, err
  4346. }
  4347. defer file.Close()
  4348. body := &bytes.Buffer{}
  4349. writer := multipart.NewWriter(body)
  4350. part, err := writer.CreateFormFile(paramName, filepath.Base(path))
  4351. if err != nil {
  4352. return nil, err
  4353. }
  4354. _, err = io.Copy(part, file)
  4355. for key, val := range params {
  4356. _ = writer.WriteField(key, val)
  4357. }
  4358. err = writer.Close()
  4359. if err != nil {
  4360. return nil, err
  4361. }
  4362. req, err := http.NewRequest("POST", uri, body)
  4363. req.Header.Set("Content-Type", writer.FormDataContentType())
  4364. return req, err
  4365. }
  4366. func CreateMedicalInsuranceCostCompareRecord(record *models.MedicalInsuranceCostCompare) error {
  4367. err := writeDb.Save(&record).Error
  4368. return err
  4369. }
  4370. //func Gdyb5203(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  4371. // // 生成签名
  4372. // nonce := GetRandomString(32)
  4373. // timestamp := time.Now().Unix()
  4374. // signature := setSignature(timestamp, nonce, secret_key)
  4375. //
  4376. // // 生成输入报文
  4377. // inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4378. // input := make(map[string]interface{})
  4379. // inputData := make(map[string]interface{})
  4380. // inputMessage["infno"] = "5203" // 交易编码
  4381. //
  4382. // inputData["fixmedins_type"] = "1"
  4383. // inputData["fixmedins_name"] = org_name
  4384. // inputData["fixmedins_code"] = fixmedins_code
  4385. // input["medinsinfo"] = inputData
  4386. // inputMessage["input"] = input //交易输入
  4387. //
  4388. // bytesData, err := json.Marshal(inputMessage)
  4389. // fmt.Println(string(bytesData))
  4390. // if err != nil {
  4391. // fmt.Println(err.Error())
  4392. // return err.Error()
  4393. // }
  4394. // reader := bytes.NewReader(bytesData)
  4395. // url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1201"
  4396. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1201"
  4397. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4398. // request, err := http.NewRequest("POST", url, reader)
  4399. // if err != nil {
  4400. // fmt.Println(err.Error())
  4401. // return err.Error()
  4402. // }
  4403. //
  4404. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4405. // request.Header.Set("x-tif-paasid", "sg03_prd")
  4406. // request.Header.Set("x-tif-signature", signature)
  4407. // request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4408. // request.Header.Set("x-tif-nonce", nonce)
  4409. //
  4410. // client := http.Client{}
  4411. // resp, err := client.Do(request)
  4412. // if err != nil {
  4413. // fmt.Println(err.Error())
  4414. // return err.Error()
  4415. // }
  4416. // respBytes, err := ioutil.ReadAll(resp.Body)
  4417. // if err != nil {
  4418. // fmt.Println(err.Error())
  4419. // return err.Error()
  4420. // }
  4421. // fmt.Println(string(respBytes))
  4422. // str := string(respBytes)
  4423. // return str
  4424. //}
  4425. func CreatePsnRecord(record *models.GdybPsnRecord) {
  4426. writeDb.Save(&record)
  4427. return
  4428. }
  4429. func GetPsnRecordById(id int64) (record models.GdybPsnRecord, err error) {
  4430. err = readDb.Model(&models.GdybPsnRecord{}).Where("id = ?").First(&record).Error
  4431. return
  4432. }
  4433. func CreatePsnNCDSRecord(record *models.GdybPsnNcdsRecord) {
  4434. writeDb.Save(&record)
  4435. return
  4436. }
  4437. func GetPsnNCDSRecordById(id int64) (record models.GdybPsnNcdsRecord, err error) {
  4438. err = readDb.Model(&models.GdybPsnNcdsRecord{}).Where("id = ?", id).First(&record).Error
  4439. return
  4440. }
  4441. func GetPatientsByIds(ids []string, current_org_id int64) (patients []*models.Patients, err error) {
  4442. err = readDb.Model(&models.Patients{}).Where("id IN (?) AND user_org_id = ?", ids, current_org_id).Find(&patients).Error
  4443. return
  4444. }
  4445. 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 {
  4446. // 生成签名
  4447. nonce := GetRandomString(32)
  4448. timestamp := time.Now().Unix()
  4449. signature := setSignature(timestamp, nonce, secret_key)
  4450. // 生成输入报文
  4451. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4452. input := make(map[string]interface{})
  4453. inputData := make(map[string]interface{})
  4454. inputMessage["infno"] = "2601" // 交易编码
  4455. inputData["psn_no"] = psnNo
  4456. inputData["omsgid"] = omsgid
  4457. inputData["oinfno"] = oinfno
  4458. input["data"] = inputData
  4459. inputMessage["input"] = input //交易输入
  4460. bytesData, err := json.Marshal(inputMessage)
  4461. fmt.Println(string(bytesData))
  4462. if err != nil {
  4463. fmt.Println(err.Error())
  4464. return err.Error()
  4465. }
  4466. reader := bytes.NewReader(bytesData)
  4467. gdyb_url := beego.AppConfig.String("gdyb_url")
  4468. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4469. url := gdyb_url + "2601"
  4470. request, err := http.NewRequest("POST", url, reader)
  4471. if err != nil {
  4472. fmt.Println(err.Error())
  4473. return err.Error()
  4474. }
  4475. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4476. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4477. request.Header.Set("x-tif-signature", signature)
  4478. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4479. request.Header.Set("x-tif-nonce", nonce)
  4480. client := http.Client{}
  4481. resp, err := client.Do(request)
  4482. if err != nil {
  4483. fmt.Println(err.Error())
  4484. return err.Error()
  4485. }
  4486. respBytes, err := ioutil.ReadAll(resp.Body)
  4487. if err != nil {
  4488. fmt.Println(err.Error())
  4489. return err.Error()
  4490. }
  4491. str := string(respBytes)
  4492. fmt.Println(str)
  4493. return str
  4494. }
  4495. // 人员信息版本3
  4496. 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 {
  4497. //生成签名
  4498. nonce := GetRandomString(32)
  4499. timestamp := time.Now().Unix()
  4500. signature := setSignature(timestamp, nonce, secret_key)
  4501. //生成输入报文
  4502. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4503. inputMessage := make(map[string]interface{})
  4504. //生成输入报文
  4505. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127"{
  4506. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs,doctor)
  4507. } else {
  4508. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4509. }
  4510. input := make(map[string]interface{})
  4511. inputData := make(map[string]interface{})
  4512. inputMessage["infno"] = "1101" // 交易编码
  4513. if certificates == 3 {
  4514. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  4515. inputData["certno"] = "01836483" // 证件号码
  4516. inputData["psn_cert_type"] = "01" // 人员证件类型
  4517. inputData["mdtrt_cert_no"] = "01836483" // 就诊凭证编号
  4518. } else {
  4519. if certificates == 1 {
  4520. if id_card_type == 1 {
  4521. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  4522. inputData["card_sn"] = card_sn // 卡识别码
  4523. inputData["certno"] = certNo // 证件号码
  4524. inputData["psn_cert_type"] = "01" // 人员证件类型
  4525. inputData["mdtrt_cert_no"] = cardNumber // 就诊凭证编号
  4526. } else {
  4527. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  4528. inputData["card_sn"] = "" // 卡识别码
  4529. inputData["certno"] = certNo // 证件号码
  4530. inputData["psn_cert_type"] = "01" // 人员证件类型
  4531. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  4532. }
  4533. } else if certificates == 6 {
  4534. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  4535. inputData["card_sn"] = "" // 卡识别码
  4536. inputData["certno"] = certNo // 证件号码
  4537. inputData["psn_cert_type"] = "17" // 人员证件类型
  4538. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  4539. }
  4540. }
  4541. inputData["begntime"] = "" // 开始时间
  4542. inputData["psn_name"] = name // 人员姓名
  4543. input["data"] = inputData
  4544. inputMessage["input"] = input //交易输入
  4545. bytesData, err := json.Marshal(inputMessage)
  4546. fmt.Println(string(bytesData))
  4547. if err != nil {
  4548. fmt.Println(err.Error())
  4549. return err.Error()
  4550. }
  4551. reader := bytes.NewReader(bytesData)
  4552. gdyb_url := beego.AppConfig.String("gdyb_url")
  4553. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4554. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4555. //url := gdyb_url + "1101"
  4556. var url string
  4557. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  4558. url = gdyb_url
  4559. } else {
  4560. url = gdyb_url + "1101"
  4561. }
  4562. fmt.Println(url)
  4563. fmt.Println(gdyb_paasid)
  4564. fmt.Println(secret_key)
  4565. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4566. request, err := http.NewRequest("POST", url, reader)
  4567. if err != nil {
  4568. fmt.Println(err.Error())
  4569. return err.Error()
  4570. }
  4571. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4572. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4573. request.Header.Set("x-tif-signature", signature)
  4574. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4575. request.Header.Set("x-tif-nonce", nonce)
  4576. client := http.Client{}
  4577. resp, err := client.Do(request)
  4578. if err != nil {
  4579. fmt.Println(err.Error())
  4580. return err.Error()
  4581. }
  4582. respBytes, err := ioutil.ReadAll(resp.Body)
  4583. if err != nil {
  4584. fmt.Println(err.Error())
  4585. return err.Error()
  4586. }
  4587. fmt.Println(string(respBytes))
  4588. str := string(respBytes)
  4589. return str
  4590. }
  4591. 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 {
  4592. //生成签名
  4593. nonce := GetRandomString(32)
  4594. timestamp := time.Now().Unix()
  4595. signature := setSignature(timestamp, nonce, secret_key)
  4596. inputMessage := make(map[string]interface{})
  4597. //生成输入报文
  4598. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127"{
  4599. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs,doctor)
  4600. } else {
  4601. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4602. }
  4603. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4604. input := make(map[string]interface{})
  4605. inputData := make(map[string]interface{})
  4606. inputMessage["infno"] = "1101" // 交易编码
  4607. if certificates == 3 {
  4608. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  4609. inputData["certno"] = "01836483" // 证件号码
  4610. inputData["psn_cert_type"] = "01" // 人员证件类型
  4611. inputData["mdtrt_cert_no"] = "01836483" // 就诊凭证编号
  4612. } else {
  4613. if certificates == 1 {
  4614. if id_card_type == 4 {
  4615. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  4616. inputData["card_sn"] = card_sn // 卡识别码
  4617. inputData["certno"] = certNo // 证件号码
  4618. inputData["psn_cert_type"] = "01" // 人员证件类型
  4619. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  4620. }
  4621. } else if certificates == 6 {
  4622. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  4623. inputData["card_sn"] = "" // 卡识别码
  4624. inputData["certno"] = certNo // 证件号码
  4625. inputData["psn_cert_type"] = "17" // 人员证件类型
  4626. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  4627. }
  4628. }
  4629. inputData["begntime"] = "" // 开始时间
  4630. inputData["psn_name"] = name // 人员姓名
  4631. input["data"] = inputData
  4632. inputMessage["input"] = input //交易输入
  4633. bytesData, err := json.Marshal(inputMessage)
  4634. fmt.Println(string(bytesData))
  4635. if err != nil {
  4636. fmt.Println(err.Error())
  4637. return err.Error()
  4638. }
  4639. reader := bytes.NewReader(bytesData)
  4640. gdyb_url := beego.AppConfig.String("gdyb_url")
  4641. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4642. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4643. //url := gdyb_url + "1101"
  4644. var url string
  4645. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  4646. url = gdyb_url
  4647. } else {
  4648. url = gdyb_url + "1101"
  4649. }
  4650. fmt.Println(url)
  4651. fmt.Println(gdyb_paasid)
  4652. fmt.Println(secret_key)
  4653. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4654. request, err := http.NewRequest("POST", url, reader)
  4655. if err != nil {
  4656. fmt.Println(err.Error())
  4657. return err.Error()
  4658. }
  4659. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4660. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4661. request.Header.Set("x-tif-signature", signature)
  4662. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4663. request.Header.Set("x-tif-nonce", nonce)
  4664. client := http.Client{}
  4665. resp, err := client.Do(request)
  4666. if err != nil {
  4667. fmt.Println(err.Error())
  4668. return err.Error()
  4669. }
  4670. respBytes, err := ioutil.ReadAll(resp.Body)
  4671. if err != nil {
  4672. fmt.Println(err.Error())
  4673. return err.Error()
  4674. }
  4675. fmt.Println(string(respBytes))
  4676. str := string(respBytes)
  4677. return str
  4678. }
  4679. 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 {
  4680. //生成签名
  4681. nonce := GetRandomString(32)
  4682. timestamp := time.Now().Unix()
  4683. signature := setSignature(timestamp, nonce, secret_key)
  4684. //生成输入报文
  4685. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4686. input := make(map[string]interface{})
  4687. inputData := make(map[string]interface{})
  4688. inputMessage["infno"] = "1101" // 交易编码
  4689. if certificates == 3 {
  4690. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  4691. inputData["certno"] = "01836483" // 证件号码
  4692. inputData["psn_cert_type"] = "01" // 人员证件类型
  4693. inputData["mdtrt_cert_no"] = "01836483" // 就诊凭证编号
  4694. } else {
  4695. if certificates == 1 {
  4696. if id_card_type == 1 {
  4697. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  4698. inputData["card_sn"] = "" // 卡识别码
  4699. inputData["certno"] = certNo // 证件号码
  4700. inputData["psn_cert_type"] = "01" // 人员证件类型
  4701. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  4702. } else {
  4703. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  4704. inputData["card_sn"] = "" // 卡识别码
  4705. inputData["certno"] = certNo // 证件号码
  4706. inputData["psn_cert_type"] = "" // 人员证件类型
  4707. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  4708. }
  4709. } else if certificates == 6 {
  4710. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  4711. inputData["card_sn"] = "" // 卡识别码
  4712. inputData["certno"] = certNo // 证件号码
  4713. inputData["psn_cert_type"] = "" // 人员证件类型
  4714. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  4715. }
  4716. }
  4717. inputData["begntime"] = "" // 开始时间
  4718. inputData["psn_name"] = "" // 人员姓名
  4719. input["data"] = inputData
  4720. inputMessage["input"] = input //交易输入
  4721. bytesData, err := json.Marshal(inputMessage)
  4722. fmt.Println(string(bytesData))
  4723. if err != nil {
  4724. fmt.Println(err.Error())
  4725. return err.Error()
  4726. }
  4727. reader := bytes.NewReader(bytesData)
  4728. gdyb_url := beego.AppConfig.String("gdyb_url")
  4729. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4730. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4731. //url := gdyb_url + "1101"
  4732. var url string
  4733. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  4734. url = gdyb_url
  4735. }else {
  4736. url = gdyb_url + "1101"
  4737. }
  4738. fmt.Println(url)
  4739. fmt.Println(gdyb_paasid)
  4740. fmt.Println(secret_key)
  4741. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4742. request, err := http.NewRequest("POST", url, reader)
  4743. if err != nil {
  4744. fmt.Println(err.Error())
  4745. return err.Error()
  4746. }
  4747. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4748. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4749. request.Header.Set("x-tif-signature", signature)
  4750. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4751. request.Header.Set("x-tif-nonce", nonce)
  4752. client := http.Client{}
  4753. resp, err := client.Do(request)
  4754. if err != nil {
  4755. fmt.Println(err.Error())
  4756. return err.Error()
  4757. }
  4758. respBytes, err := ioutil.ReadAll(resp.Body)
  4759. if err != nil {
  4760. fmt.Println(err.Error())
  4761. return err.Error()
  4762. }
  4763. fmt.Println(string(respBytes))
  4764. str := string(respBytes)
  4765. return str
  4766. }
  4767. 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 {
  4768. //生成签名
  4769. nonce := GetRandomString(32)
  4770. timestamp := time.Now().Unix()
  4771. signature := setSignature(timestamp, nonce, secret_key)
  4772. //生成输入报文
  4773. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4774. input := make(map[string]interface{})
  4775. inputData := make(map[string]interface{})
  4776. inputMessage["infno"] = "1101" // 交易编码
  4777. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  4778. inputData["card_sn"] = card_sn // 卡识别码
  4779. inputData["certno"] = certNo // 证件号码
  4780. inputData["psn_cert_type"] = "01" // 人员证件类型
  4781. inputData["mdtrt_cert_no"] = cardNumber // 就诊凭证编号
  4782. inputData["begntime"] = "" // 开始时间
  4783. inputData["psn_name"] = name // 人员姓名
  4784. input["data"] = inputData
  4785. inputMessage["input"] = input //交易输入
  4786. bytesData, err := json.Marshal(inputMessage)
  4787. fmt.Println(string(bytesData))
  4788. if err != nil {
  4789. fmt.Println(err.Error())
  4790. return err.Error()
  4791. }
  4792. reader := bytes.NewReader(bytesData)
  4793. gdyb_url := beego.AppConfig.String("gdyb_url")
  4794. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4795. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4796. //url := gdyb_url + "1101"
  4797. var url string
  4798. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  4799. url = gdyb_url
  4800. }else {
  4801. url = gdyb_url + "1101"
  4802. }
  4803. fmt.Println(url)
  4804. fmt.Println(gdyb_paasid)
  4805. fmt.Println(secret_key)
  4806. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4807. request, err := http.NewRequest("POST", url, reader)
  4808. if err != nil {
  4809. fmt.Println(err.Error())
  4810. return err.Error()
  4811. }
  4812. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4813. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4814. request.Header.Set("x-tif-signature", signature)
  4815. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4816. request.Header.Set("x-tif-nonce", nonce)
  4817. client := http.Client{}
  4818. resp, err := client.Do(request)
  4819. if err != nil {
  4820. fmt.Println(err.Error())
  4821. return err.Error()
  4822. }
  4823. respBytes, err := ioutil.ReadAll(resp.Body)
  4824. if err != nil {
  4825. fmt.Println(err.Error())
  4826. return err.Error()
  4827. }
  4828. fmt.Println(string(respBytes))
  4829. str := string(respBytes)
  4830. return str
  4831. }
  4832. 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) {
  4833. //生成签名
  4834. nonce := GetRandomString(32)
  4835. timestamp := time.Now().Unix()
  4836. signature := setSignature(timestamp, nonce, secret_key)
  4837. //生成输入报文
  4838. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4839. input := make(map[string]interface{})
  4840. inputData := make(map[string]interface{})
  4841. inputMessage["infno"] = "1101" // 交易编码
  4842. if certificates == 6 {
  4843. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  4844. inputData["psn_cert_type"] = "" // 人员证件类型
  4845. }else{
  4846. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  4847. inputData["psn_cert_type"] = "01" // 人员证件类型
  4848. }
  4849. inputData["card_sn"] = "" // 卡识别码
  4850. inputData["certno"] = idNo // 证件号码
  4851. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  4852. inputData["begntime"] = "" // 开始时间
  4853. inputData["psn_name"] = user_name // 人员姓名
  4854. input["data"] = inputData
  4855. inputMessage["input"] = input //交易输入
  4856. bytesData, err := json.Marshal(inputMessage)
  4857. fmt.Println(string(bytesData))
  4858. if err != nil {
  4859. fmt.Println(err.Error())
  4860. return err.Error(), ""
  4861. }
  4862. reader := bytes.NewReader(bytesData)
  4863. gdyb_url := beego.AppConfig.String("gdyb_url")
  4864. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4865. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4866. //url := gdyb_url + "1101"
  4867. var url string
  4868. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  4869. url = gdyb_url
  4870. } else {
  4871. url = gdyb_url + "1101"
  4872. }
  4873. fmt.Println(url)
  4874. fmt.Println(gdyb_paasid)
  4875. fmt.Println(secret_key)
  4876. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4877. request, err := http.NewRequest("POST", url, reader)
  4878. if err != nil {
  4879. fmt.Println(err.Error())
  4880. return err.Error(), ""
  4881. }
  4882. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4883. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4884. request.Header.Set("x-tif-signature", signature)
  4885. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4886. request.Header.Set("x-tif-nonce", nonce)
  4887. client := http.Client{}
  4888. resp, err := client.Do(request)
  4889. if err != nil {
  4890. fmt.Println(err.Error())
  4891. return err.Error(), ""
  4892. }
  4893. respBytes, err := ioutil.ReadAll(resp.Body)
  4894. if err != nil {
  4895. fmt.Println(err.Error())
  4896. return err.Error(), ""
  4897. }
  4898. fmt.Println(string(respBytes))
  4899. str := string(respBytes)
  4900. return str, string(bytesData)
  4901. }
  4902. 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) {
  4903. //生成签名
  4904. nonce := GetRandomString(32)
  4905. timestamp := time.Now().Unix()
  4906. signature := setSignature(timestamp, nonce, secret_key)
  4907. //生成输入报文
  4908. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4909. input := make(map[string]interface{})
  4910. inputData := make(map[string]interface{})
  4911. inputMessage["infno"] = "1101" // 交易编码
  4912. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  4913. inputData["psn_cert_type"] = "01" // 人员证件类型
  4914. inputData["card_sn"] = "" // 卡识别码
  4915. inputData["certno"] = idNo // 证件号码
  4916. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  4917. inputData["begntime"] = "" // 开始时间
  4918. inputData["psn_name"] = user_name // 人员姓名
  4919. input["data"] = inputData
  4920. inputMessage["input"] = input //交易输入
  4921. bytesData, err := json.Marshal(inputMessage)
  4922. fmt.Println(string(bytesData))
  4923. if err != nil {
  4924. fmt.Println(err.Error())
  4925. return err.Error(), ""
  4926. }
  4927. reader := bytes.NewReader(bytesData)
  4928. gdyb_url := beego.AppConfig.String("gdyb_url")
  4929. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4930. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4931. //url := gdyb_url + "1101"
  4932. var url string
  4933. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  4934. url = gdyb_url
  4935. } else {
  4936. url = gdyb_url + "1101"
  4937. }
  4938. fmt.Println(url)
  4939. fmt.Println(gdyb_paasid)
  4940. fmt.Println(secret_key)
  4941. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4942. request, err := http.NewRequest("POST", url, reader)
  4943. if err != nil {
  4944. fmt.Println(err.Error())
  4945. return err.Error(), ""
  4946. }
  4947. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4948. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4949. request.Header.Set("x-tif-signature", signature)
  4950. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4951. request.Header.Set("x-tif-nonce", nonce)
  4952. client := http.Client{}
  4953. resp, err := client.Do(request)
  4954. if err != nil {
  4955. fmt.Println(err.Error())
  4956. return err.Error(), ""
  4957. }
  4958. respBytes, err := ioutil.ReadAll(resp.Body)
  4959. if err != nil {
  4960. fmt.Println(err.Error())
  4961. return err.Error(), ""
  4962. }
  4963. fmt.Println(string(respBytes))
  4964. str := string(respBytes)
  4965. return str, string(bytesData)
  4966. }
  4967. 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) {
  4968. //生成签名
  4969. nonce := GetRandomString(32)
  4970. timestamp := time.Now().Unix()
  4971. signature := setSignature(timestamp, nonce, secret_key)
  4972. //生成输入报文
  4973. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4974. input := make(map[string]interface{})
  4975. inputData := make(map[string]interface{})
  4976. inputMessage["infno"] = "1101" // 交易编码
  4977. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  4978. inputData["card_sn"] = "" // 卡识别码
  4979. inputData["certno"] = idNo // 证件号码
  4980. inputData["psn_cert_type"] = "01" // 人员证件类型
  4981. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  4982. inputData["begntime"] = "" // 开始时间
  4983. inputData["psn_name"] = user_name // 人员姓名
  4984. input["data"] = inputData
  4985. inputMessage["input"] = input //交易输入
  4986. bytesData, err := json.Marshal(inputMessage)
  4987. fmt.Println(string(bytesData))
  4988. if err != nil {
  4989. fmt.Println(err.Error())
  4990. return err.Error(), ""
  4991. }
  4992. reader := bytes.NewReader(bytesData)
  4993. gdyb_url := beego.AppConfig.String("gdyb_url")
  4994. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4995. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4996. //url := gdyb_url + "1101"
  4997. var url string
  4998. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  4999. url = gdyb_url
  5000. } else {
  5001. url = gdyb_url + "1101"
  5002. }
  5003. fmt.Println(url)
  5004. fmt.Println(gdyb_paasid)
  5005. fmt.Println(secret_key)
  5006. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  5007. request, err := http.NewRequest("POST", url, reader)
  5008. if err != nil {
  5009. fmt.Println(err.Error())
  5010. return err.Error(), ""
  5011. }
  5012. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5013. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5014. request.Header.Set("x-tif-signature", signature)
  5015. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5016. request.Header.Set("x-tif-nonce", nonce)
  5017. client := http.Client{}
  5018. resp, err := client.Do(request)
  5019. if err != nil {
  5020. fmt.Println(err.Error())
  5021. return err.Error(), ""
  5022. }
  5023. respBytes, err := ioutil.ReadAll(resp.Body)
  5024. if err != nil {
  5025. fmt.Println(err.Error())
  5026. return err.Error(), ""
  5027. }
  5028. fmt.Println(string(respBytes))
  5029. str := string(respBytes)
  5030. return str, string(bytesData)
  5031. }
  5032. func Gdyb6101(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) (string, string) {
  5033. //生成签名
  5034. nonce := GetRandomString(32)
  5035. timestamp := time.Now().Unix()
  5036. signature := setSignature(timestamp, nonce, secret_key)
  5037. //生成输入报文
  5038. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  5039. input := make(map[string]interface{})
  5040. inputData := make(map[string]interface{})
  5041. inputMessage["infno"] = "6101" // 交易编码
  5042. inputData["orgId"] = fixmedins_code // 就诊凭证类型
  5043. inputData["businessType"] = "01101" // 卡识别码
  5044. inputData["businessInfo"] = "" // 证件号码
  5045. inputData["operateorId"] = "01" // 人员证件类型
  5046. inputData["operateornName"] = doctor // 就诊凭证编号
  5047. inputData["officeId"] = "01" // 开始时间
  5048. inputData["officeName"] = "血透" // 人员姓名
  5049. inputData["deviceType"] = "" // 人员姓名
  5050. input["InData"] = inputData
  5051. inputMessage["input"] = input //交易输入
  5052. bytesData, err := json.Marshal(inputMessage)
  5053. fmt.Println(string(bytesData))
  5054. if err != nil {
  5055. fmt.Println(err.Error())
  5056. return err.Error(), ""
  5057. }
  5058. reader := bytes.NewReader(bytesData)
  5059. gdyb_url := beego.AppConfig.String("gdyb_url")
  5060. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5061. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  5062. //url := gdyb_url + "1101"
  5063. var url string
  5064. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450127" {
  5065. url = gdyb_url
  5066. } else {
  5067. url = gdyb_url + "1101"
  5068. }
  5069. fmt.Println(url)
  5070. fmt.Println(gdyb_paasid)
  5071. fmt.Println(secret_key)
  5072. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  5073. request, err := http.NewRequest("POST", url, reader)
  5074. if err != nil {
  5075. fmt.Println(err.Error())
  5076. return err.Error(), ""
  5077. }
  5078. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5079. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5080. request.Header.Set("x-tif-signature", signature)
  5081. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5082. request.Header.Set("x-tif-nonce", nonce)
  5083. client := http.Client{}
  5084. resp, err := client.Do(request)
  5085. if err != nil {
  5086. fmt.Println(err.Error())
  5087. return err.Error(), ""
  5088. }
  5089. respBytes, err := ioutil.ReadAll(resp.Body)
  5090. if err != nil {
  5091. fmt.Println(err.Error())
  5092. return err.Error(), ""
  5093. }
  5094. fmt.Println(string(respBytes))
  5095. str := string(respBytes)
  5096. return str, string(bytesData)
  5097. }
  5098. // 人员信息版本4
  5099. 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) {
  5100. //生成签名
  5101. nonce := GetRandomString(32)
  5102. timestamp := time.Now().Unix()
  5103. //signature := setSignature(timestamp, nonce, secret_key)
  5104. //生成输入报文
  5105. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  5106. input := make(map[string]interface{})
  5107. inputData := make(map[string]interface{})
  5108. inputMessage["infno"] = "1101" // 交易编码
  5109. if certificates == 3 {
  5110. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  5111. inputData["certno"] = certNo // 证件号码
  5112. inputData["psn_cert_type"] = "99" // 人员证件类型
  5113. } else {
  5114. if id_card_type == 1 {
  5115. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  5116. inputData["card_sn"] = "" // 卡识别码
  5117. inputData["certno"] = "" // 证件号码
  5118. inputData["psn_cert_type"] = "" // 人员证件类型
  5119. } else {
  5120. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  5121. inputData["card_sn"] = "" // 卡识别码
  5122. inputData["certno"] = certNo // 证件号码
  5123. inputData["psn_cert_type"] = "1" // 人员证件类型
  5124. }
  5125. }
  5126. inputData["mdtrt_cert_no"] = "" // 就诊凭证编号
  5127. inputData["begntime"] = "" // 开始时间
  5128. inputData["psn_name"] = "" // 人员姓名
  5129. input["data"] = inputData
  5130. inputMessage["input"] = input //交易输入
  5131. bytesData, err := json.Marshal(inputMessage)
  5132. fmt.Println(string(bytesData))
  5133. if err != nil {
  5134. fmt.Println(err.Error())
  5135. return err.Error(), ""
  5136. }
  5137. var json2 string
  5138. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  5139. out, err := cmd.Output()
  5140. if err != nil {
  5141. fmt.Println("error:", err.Error())
  5142. }
  5143. fmt.Println(string(out))
  5144. return string(out), string(bytesData)
  5145. }
  5146. func StrPtr(s string) uintptr {
  5147. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  5148. }
  5149. 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 {
  5150. //生成签名
  5151. nonce := GetRandomString(32)
  5152. timestamp := time.Now().Unix()
  5153. signature := setSignature(timestamp, nonce, secret_key)
  5154. //生成输入报文
  5155. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  5156. input := make(map[string]interface{})
  5157. inputData := make(map[string]interface{})
  5158. inputMessage["infno"] = "90991" // 交易编码
  5159. inputData["fixmedins_code"] = fixmedins_code // 就诊凭证编号
  5160. inputData["psn_no"] = psn_no // 开始时间
  5161. inputData["card_pwd"] = pwd // 人员姓名
  5162. inputData["sscno"] = card_number // 人员姓名
  5163. input["data"] = inputData
  5164. inputMessage["input"] = input //交易输入
  5165. bytesData, err := json.Marshal(inputMessage)
  5166. fmt.Println(string(bytesData))
  5167. if err != nil {
  5168. fmt.Println(err.Error())
  5169. return err.Error()
  5170. }
  5171. reader := bytes.NewReader(bytesData)
  5172. gdyb_url := beego.AppConfig.String("gdyb_url")
  5173. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5174. url := gdyb_url + "90991"
  5175. request, err := http.NewRequest("POST", url, reader)
  5176. if err != nil {
  5177. fmt.Println(err.Error())
  5178. return err.Error()
  5179. }
  5180. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5181. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5182. request.Header.Set("x-tif-signature", signature)
  5183. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5184. request.Header.Set("x-tif-nonce", nonce)
  5185. client := http.Client{}
  5186. resp, err := client.Do(request)
  5187. if err != nil {
  5188. fmt.Println(err.Error())
  5189. return err.Error()
  5190. }
  5191. respBytes, err := ioutil.ReadAll(resp.Body)
  5192. if err != nil {
  5193. fmt.Println(err.Error())
  5194. return err.Error()
  5195. }
  5196. fmt.Println(string(respBytes))
  5197. str := string(respBytes)
  5198. return str
  5199. }
  5200. func Gdyb90100(psn_no string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  5201. //生成签名
  5202. nonce := GetRandomString(32)
  5203. timestamp := time.Now().Unix()
  5204. signature := setSignature(timestamp, nonce, secret_key)
  5205. //生成输入报文
  5206. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  5207. input := make(map[string]interface{})
  5208. inputData := make(map[string]interface{})
  5209. inputMessage["infno"] = "90100" // 交易编码
  5210. inputData["psn_no"] = psn_no // 开始时间
  5211. input["data"] = inputData
  5212. inputMessage["input"] = input //交易输入
  5213. bytesData, err := json.Marshal(inputMessage)
  5214. fmt.Println(string(bytesData))
  5215. if err != nil {
  5216. fmt.Println(err.Error())
  5217. return err.Error()
  5218. }
  5219. reader := bytes.NewReader(bytesData)
  5220. gdyb_url := beego.AppConfig.String("gdyb_url")
  5221. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5222. url := gdyb_url + "90100"
  5223. request, err := http.NewRequest("POST", url, reader)
  5224. if err != nil {
  5225. fmt.Println(err.Error())
  5226. return err.Error()
  5227. }
  5228. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5229. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5230. request.Header.Set("x-tif-signature", signature)
  5231. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5232. request.Header.Set("x-tif-nonce", nonce)
  5233. client := http.Client{}
  5234. resp, err := client.Do(request)
  5235. if err != nil {
  5236. fmt.Println(err.Error())
  5237. return err.Error()
  5238. }
  5239. respBytes, err := ioutil.ReadAll(resp.Body)
  5240. if err != nil {
  5241. fmt.Println(err.Error())
  5242. return err.Error()
  5243. }
  5244. fmt.Println(string(respBytes))
  5245. str := string(respBytes)
  5246. return str
  5247. }
  5248. 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) {
  5249. //生成签名
  5250. nonce := GetRandomString(32)
  5251. timestamp := time.Now().Unix()
  5252. signature := setSignature(timestamp, nonce, secret_key)
  5253. //生成输入报文
  5254. inputMessage := SetInputMessageTwo(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, sign)
  5255. input := make(map[string]interface{})
  5256. inputData := make(map[string]interface{})
  5257. inputMessage["infno"] = "3260" // 交易编码
  5258. inputData["sign"] = sign // 就诊凭证编号
  5259. inputData["trt_year"] = year // 就诊凭证编号
  5260. inputData["trt_month"] = month // 开始时间
  5261. inputData["startrow"] = count // 人员姓名
  5262. input["data"] = inputData
  5263. inputMessage["input"] = input //交易输入
  5264. var inputLog string
  5265. bytesData, err := json.Marshal(inputMessage)
  5266. inputLog = string(bytesData)
  5267. fmt.Println(string(bytesData))
  5268. if err != nil {
  5269. fmt.Println(err.Error())
  5270. return err.Error(), ""
  5271. }
  5272. reader := bytes.NewReader(bytesData)
  5273. gdyb_url := beego.AppConfig.String("gdyb_url")
  5274. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5275. var url string
  5276. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5277. url = gdyb_url
  5278. } else {
  5279. url = gdyb_url + "3260"
  5280. }
  5281. if insuplc_admdvs == "421300" {
  5282. var json2 string
  5283. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  5284. out, err := cmd.Output()
  5285. if err != nil {
  5286. fmt.Println("error:", err.Error())
  5287. }
  5288. fmt.Println(string(out))
  5289. return hex.EncodeToString(out), inputLog
  5290. } else {
  5291. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  5292. request, err := http.NewRequest("POST", url, reader)
  5293. if err != nil {
  5294. fmt.Println(err.Error())
  5295. return err.Error(), ""
  5296. }
  5297. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5298. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5299. request.Header.Set("x-tif-signature", signature)
  5300. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5301. request.Header.Set("x-tif-nonce", nonce)
  5302. client := http.Client{}
  5303. resp, err := client.Do(request)
  5304. if err != nil {
  5305. fmt.Println(err.Error())
  5306. return err.Error(), ""
  5307. }
  5308. respBytes, err := ioutil.ReadAll(resp.Body)
  5309. if err != nil {
  5310. fmt.Println(err.Error())
  5311. return err.Error(), ""
  5312. }
  5313. fmt.Println(string(respBytes))
  5314. str := string(respBytes)
  5315. return str, inputLog
  5316. }
  5317. }
  5318. 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) {
  5319. //msg_month := time.Unix(1557042972, 0).Format("1")
  5320. //msg_year := time.Now().Format("2006")
  5321. //msg_month = time.Now().Format("01")
  5322. //day := time.Now().Format("02")
  5323. //
  5324. //hour := time.Now().Format("15")
  5325. //min := time.Now().Format("04")
  5326. //sec := time.Now().Format("05")
  5327. //
  5328. //msec := time.Now().Format("000")
  5329. //msg_id := fixmedins_code + msg_year + msg_month + day + hour + min + sec + msec + "0"
  5330. feedetail := make([]map[string]interface{}, 0)
  5331. for _, subitem := range result3260 {
  5332. for _, item := range subitem.Output.Data {
  5333. if item.MdtrtId != "out20230406681871" && item.MdtrtId != "out20230406681868" && item.MdtrtId != "out202404174009254" && item.MdtrtId != "out202405154379275" {
  5334. feedetailInfo := make(map[string]interface{})
  5335. feedetailInfo["certno"] = item.Certno
  5336. feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5337. feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5338. feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5339. feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5340. feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5341. feedetailInfo["cnfm_flag"] = "1" // 处方号
  5342. feedetail = append(feedetail, feedetailInfo)
  5343. }
  5344. }
  5345. }
  5346. for _, subitem := range result3260 {
  5347. for _, item := range subitem.Output.Data {
  5348. if item.MdtrtId == "out20230406681871" {
  5349. feedetailInfo := make(map[string]interface{})
  5350. feedetailInfo["certno"] = item.Certno
  5351. feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5352. feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5353. feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5354. feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5355. feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5356. feedetailInfo["cnfm_flag"] = "0" // 处方号
  5357. feedetail = append(feedetail, feedetailInfo)
  5358. }
  5359. }
  5360. }
  5361. for _, subitem := range result3260 {
  5362. for _, item := range subitem.Output.Data {
  5363. if item.MdtrtId == "out20230406681868" {
  5364. feedetailInfo := make(map[string]interface{})
  5365. feedetailInfo["certno"] = item.Certno
  5366. feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5367. feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5368. feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5369. feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5370. feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5371. feedetailInfo["cnfm_flag"] = "0" // 处方号
  5372. feedetail = append(feedetail, feedetailInfo)
  5373. }
  5374. }
  5375. }
  5376. // 分页操作
  5377. pageSize := 100
  5378. pages := paginate(feedetail, pageSize)
  5379. //aa := 0
  5380. // 输出每一页的数据
  5381. for _, page := range pages {
  5382. nonce := GetRandomString(32)
  5383. timestamp := time.Now().Unix()
  5384. signature := setSignature(timestamp, nonce, secret_key)
  5385. //生成输入报文
  5386. //aa = aa + len(page)
  5387. //nonce := GetRandomString(32)
  5388. //timestamp := time.Now().Unix()
  5389. inputMessage := SetInputMessageTwo(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, sign_no)
  5390. input := make(map[string]interface{})
  5391. inputData := make(map[string]interface{})
  5392. inputMessage["infno"] = "3261" // 交易编码
  5393. inputData["trt_year"] = year // 就诊凭证编号
  5394. inputData["trt_month"] = month // 开始时间
  5395. inputData["totalrow"] =len(feedetail)// 人员姓名
  5396. input["data"] = inputData
  5397. input["detail"] = page
  5398. inputMessage["input"] = input //交易输入
  5399. //var inputLog string
  5400. bytesData, err := json.Marshal(inputMessage)
  5401. //inputLog = string(bytesData)
  5402. fmt.Println(string(bytesData))
  5403. if err != nil {
  5404. fmt.Println(err.Error())
  5405. return
  5406. }
  5407. reader := bytes.NewReader(bytesData)
  5408. gdyb_url := beego.AppConfig.String("gdyb_url")
  5409. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5410. var url string
  5411. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5412. url = gdyb_url
  5413. } else {
  5414. url = gdyb_url + "3261"
  5415. }
  5416. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  5417. request, err := http.NewRequest("POST", url, reader)
  5418. if err != nil {
  5419. fmt.Println(err.Error())
  5420. return
  5421. }
  5422. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5423. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5424. request.Header.Set("x-tif-signature", signature)
  5425. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5426. request.Header.Set("x-tif-nonce", nonce)
  5427. client := http.Client{}
  5428. resp, err := client.Do(request)
  5429. if err != nil {
  5430. fmt.Println(err.Error())
  5431. return
  5432. }
  5433. respBytes, err := ioutil.ReadAll(resp.Body)
  5434. if err != nil {
  5435. fmt.Println(err.Error())
  5436. return
  5437. }
  5438. fmt.Println(string(respBytes))
  5439. str := string(respBytes)
  5440. fmt.Println(str)
  5441. }
  5442. //for _, item := range result3260.Output.Data[start-1 : stop] {
  5443. // if item.MdtrtId != "out20230406681871" && item.MdtrtId != "out20230406681868" {
  5444. // feedetailInfo := make(map[string]interface{})
  5445. // feedetailInfo["certno"] = item.Certno
  5446. // feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5447. // feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5448. // feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5449. // feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5450. // feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5451. // feedetailInfo["cnfm_flag"] = "1" // 处方号
  5452. // feedetail = append(feedetail, feedetailInfo)
  5453. // }
  5454. //}
  5455. //for _, item := range result3260.Output.Data[start-1 : stop] {
  5456. // if item.MdtrtId == "out20230406681871" {
  5457. // feedetailInfo := make(map[string]interface{})
  5458. // feedetailInfo["certno"] = item.Certno
  5459. // feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5460. // feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5461. // feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5462. // feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5463. // feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5464. // feedetailInfo["cnfm_flag"] = "0" // 处方号
  5465. // feedetail = append(feedetail, feedetailInfo)
  5466. // }
  5467. //
  5468. //}
  5469. //for _, item := range result3260.Output.Data[start-1 : stop] {
  5470. // if item.MdtrtId == "out20230406681868" {
  5471. // feedetailInfo := make(map[string]interface{})
  5472. // feedetailInfo["certno"] = item.Certno
  5473. // feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5474. // feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5475. // feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5476. // feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5477. // feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5478. // feedetailInfo["cnfm_flag"] = "0" // 处方号
  5479. // feedetail = append(feedetail, feedetailInfo)
  5480. // }
  5481. //
  5482. //}
  5483. return
  5484. }
  5485. 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) {
  5486. //msg_month := time.Unix(1557042972, 0).Format("1")
  5487. //msg_year := time.Now().Format("2006")
  5488. //msg_month = time.Now().Format("01")
  5489. //day := time.Now().Format("02")
  5490. //
  5491. //hour := time.Now().Format("15")
  5492. //min := time.Now().Format("04")
  5493. //sec := time.Now().Format("05")
  5494. //
  5495. //msec := time.Now().Format("000")
  5496. //msg_id := fixmedins_code + msg_year + msg_month + day + hour + min + sec + msec + "0"
  5497. feedetail := make([]map[string]interface{}, 0)
  5498. for _, subitem := range result3260 {
  5499. for _, item := range subitem.Output.Data {
  5500. if item.MdtrtId != "out20230406681871" && item.MdtrtId != "out20230406681868" && item.MdtrtId != "out202404174009254" {
  5501. feedetailInfo := make(map[string]interface{})
  5502. feedetailInfo["certno"] = item.Certno
  5503. feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5504. feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5505. feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5506. feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5507. feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5508. feedetailInfo["cnfm_flag"] = "1" // 处方号
  5509. feedetail = append(feedetail, feedetailInfo)
  5510. }
  5511. }
  5512. }
  5513. for _, subitem := range result3260 {
  5514. for _, item := range subitem.Output.Data {
  5515. if item.MdtrtId == "out20230406681871" {
  5516. feedetailInfo := make(map[string]interface{})
  5517. feedetailInfo["certno"] = item.Certno
  5518. feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5519. feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5520. feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5521. feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5522. feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5523. feedetailInfo["cnfm_flag"] = "0" // 处方号
  5524. feedetail = append(feedetail, feedetailInfo)
  5525. }
  5526. }
  5527. }
  5528. for _, subitem := range result3260 {
  5529. for _, item := range subitem.Output.Data {
  5530. if item.MdtrtId == "out20230406681868" {
  5531. feedetailInfo := make(map[string]interface{})
  5532. feedetailInfo["certno"] = item.Certno
  5533. feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5534. feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5535. feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5536. feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5537. feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5538. feedetailInfo["cnfm_flag"] = "0" // 处方号
  5539. feedetail = append(feedetail, feedetailInfo)
  5540. }
  5541. }
  5542. }
  5543. var firstSlice, secondSlice []map[string]interface{}
  5544. if len(feedetail) > 500 {
  5545. firstSlice = feedetail[:500]
  5546. secondSlice = feedetail[500:]
  5547. } else {
  5548. firstSlice = feedetail
  5549. secondSlice = []map[string]interface{}{}
  5550. }
  5551. fmt.Println(firstSlice)
  5552. nonce := GetRandomString(32)
  5553. timestamp := time.Now().Unix()
  5554. signature := setSignature(timestamp, nonce, secret_key)
  5555. //生成输入报文
  5556. total := 0
  5557. for _, item := range result3260{
  5558. total =total + len(item.Output.Data)
  5559. }
  5560. //nonce := GetRandomString(32)
  5561. //timestamp := time.Now().Unix()
  5562. inputMessage := SetInputMessageTwo(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, sign_no)
  5563. input := make(map[string]interface{})
  5564. inputData := make(map[string]interface{})
  5565. inputMessage["infno"] = "3261" // 交易编码
  5566. inputData["trt_year"] = year // 就诊凭证编号
  5567. inputData["trt_month"] = month // 开始时间
  5568. inputData["totalrow"] =len(secondSlice)// 人员姓名
  5569. input["data"] = inputData
  5570. input["detail"] = secondSlice
  5571. inputMessage["input"] = input //交易输入
  5572. //var inputLog string
  5573. bytesData, err := json.Marshal(inputMessage)
  5574. //inputLog = string(bytesData)
  5575. fmt.Println(string(bytesData))
  5576. if err != nil {
  5577. fmt.Println(err.Error())
  5578. return
  5579. }
  5580. reader := bytes.NewReader(bytesData)
  5581. gdyb_url := beego.AppConfig.String("gdyb_url")
  5582. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5583. var url string
  5584. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5585. url = gdyb_url
  5586. } else {
  5587. url = gdyb_url + "3261"
  5588. }
  5589. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  5590. request, err := http.NewRequest("POST", url, reader)
  5591. if err != nil {
  5592. fmt.Println(err.Error())
  5593. return
  5594. }
  5595. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5596. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5597. request.Header.Set("x-tif-signature", signature)
  5598. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5599. request.Header.Set("x-tif-nonce", nonce)
  5600. client := http.Client{}
  5601. resp, err := client.Do(request)
  5602. if err != nil {
  5603. fmt.Println(err.Error())
  5604. return
  5605. }
  5606. respBytes, err := ioutil.ReadAll(resp.Body)
  5607. if err != nil {
  5608. fmt.Println(err.Error())
  5609. return
  5610. }
  5611. fmt.Println(string(respBytes))
  5612. str := string(respBytes)
  5613. fmt.Println(str)
  5614. //for _, item := range result3260.Output.Data[start-1 : stop] {
  5615. // if item.MdtrtId != "out20230406681871" && item.MdtrtId != "out20230406681868" {
  5616. // feedetailInfo := make(map[string]interface{})
  5617. // feedetailInfo["certno"] = item.Certno
  5618. // feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5619. // feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5620. // feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5621. // feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5622. // feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5623. // feedetailInfo["cnfm_flag"] = "1" // 处方号
  5624. // feedetail = append(feedetail, feedetailInfo)
  5625. // }
  5626. //}
  5627. //for _, item := range result3260.Output.Data[start-1 : stop] {
  5628. // if item.MdtrtId == "out20230406681871" {
  5629. // feedetailInfo := make(map[string]interface{})
  5630. // feedetailInfo["certno"] = item.Certno
  5631. // feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5632. // feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5633. // feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5634. // feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5635. // feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5636. // feedetailInfo["cnfm_flag"] = "0" // 处方号
  5637. // feedetail = append(feedetail, feedetailInfo)
  5638. // }
  5639. //
  5640. //}
  5641. //for _, item := range result3260.Output.Data[start-1 : stop] {
  5642. // if item.MdtrtId == "out20230406681868" {
  5643. // feedetailInfo := make(map[string]interface{})
  5644. // feedetailInfo["certno"] = item.Certno
  5645. // feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5646. // feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5647. // feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5648. // feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5649. // feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5650. // feedetailInfo["cnfm_flag"] = "0" // 处方号
  5651. // feedetail = append(feedetail, feedetailInfo)
  5652. // }
  5653. //
  5654. //}
  5655. return
  5656. }
  5657. 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) {
  5658. //生成签名
  5659. nonce := GetRandomString(32)
  5660. timestamp := time.Now().Unix()
  5661. signature := setSignature(timestamp, nonce, secret_key)
  5662. //生成输入报文
  5663. inputMessage := SetInputMessageTwo(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, sign_no)
  5664. input := make(map[string]interface{})
  5665. inputData := make(map[string]interface{})
  5666. inputMessage["infno"] = "3262" // 交易编码
  5667. inputData["trt_year"] = year // 就诊凭证编号
  5668. inputData["trt_month"] = month // 开始时间
  5669. inputData["otransid"] = "0" // 开始时间
  5670. input["data"] = inputData
  5671. inputMessage["input"] = input //交易输入
  5672. var inputLog string
  5673. bytesData, err := json.Marshal(inputMessage)
  5674. inputLog = string(bytesData)
  5675. fmt.Println(string(bytesData))
  5676. if err != nil {
  5677. fmt.Println(err.Error())
  5678. return err.Error(), ""
  5679. }
  5680. reader := bytes.NewReader(bytesData)
  5681. gdyb_url := beego.AppConfig.String("gdyb_url")
  5682. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5683. var url string
  5684. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5685. url = gdyb_url
  5686. } else {
  5687. url = gdyb_url + "3262"
  5688. }
  5689. if insuplc_admdvs == "421300" {
  5690. var json2 string
  5691. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  5692. out, err := cmd.Output()
  5693. if err != nil {
  5694. fmt.Println("error:", err.Error())
  5695. }
  5696. fmt.Println(string(out))
  5697. return hex.EncodeToString(out), inputLog
  5698. } else {
  5699. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  5700. request, err := http.NewRequest("POST", url, reader)
  5701. if err != nil {
  5702. fmt.Println(err.Error())
  5703. return err.Error(), ""
  5704. }
  5705. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5706. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5707. request.Header.Set("x-tif-signature", signature)
  5708. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5709. request.Header.Set("x-tif-nonce", nonce)
  5710. client := http.Client{}
  5711. resp, err := client.Do(request)
  5712. if err != nil {
  5713. fmt.Println(err.Error())
  5714. return err.Error(), ""
  5715. }
  5716. respBytes, err := ioutil.ReadAll(resp.Body)
  5717. if err != nil {
  5718. fmt.Println(err.Error())
  5719. return err.Error(), ""
  5720. }
  5721. fmt.Println(string(respBytes))
  5722. str := string(respBytes)
  5723. return str, inputLog
  5724. }
  5725. }
  5726. 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) {
  5727. //生成签名
  5728. nonce := GetRandomString(32)
  5729. timestamp := time.Now().Unix()
  5730. signature := setSignature(timestamp, nonce, "d6Ad0P1B3z6Dsdst0gYAFPlz8YlIvFDx")
  5731. inputMessage := make(map[string]interface{})
  5732. //生成输入报文
  5733. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127"{
  5734. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs,doctor)
  5735. } else {
  5736. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  5737. }
  5738. input := make(map[string]interface{})
  5739. inputData := make(map[string]interface{})
  5740. inputMessage["infno"] = "9001" // 交易编码
  5741. inputData["opter_no"] = admin_user_id // 就诊凭证编号
  5742. inputData["mac"] = "11-11-11-11-11" // 开始时间
  5743. inputData["ip"] = "11.11.11.11"
  5744. //inputData["userid"] = "H44010400081"
  5745. //month := time.Unix(1557042972, 0).Format("1")
  5746. //year := time.Now().Format("2006")
  5747. //month = time.Now().Format("01")
  5748. //day := time.Now().Format("02")
  5749. //hour := time.Now().Format("15")
  5750. //min := time.Now().Format("04")
  5751. //sec := time.Now().Format("05")
  5752. //custom_time := year + month + day + hour + min + sec
  5753. //inputData["currenttime"] = custom_time
  5754. //var psd string
  5755. //psd = custom_time + "Gzyb$867"
  5756. //h := md5.New()
  5757. //h.Write([]byte(psd))
  5758. //inputData["password"] = strings.ToUpper(hex.EncodeToString(h.Sum(nil)))
  5759. input["data"] = inputData
  5760. inputMessage["input"] = input //交易输入
  5761. var inputLog string
  5762. bytesData, err := json.Marshal(inputMessage)
  5763. inputLog = string(bytesData)
  5764. fmt.Println(string(bytesData))
  5765. if err != nil {
  5766. fmt.Println(err.Error())
  5767. return err.Error(), ""
  5768. }
  5769. reader := bytes.NewReader(bytesData)
  5770. gdyb_url := beego.AppConfig.String("gdyb_url")
  5771. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5772. var url string
  5773. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127"{
  5774. url = gdyb_url
  5775. } else {
  5776. url = gdyb_url + "9001"
  5777. }
  5778. if insuplc_admdvs == "421300" {
  5779. var json2 string
  5780. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  5781. out, err := cmd.Output()
  5782. if err != nil {
  5783. fmt.Println("error:", err.Error())
  5784. }
  5785. fmt.Println(string(out))
  5786. return hex.EncodeToString(out), inputLog
  5787. } else {
  5788. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  5789. request, err := http.NewRequest("POST", url, reader)
  5790. if err != nil {
  5791. fmt.Println(err.Error())
  5792. return err.Error(), ""
  5793. }
  5794. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5795. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5796. request.Header.Set("x-tif-signature", signature)
  5797. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5798. request.Header.Set("x-tif-nonce", nonce)
  5799. fmt.Println(string(bytesData))
  5800. fmt.Println(gdyb_url)
  5801. fmt.Println(gdyb_paasid)
  5802. fmt.Println(request.Header)
  5803. client := http.Client{}
  5804. resp, err := client.Do(request)
  5805. if err != nil {
  5806. fmt.Println(err.Error())
  5807. return err.Error(), ""
  5808. }
  5809. respBytes, err := ioutil.ReadAll(resp.Body)
  5810. if err != nil {
  5811. fmt.Println(err.Error())
  5812. return err.Error(), ""
  5813. }
  5814. fmt.Println(string(respBytes))
  5815. str := string(respBytes)
  5816. return str, inputLog
  5817. }
  5818. }
  5819. 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) {
  5820. //生成签名
  5821. nonce := GetRandomString(32)
  5822. timestamp := time.Now().Unix()
  5823. signature := setSignature(timestamp, nonce, secret_key)
  5824. inputMessage := make(map[string]interface{})
  5825. //生成输入报文
  5826. //生成输入报文
  5827. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127"{
  5828. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs,doctor)
  5829. } else {
  5830. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  5831. }
  5832. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  5833. input := make(map[string]interface{})
  5834. inputData := make(map[string]interface{})
  5835. inputMessage["infno"] = "9001" // 交易编码
  5836. inputData["opter_no"] = admin_user_id // 就诊凭证编号
  5837. inputData["mac"] = GetMac() // 开始时间
  5838. inputData["ip"] = GetLocalIp()
  5839. input["signIn"] = inputData
  5840. inputMessage["input"] = input //交易输入
  5841. var inputLog string
  5842. bytesData, err := json.Marshal(inputMessage)
  5843. inputLog = string(bytesData)
  5844. fmt.Println(string(bytesData))
  5845. if err != nil {
  5846. fmt.Println(err.Error())
  5847. return err.Error(), ""
  5848. }
  5849. reader := bytes.NewReader(bytesData)
  5850. gdyb_url := beego.AppConfig.String("gdyb_url")
  5851. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5852. var url string
  5853. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5854. url = gdyb_url
  5855. } else {
  5856. url = gdyb_url + "9001"
  5857. }
  5858. if insuplc_admdvs == "421300" {
  5859. var json2 string
  5860. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  5861. out, err := cmd.Output()
  5862. if err != nil {
  5863. fmt.Println("error:", err.Error())
  5864. }
  5865. fmt.Println(string(out))
  5866. return hex.EncodeToString(out), inputLog
  5867. } else {
  5868. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  5869. request, err := http.NewRequest("POST", url, reader)
  5870. if err != nil {
  5871. fmt.Println(err.Error())
  5872. return err.Error(), ""
  5873. }
  5874. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5875. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5876. request.Header.Set("x-tif-signature", signature)
  5877. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5878. request.Header.Set("x-tif-nonce", nonce)
  5879. fmt.Println(string(bytesData))
  5880. fmt.Println(gdyb_url)
  5881. fmt.Println(gdyb_paasid)
  5882. fmt.Println(request.Header)
  5883. client := http.Client{}
  5884. resp, err := client.Do(request)
  5885. if err != nil {
  5886. fmt.Println(err.Error())
  5887. return err.Error(), ""
  5888. }
  5889. respBytes, err := ioutil.ReadAll(resp.Body)
  5890. if err != nil {
  5891. fmt.Println(err.Error())
  5892. return err.Error(), ""
  5893. }
  5894. fmt.Println(string(respBytes))
  5895. str := string(respBytes)
  5896. return str, inputLog
  5897. }
  5898. }
  5899. // 获取本机ip
  5900. func GetLocalIp() string {
  5901. addrs, err := net.InterfaceAddrs()
  5902. if err != nil {
  5903. fmt.Println("get local ip failed")
  5904. }
  5905. for _, address := range addrs {
  5906. if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
  5907. if ipnet.IP.To4() != nil {
  5908. return ipnet.IP.String()
  5909. }
  5910. }
  5911. }
  5912. return ""
  5913. }
  5914. // 获取本机Mac
  5915. func GetMac() string {
  5916. interfaces, err := net.Interfaces()
  5917. if err != nil {
  5918. fmt.Println("Get loacl Mac failed")
  5919. }
  5920. for _, inter := range interfaces {
  5921. mac := inter.HardwareAddr
  5922. fmt.Println("+======" + mac.String())
  5923. if mac.String() != "" {
  5924. return mac.String()
  5925. }
  5926. }
  5927. return ""
  5928. }
  5929. // 人员基本信息
  5930. 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) {
  5931. //生成签名
  5932. fmt.Println("DDDDD")
  5933. nonce := GetRandomString(32)
  5934. timestamp := time.Now().Unix()
  5935. signature := setSignature(timestamp, nonce, secret_key)
  5936. //生成输入报文
  5937. inputMessage := make(map[string]interface{})
  5938. //tempTime := time.Unix(timestamp, 0)
  5939. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  5940. // 生成输入报文
  5941. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127"{
  5942. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs,doctor)
  5943. } else {
  5944. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  5945. }
  5946. //inputMessage := SetInputMessagenosign(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  5947. input := make(map[string]interface{})
  5948. inputData := make(map[string]interface{})
  5949. inputMessage["infno"] = "1101" // 交易编码
  5950. if certificates == "3" {
  5951. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  5952. inputData["certno"] = certNo // 证件号码
  5953. inputData["psn_cert_type"] = "99" // 人员证件类型
  5954. } else {
  5955. if certificates == "1" {
  5956. if id_card_type == 1 {
  5957. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  5958. inputData["card_sn"] = "" // 卡识别码
  5959. inputData["certno"] = certNo // 证件号码
  5960. inputData["psn_cert_type"] = "01" // 人员证件类型
  5961. } else if id_card_type == 4 {
  5962. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  5963. inputData["certno"] = certNo // 证件号码
  5964. inputData["psn_cert_type"] = "01" // 人员证件类型
  5965. } else {
  5966. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  5967. inputData["card_sn"] = "" // 卡识别码
  5968. inputData["certno"] = certNo // 证件号码
  5969. inputData["psn_cert_type"] = "01" // 人员证件类型
  5970. }
  5971. } else if certificates == "6" {
  5972. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  5973. inputData["card_sn"] = "" // 卡识别码
  5974. inputData["certno"] = certNo // 证件号码
  5975. inputData["psn_cert_type"] = "17" // 人员证件类型
  5976. }
  5977. }
  5978. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  5979. inputData["begntime"] = "" // 开始时间
  5980. inputData["psn_name"] = "" // 人员姓名
  5981. input["data"] = inputData
  5982. inputMessage["input"] = input //交易输入
  5983. var inputLog string
  5984. bytesData, err := json.Marshal(inputMessage)
  5985. inputLog = string(bytesData)
  5986. fmt.Println(string(bytesData))
  5987. if err != nil {
  5988. fmt.Println(err.Error())
  5989. return err.Error(), ""
  5990. }
  5991. reader := bytes.NewReader(bytesData)
  5992. gdyb_url := beego.AppConfig.String("gdyb_url")
  5993. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5994. //DllDef := syscall.MustLoadDLL("yh_hb_sctrl.dll")
  5995. //Iinit := DllDef.MustFindProc("yh_hb_call")
  5996. //var str3 string
  5997. //ret, _, _ := Iinit.Call(StrPtr("1101"), StrPtr(string(bytesData)), StrPtr(str3))
  5998. //fmt.Println(ret)
  5999. //fmt.Println(str3)
  6000. //
  6001. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6002. var url string
  6003. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  6004. url = gdyb_url
  6005. } else {
  6006. url = gdyb_url + "1101"
  6007. }
  6008. if insuplc_admdvs == "421300" {
  6009. var json2 string
  6010. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  6011. out, err := cmd.Output()
  6012. if err != nil {
  6013. fmt.Println("error:", err.Error())
  6014. }
  6015. fmt.Println(string(out))
  6016. return hex.EncodeToString(out), inputLog
  6017. } else {
  6018. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  6019. request, err := http.NewRequest("POST", url, reader)
  6020. if err != nil {
  6021. fmt.Println(err.Error())
  6022. return err.Error(), ""
  6023. }
  6024. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6025. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6026. request.Header.Set("x-tif-signature", signature)
  6027. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6028. request.Header.Set("x-tif-nonce", nonce)
  6029. client := http.Client{}
  6030. resp, err := client.Do(request)
  6031. if err != nil {
  6032. fmt.Println(err.Error())
  6033. return err.Error(), ""
  6034. }
  6035. respBytes, err := ioutil.ReadAll(resp.Body)
  6036. if err != nil {
  6037. fmt.Println(err.Error())
  6038. return err.Error(), ""
  6039. }
  6040. fmt.Println(string(respBytes))
  6041. str := string(respBytes)
  6042. return str, inputLog
  6043. }
  6044. }
  6045. //func SetInputMessageFour(nonce string, timestamp int64, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) map[string]interface{} {
  6046. // // 生成签名
  6047. // //tempTime := time.Unix(timestamp, 0)
  6048. // //timeFormat := tempTime.Format("20060102150405")
  6049. // //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  6050. // //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  6051. //
  6052. // msec := time.Now().Format("000")
  6053. // fmt.Println(utils.GetNetTime())
  6054. // // 生成输入报文
  6055. // inputMessage := make(map[string]interface{})
  6056. // inputMessage["msgid"] = fixmedins_code + utils.GetNetTime() + msec + "0" // 发送方报文 ID
  6057. // inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  6058. // inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  6059. // inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  6060. // inputMessage["dev_no"] = "" // 设备编号
  6061. // inputMessage["dev_safe_info"] = "" // 设备安全信息
  6062. // inputMessage["cainfo"] = "" // 数字签名信息
  6063. // inputMessage["signtype"] = "SM3" // 签名类型
  6064. // inputMessage["infver"] = "V1.0" // 接收方系统代码
  6065. // inputMessage["opter_type"] = "1" // 经办人类别
  6066. // inputMessage["opter"] = doctor // 经办人
  6067. // inputMessage["opter_name"] = doctor // 经办人姓名
  6068. // inputMessage["inf_time"] = utils.GetNetTime() // 交易时间
  6069. // inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  6070. // inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  6071. // inputMessage["sign_no"] = "" //交易签到流水号
  6072. // return inputMessage
  6073. //}
  6074. func Gdyb5302(psnNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  6075. // 生成签名
  6076. nonce := GetRandomString(32)
  6077. //timestamp := time.Now().Unix()
  6078. timestamp := time.Now().UnixNano() / 1e6
  6079. signature := setSignature(timestamp, nonce, secret_key)
  6080. // 生成输入报文
  6081. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  6082. input := make(map[string]interface{})
  6083. inputData := make(map[string]interface{})
  6084. inputMessage["infno"] = "5302" // 交易编码
  6085. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  6086. inputData["biz_appy_type"] = "03" // 人员编号 (来自1101接口返回)
  6087. input["data"] = inputData
  6088. inputMessage["input"] = input //交易输入
  6089. bytesData, err := json.Marshal(inputMessage)
  6090. fmt.Println(string(bytesData))
  6091. if err != nil {
  6092. fmt.Println(err.Error())
  6093. return err.Error()
  6094. }
  6095. reader := bytes.NewReader(bytesData)
  6096. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6097. gdyb_url := beego.AppConfig.String("gdyb_url")
  6098. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6099. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6100. url := gdyb_url + "5302"
  6101. request, err := http.NewRequest("POST", url, reader)
  6102. if err != nil {
  6103. fmt.Println(err.Error())
  6104. return err.Error()
  6105. }
  6106. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6107. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6108. request.Header.Set("x-tif-signature", signature)
  6109. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6110. request.Header.Set("x-tif-nonce", nonce)
  6111. client := http.Client{}
  6112. resp, err := client.Do(request)
  6113. if err != nil {
  6114. fmt.Println(err.Error())
  6115. return err.Error()
  6116. }
  6117. respBytes, err := ioutil.ReadAll(resp.Body)
  6118. if err != nil {
  6119. fmt.Println(err.Error())
  6120. return err.Error()
  6121. }
  6122. str := string(respBytes)
  6123. fmt.Println(str)
  6124. return str
  6125. }
  6126. func CreateSignIn(record *models.HisSignIn) (err error) {
  6127. err = writeDb.Save(&record).Error
  6128. return
  6129. }
  6130. func GetSignInInfo(code string) string {
  6131. var sign models.HisSignIn
  6132. err = readDb.Model(&models.HisSignIn{}).Where("fixmedins_code = ? AND status = 1", code).Last(&sign).Error
  6133. return sign.SignNo
  6134. }
  6135. func Gdyb3501(struct3501 models.Struct3501, secret_key string) string {
  6136. // 生成签名
  6137. nonce := GetRandomString(32)
  6138. timestamp := time.Now().Unix()
  6139. signature := setSignature(timestamp, nonce, secret_key)
  6140. // 生成输入报文
  6141. inputMessage := SetGdInputMessage(timestamp, struct3501.OrgName, struct3501.Opter, struct3501.FixmedinsHilistId, struct3501.InsuplcAdmdvs, struct3501.MdtrtareaAdmvs, struct3501.Cainfo)
  6142. input := make(map[string]interface{})
  6143. inputData := make(map[string]interface{})
  6144. inputMessage["infno"] = "3501" // 交易编码
  6145. inputData["med_list_codg"] = struct3501.MedListCodg // 定点医药机构目录编号
  6146. inputData["fixmedins_hilist_id"] = struct3501.FixmedinsHilistId // 定点医药机构目录编号
  6147. inputData["fixmedins_hilist_name"] = struct3501.OrgName // 定点医药机构目录名称
  6148. inputData["rx_flag"] = struct3501.RxFlag //
  6149. inputData["invdate"] = struct3501.Invdate // 人员编号 (来自1101接口返回)
  6150. inputData["inv_cnt"] = struct3501.InvCnt // 人员编号 (来自1101接口返回)
  6151. inputData["manu_lotnum"] = struct3501.ManuLotnum // 人员编号 (来自1101接口返回)
  6152. inputData["fixmedins_bchno"] = struct3501.FixmedinsBchno // 人员编号 (来自1101接口返回)
  6153. inputData["manu_date"] = struct3501.ManuDate // 人员编号 (来自1101接口返回)
  6154. inputData["expy_end"] = struct3501.ExpyEnd // 人员编号 (来自1101接口返回)
  6155. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  6156. input["invinfo"] = inputData
  6157. inputMessage["input"] = input //交易输入
  6158. bytesData, err := json.Marshal(inputMessage)
  6159. fmt.Println(string(bytesData))
  6160. if err != nil {
  6161. fmt.Println(err.Error())
  6162. return err.Error()
  6163. }
  6164. reader := bytes.NewReader(bytesData)
  6165. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6166. gdyb_url := beego.AppConfig.String("gdyb_url")
  6167. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6168. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6169. url := gdyb_url + "3501"
  6170. request, err := http.NewRequest("POST", url, reader)
  6171. if err != nil {
  6172. fmt.Println(err.Error())
  6173. return err.Error()
  6174. }
  6175. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6176. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6177. request.Header.Set("x-tif-signature", signature)
  6178. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6179. request.Header.Set("x-tif-nonce", nonce)
  6180. client := http.Client{}
  6181. resp, err := client.Do(request)
  6182. if err != nil {
  6183. fmt.Println(err.Error())
  6184. return err.Error()
  6185. }
  6186. respBytes, err := ioutil.ReadAll(resp.Body)
  6187. if err != nil {
  6188. fmt.Println(err.Error())
  6189. return err.Error()
  6190. }
  6191. str := string(respBytes)
  6192. fmt.Println(str)
  6193. return str
  6194. }
  6195. func Gdyb3502(struct3502 models.Struct3502, secret_key string) string {
  6196. // 生成签名
  6197. nonce := GetRandomString(32)
  6198. timestamp := time.Now().Unix()
  6199. signature := setSignature(timestamp, nonce, secret_key)
  6200. // 生成输入报文
  6201. inputMessage := SetGdInputMessage(timestamp, struct3502.OrgName, struct3502.Opter, struct3502.FixmedinsCode, struct3502.InsuplcAdmdvs, struct3502.MdtrtareaAdmvs, struct3502.Cainfo)
  6202. input := make(map[string]interface{})
  6203. inputData := make(map[string]interface{})
  6204. inputMessage["infno"] = "3502" // 交易编码
  6205. inputData["med_list_codg"] = struct3502.MedListCodg // 定点医药机构目录编号
  6206. inputData["inv_chg_type"] = struct3502.InvChgType // 定点医药机构目录编号
  6207. inputData["fixmedins_hilist_id"] = struct3502.FixmedinsCode // 定点医药机构目录编号
  6208. inputData["fixmedins_hilist_name"] = struct3502.OrgName // 定点医药机构目录名称
  6209. inputData["fixmedins_bchno"] = struct3502.FixmedinsBchno // 人员编号 (来自1101接口返回)
  6210. inputData["pric"] = struct3502.Pric // 人员编号 (来自1101接口返回)
  6211. inputData["cnt"] = struct3502.Cnt // 人员编号 (来自1101接口返回)
  6212. inputData["rx_flag"] = struct3502.RxFlag //
  6213. inputData["inv_chg_time"] = struct3502.InvChgTime // 人员编号 (来自1101接口返回)
  6214. inputData["inv_chg_opter_name"] = "" // 人员编号 (来自1101接口返回)
  6215. inputData["memo"] = struct3502.Memo // 人员编号 (来自1101接口返回)
  6216. inputData["trdn_flag"] = "" // 人员编号 (来自1101接口返回)
  6217. input["invinfo"] = inputData
  6218. inputMessage["input"] = input //交易输入
  6219. bytesData, err := json.Marshal(inputMessage)
  6220. fmt.Println(string(bytesData))
  6221. if err != nil {
  6222. fmt.Println(err.Error())
  6223. return err.Error()
  6224. }
  6225. reader := bytes.NewReader(bytesData)
  6226. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6227. gdyb_url := beego.AppConfig.String("gdyb_url")
  6228. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6229. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6230. url := gdyb_url + "3502"
  6231. request, err := http.NewRequest("POST", url, reader)
  6232. if err != nil {
  6233. fmt.Println(err.Error())
  6234. return err.Error()
  6235. }
  6236. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6237. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6238. request.Header.Set("x-tif-signature", signature)
  6239. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6240. request.Header.Set("x-tif-nonce", nonce)
  6241. client := http.Client{}
  6242. resp, err := client.Do(request)
  6243. if err != nil {
  6244. fmt.Println(err.Error())
  6245. return err.Error()
  6246. }
  6247. respBytes, err := ioutil.ReadAll(resp.Body)
  6248. if err != nil {
  6249. fmt.Println(err.Error())
  6250. return err.Error()
  6251. }
  6252. str := string(respBytes)
  6253. fmt.Println(str)
  6254. return str
  6255. }
  6256. func Gdyb3503(struct3503 models.Struct3503, secret_key string) string {
  6257. // 生成签名
  6258. nonce := GetRandomString(32)
  6259. timestamp := time.Now().Unix()
  6260. signature := setSignature(timestamp, nonce, secret_key)
  6261. // 生成输入报文
  6262. inputMessage := SetGdInputMessage(timestamp, struct3503.OrgName, struct3503.Opter, struct3503.FixmedinsHilistId, struct3503.InsuplcAdmdvs, struct3503.MdtrtareaAdmvs, struct3503.Cainfo)
  6263. input := make(map[string]interface{})
  6264. inputMessage["infno"] = "3503"
  6265. item := struct3503
  6266. feedetailInfo := make(map[string]interface{})
  6267. feedetailInfo["med_list_codg"] = item.MedListCodg
  6268. feedetailInfo["fixmedins_hilist_id"] = item.FixmedinsHilistId
  6269. feedetailInfo["fixmedins_hilist_name"] = item.FixmedinsHilistName
  6270. feedetailInfo["dynt_no"] = ""
  6271. feedetailInfo["fixmedins_bchno"] = item.FixmedinsBchno // 人员编号 (来自1101接口返回)
  6272. feedetailInfo["spler_name"] = item.SplerName // 人员编号 (来自1101接口返回)
  6273. feedetailInfo["spler_pmtno"] = "" // 人员编号 (来自1101接口返回)
  6274. feedetailInfo["manu_lotnum"] = item.ManuLotnum // 人员编号 (来自1101接口返回)
  6275. feedetailInfo["prodentp_name"] = item.ProdentpName // 人员编号 (来自1101接口返回)
  6276. feedetailInfo["aprvno"] = item.Aprvno // 人员编号 (来自1101接口返回)
  6277. feedetailInfo["manu_date"] = item.ManuDate // 人员编号 (来自1101接口返回)
  6278. feedetailInfo["expy_end"] = item.ExpyEnd // 人员编号 (来自1101接口返回)
  6279. feedetailInfo["finl_trns_pric"] = item.FinlTrnsPric // 人员编号 (来自1101接口返回)
  6280. feedetailInfo["purc_retn_cnt"] = item.PurcRetnCnt // 人员编号 (来自1101接口返回)
  6281. feedetailInfo["purc_invo_codg"] = item.PurcInvoCodg // 人员编号 (来自1101接口返回)
  6282. feedetailInfo["purc_invo_no"] = item.PurcInvoNo // 人员编号 (来自1101接口返回)
  6283. feedetailInfo["rx_flag"] = item.RxFlag // 人员编号 (来自1101接口返回)
  6284. feedetailInfo["purc_retn_stoin_time"] = item.PurcRetnStoinTime // 人员编号 (来自1101接口返回)
  6285. feedetailInfo["purc_retn_opter_name"] = item.PurcRetnOpterName // 人员编号 (来自1101接口返回)
  6286. feedetailInfo["prod_geay_flag"] = "" // 人员编号 (来自1101接口返回)
  6287. feedetailInfo["memo"] = "" // 人员编号 (来自1101接口返回)
  6288. input["purcinfo"] = feedetailInfo
  6289. inputMessage["input"] = input //交易输入
  6290. bytesData, err := json.Marshal(inputMessage)
  6291. fmt.Println(string(bytesData))
  6292. if err != nil {
  6293. fmt.Println(err.Error())
  6294. return err.Error()
  6295. }
  6296. reader := bytes.NewReader(bytesData)
  6297. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6298. gdyb_url := beego.AppConfig.String("gdyb_url")
  6299. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6300. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6301. url := gdyb_url + "3503"
  6302. request, err := http.NewRequest("POST", url, reader)
  6303. if err != nil {
  6304. fmt.Println(err.Error())
  6305. return err.Error()
  6306. }
  6307. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6308. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6309. request.Header.Set("x-tif-signature", signature)
  6310. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6311. request.Header.Set("x-tif-nonce", nonce)
  6312. client := http.Client{}
  6313. resp, err := client.Do(request)
  6314. if err != nil {
  6315. fmt.Println(err.Error())
  6316. return err.Error()
  6317. }
  6318. respBytes, err := ioutil.ReadAll(resp.Body)
  6319. if err != nil {
  6320. fmt.Println(err.Error())
  6321. return err.Error()
  6322. }
  6323. str := string(respBytes)
  6324. fmt.Println(str)
  6325. return str
  6326. }
  6327. func Gdyb3504(struct3504 models.Struct3504, secret_key string) string {
  6328. // 生成签名
  6329. nonce := GetRandomString(32)
  6330. timestamp := time.Now().Unix()
  6331. signature := setSignature(timestamp, nonce, secret_key)
  6332. // 生成输入报文
  6333. inputMessage := SetGdInputMessage(timestamp, struct3504.OrgName, struct3504.Opter, struct3504.FixmedinsCode, struct3504.InsuplcAdmdvs, struct3504.MdtrtareaAdmvs, struct3504.Cainfo)
  6334. input := make(map[string]interface{})
  6335. inputData := make(map[string]interface{})
  6336. inputMessage["infno"] = "3504" // 交易编码
  6337. inputData["med_list_codg"] = struct3504.MedListCodg // 定点医药机构目录编号
  6338. inputData["fixmedins_hilist_id"] = struct3504.FixmedinsHilistId // 定点医药机构目录编号
  6339. inputData["fixmedins_hilist_name"] = struct3504.FixmedinsHilistName // 定点医药机构目录名称
  6340. inputData["fixmedins_bchno"] = struct3504.FixmedinsBchno // 人员编号 (来自1101接口返回)
  6341. inputData["spler_name"] = struct3504.SplerName // 人员编号 (来自1101接口返回)
  6342. inputData["spler_pmtno"] = "" // 人员编号 (来自1101接口返回)
  6343. inputData["manu_date"] = struct3504.ManuDate // 人员编号 (来自1101接口返回)
  6344. inputData["expy_end"] = struct3504.ExpyEnd // 人员编号 (来自1101接口返回)
  6345. inputData["finl_trns_pric"] = struct3504.FinlTrnsPric // 人员编号 (来自1101接口返回)
  6346. inputData["purc_retn_cnt"] = struct3504.PurcRetnCnt // 人员编号 (来自1101接口返回)
  6347. inputData["purc_invo_codg"] = struct3504.PurcInvoCodg // 人员编号 (来自1101接口返回)
  6348. inputData["purc_invo_no"] = struct3504.PurcInvoNo // 人员编号 (来自1101接口返回)
  6349. inputData["rx_flag"] = struct3504.RxFlag
  6350. inputData["purc_retn_stoin_time"] = struct3504.PurcRetnStoin
  6351. inputData["purc_retn_opter_name"] = struct3504.PurcRetnStoin
  6352. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  6353. inputData["medins_prod_purc_no"] = "" // 人员编号 (来自1101接口返回)
  6354. input["purcinfo"] = inputData
  6355. inputMessage["input"] = input //交易输入
  6356. bytesData, err := json.Marshal(inputMessage)
  6357. fmt.Println(string(bytesData))
  6358. if err != nil {
  6359. fmt.Println(err.Error())
  6360. return err.Error()
  6361. }
  6362. reader := bytes.NewReader(bytesData)
  6363. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6364. gdyb_url := beego.AppConfig.String("gdyb_url")
  6365. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6366. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6367. url := gdyb_url + "3504"
  6368. request, err := http.NewRequest("POST", url, reader)
  6369. if err != nil {
  6370. fmt.Println(err.Error())
  6371. return err.Error()
  6372. }
  6373. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6374. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6375. request.Header.Set("x-tif-signature", signature)
  6376. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6377. request.Header.Set("x-tif-nonce", nonce)
  6378. client := http.Client{}
  6379. resp, err := client.Do(request)
  6380. if err != nil {
  6381. fmt.Println(err.Error())
  6382. return err.Error()
  6383. }
  6384. respBytes, err := ioutil.ReadAll(resp.Body)
  6385. if err != nil {
  6386. fmt.Println(err.Error())
  6387. return err.Error()
  6388. }
  6389. str := string(respBytes)
  6390. fmt.Println(str)
  6391. return str
  6392. }
  6393. func Gdyb3505(struct3505 models.Struct3505, secret_key string) string {
  6394. // 生成签名
  6395. nonce := GetRandomString(32)
  6396. timestamp := time.Now().Unix()
  6397. signature := setSignature(timestamp, nonce, secret_key)
  6398. // 生成输入报文
  6399. inputMessage := SetGdInputMessage(timestamp, struct3505.OrgName, struct3505.Opter, struct3505.FixmedinsHilistId, struct3505.InsuplcAdmdvs, struct3505.MdtrtareaAdmvs, struct3505.Cainfo)
  6400. input := make(map[string]interface{})
  6401. inputData := make(map[string]interface{})
  6402. inputMessage["infno"] = "3505" // 交易编码
  6403. inputData["med_list_codg"] = struct3505.MedListCodg // 定点医药机构目录编号
  6404. inputData["fixmedins_hilist_id"] = struct3505.FixmedinsHilistId // 定点医药机构目录编号
  6405. inputData["fixmedins_hilist_name"] = struct3505.OrgName // 定点医药机构目录名称
  6406. inputData["fixmedins_bchno"] = struct3505.FixmedinsBchno // 人员编号 (来自1101接口返回)
  6407. inputData["prsc_dr_cert_type"] = struct3505.PrscDrCertType // 人员编号 (来自1101接口返回)
  6408. inputData["prsc_dr_certno"] = struct3505.PrscDrCertno // 人员编号 (来自1101接口返回)
  6409. inputData["prsc_dr_name"] = struct3505.PrscDrName // 人员编号 (来自1101接口返回)
  6410. inputData["phar_cert_type"] = struct3505.PharCertType // 人员编号 (来自1101接口返回)
  6411. inputData["phar_certno"] = struct3505.PharCertno // 人员编号 (来自1101接口返回)
  6412. inputData["phar_name"] = struct3505.PharName // 人员编号 (来自1101接口返回)
  6413. inputData["phar_prac_cert_no"] = struct3505.PharPracCertNo // 人员编号 (来自1101接口返回)
  6414. inputData["hi_feesetl_type"] = struct3505.HiFeesetlType // 人员编号 (来自1101接口返回)
  6415. inputData["setl_id"] = struct3505.SetlId // 人员编号 (来自1101接口返回)
  6416. inputData["mdtrt_sn"] = struct3505.MdtrtSn // 人员编号 (来自1101接口返回)
  6417. inputData["psn_no"] = struct3505.PsnNo // 人员编号 (来自1101接口返回)
  6418. inputData["psn_cert_type"] = struct3505.PsnCertType // 人员编号 (来自1101接口返回)
  6419. inputData["certno"] = struct3505.CertNo // 人员编号 (来自1101接口返回)
  6420. inputData["psn_name"] = struct3505.PsnName // 人员编号 (来自1101接口返回)
  6421. inputData["manu_lotnum"] = struct3505.ManuLotnum // 人员编号 (来自1101接口返回)
  6422. inputData["manu_date"] = struct3505.ManuDate // 人员编号 (来自1101接口返回)
  6423. inputData["expy_end"] = struct3505.ExpyEnd // 人员编号 (来自1101接口返回)
  6424. inputData["rx_flag"] = struct3505.RxFlag // 人员编号 (来自1101接口返回)
  6425. inputData["trdn_flag"] = struct3505.TrdnFlag // 人员编号 (来自1101接口返回)
  6426. inputData["finl_trns_pric"] = struct3505.FinlTrnsPric // 人员编号 (来自1101接口返回)
  6427. inputData["rxno"] = struct3505.Rxno // 人员编号 (来自1101接口返回)
  6428. inputData["rx_circ_flag"] = struct3505.RxCircFlag // 人员编号 (来自1101接口返回)
  6429. inputData["rtal_docno"] = struct3505.RtalDocno // 人员编号 (来自1101接口返回)
  6430. inputData["stoout_no"] = struct3505.StooutNo // 人员编号 (来自1101接口返回)
  6431. inputData["bchno"] = struct3505.Bchno // 人员编号 (来自1101接口返回)
  6432. inputData["drug_trac_codg"] = struct3505.DrugTracCodg // 人员编号 (来自1101接口返回)
  6433. inputData["drug_prod_barc"] = struct3505.DrugProdBarc // 人员编号 (来自1101接口返回)
  6434. inputData["shelf_posi"] = struct3505.ShelfPosi // 人员编号 (来自1101接口返回)
  6435. inputData["sel_retn_cnt"] = struct3505.SelRetnCnt // 人员编号 (来自1101接口返回)
  6436. inputData["sel_retn_time"] = struct3505.SelRetnTime // 人员编号 (来自1101接口返回)
  6437. inputData["sel_retn_opter_name"] = struct3505.SelRetnOpterName // 人员编号 (来自1101接口返回)
  6438. inputData["memo"] = struct3505.Memo // 人员编号 (来自1101接口返回)
  6439. input["selinfo"] = inputData
  6440. inputMessage["input"] = input //交易输入
  6441. bytesData, err := json.Marshal(inputMessage)
  6442. fmt.Println(string(bytesData))
  6443. if err != nil {
  6444. fmt.Println(err.Error())
  6445. return err.Error()
  6446. }
  6447. reader := bytes.NewReader(bytesData)
  6448. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6449. gdyb_url := beego.AppConfig.String("gdyb_url")
  6450. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6451. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6452. url := gdyb_url + "3505"
  6453. request, err := http.NewRequest("POST", url, reader)
  6454. if err != nil {
  6455. fmt.Println(err.Error())
  6456. return err.Error()
  6457. }
  6458. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6459. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6460. request.Header.Set("x-tif-signature", signature)
  6461. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6462. request.Header.Set("x-tif-nonce", nonce)
  6463. client := http.Client{}
  6464. resp, err := client.Do(request)
  6465. if err != nil {
  6466. fmt.Println(err.Error())
  6467. return err.Error()
  6468. }
  6469. respBytes, err := ioutil.ReadAll(resp.Body)
  6470. if err != nil {
  6471. fmt.Println(err.Error())
  6472. return err.Error()
  6473. }
  6474. str := string(respBytes)
  6475. fmt.Println(str)
  6476. return str
  6477. }
  6478. func Gdyb3506(struct3506 models.Struct3506, secret_key string) string {
  6479. // 生成签名
  6480. nonce := GetRandomString(32)
  6481. timestamp := time.Now().Unix()
  6482. signature := setSignature(timestamp, nonce, secret_key)
  6483. // 生成输入报文
  6484. inputMessage := SetGdInputMessage(timestamp, struct3506.OrgName, struct3506.Opter, struct3506.FixmedinsCode, struct3506.InsuplcAdmdvs, struct3506.MdtrtareaAdmvs, struct3506.Cainfo)
  6485. input := make(map[string]interface{})
  6486. inputData := make(map[string]interface{})
  6487. inputMessage["infno"] = "3506" // 交易编码
  6488. inputData["med_list_codg"] = struct3506.MedListCodg // 定点医药机构目录编号
  6489. inputData["fixmedins_hilist_id"] = struct3506.FixmedinsHilistId // 定点医药机构目录编号
  6490. inputData["fixmedins_hilist_name"] = struct3506.OrgName // 定点医药机构目录名称
  6491. inputData["fixmedins_bchno"] = struct3506.FixmedinsBchno // 人员编号 (来自1101接口返回)
  6492. inputData["setl_id"] = struct3506.SetlId // 人员编号 (来自1101接口返回)
  6493. inputData["psn_no"] = struct3506.PsnNo // 人员编号 (来自1101接口返回)
  6494. inputData["psn_cert_type"] = struct3506.PsnCertType // 人员编号 (来自1101接口返回)
  6495. inputData["certno"] = struct3506.Certno // 人员编号 (来自1101接口返回)
  6496. inputData["psn_name"] = struct3506.PsnName // 人员编号 (来自1101接口返回)
  6497. inputData["manu_lotnum"] = struct3506.ManuLotnum // 人员编号 (来自1101接口返回)
  6498. inputData["manu_date"] = struct3506.ManuDate // 人员编号 (来自1101接口返回)
  6499. inputData["expy_end"] = struct3506.ExpyEnd // 人员编号 (来自1101接口返回)
  6500. inputData["rx_flag"] = struct3506.RxFlag // 人员编号 (来自1101接口返回)
  6501. inputData["trdn_flag"] = struct3506.TrdnFlag // 人员编号 (来自1101接口返回)
  6502. inputData["finl_trns_pric"] = struct3506.FinlTrnsPric // 人员编号 (来自1101接口返回)
  6503. inputData["sel_retn_cnt"] = struct3506.SelRetnCnt // 人员编号 (来自1101接口返回)
  6504. inputData["sel_retn_time"] = struct3506.SelRetnTime // 人员编号 (来自1101接口返回)
  6505. inputData["sel_retn_opter_name"] = struct3506.SelRetnOpterName // 人员编号 (来自1101接口返回)
  6506. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  6507. inputData["medins_prod_sel_no"] = "" // 人员编号 (来自1101接口返回)
  6508. input["selinfo"] = inputData
  6509. inputMessage["input"] = input //交易输入
  6510. bytesData, err := json.Marshal(inputMessage)
  6511. fmt.Println(string(bytesData))
  6512. if err != nil {
  6513. fmt.Println(err.Error())
  6514. return err.Error()
  6515. }
  6516. reader := bytes.NewReader(bytesData)
  6517. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6518. gdyb_url := beego.AppConfig.String("gdyb_url")
  6519. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6520. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6521. url := gdyb_url + "3506"
  6522. request, err := http.NewRequest("POST", url, reader)
  6523. if err != nil {
  6524. fmt.Println(err.Error())
  6525. return err.Error()
  6526. }
  6527. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6528. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6529. request.Header.Set("x-tif-signature", signature)
  6530. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6531. request.Header.Set("x-tif-nonce", nonce)
  6532. client := http.Client{}
  6533. resp, err := client.Do(request)
  6534. if err != nil {
  6535. fmt.Println(err.Error())
  6536. return err.Error()
  6537. }
  6538. respBytes, err := ioutil.ReadAll(resp.Body)
  6539. if err != nil {
  6540. fmt.Println(err.Error())
  6541. return err.Error()
  6542. }
  6543. str := string(respBytes)
  6544. fmt.Println(str)
  6545. return str
  6546. }
  6547. func Gdyb3507(struct3507 models.Struct3507, secret_key string) string {
  6548. // 生成签名
  6549. nonce := GetRandomString(32)
  6550. timestamp := time.Now().Unix()
  6551. signature := setSignature(timestamp, nonce, secret_key)
  6552. // 生成输入报文
  6553. inputMessage := SetGdInputMessage(timestamp, struct3507.OrgName, struct3507.Opter, struct3507.FixmedinsCode, struct3507.InsuplcAdmdvs, struct3507.MdtrtareaAdmvs, struct3507.Cainfo)
  6554. input := make(map[string]interface{})
  6555. inputData := make(map[string]interface{})
  6556. inputMessage["infno"] = "3507" // 交易编码
  6557. inputData["fixmedins_bchno"] = struct3507.FixmedinsCode // 人员编号 (来自1101接口返回)
  6558. inputData["inv_data_type"] = struct3507.InvDataType // 人员编号 (来自1101接口返回)
  6559. input["data"] = inputData
  6560. inputMessage["input"] = input //交易输入
  6561. bytesData, err := json.Marshal(inputMessage)
  6562. fmt.Println(string(bytesData))
  6563. if err != nil {
  6564. fmt.Println(err.Error())
  6565. return err.Error()
  6566. }
  6567. reader := bytes.NewReader(bytesData)
  6568. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6569. gdyb_url := beego.AppConfig.String("gdyb_url")
  6570. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6571. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6572. url := gdyb_url + "3507"
  6573. request, err := http.NewRequest("POST", url, reader)
  6574. if err != nil {
  6575. fmt.Println(err.Error())
  6576. return err.Error()
  6577. }
  6578. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6579. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6580. request.Header.Set("x-tif-signature", signature)
  6581. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6582. request.Header.Set("x-tif-nonce", nonce)
  6583. client := http.Client{}
  6584. resp, err := client.Do(request)
  6585. if err != nil {
  6586. fmt.Println(err.Error())
  6587. return err.Error()
  6588. }
  6589. respBytes, err := ioutil.ReadAll(resp.Body)
  6590. if err != nil {
  6591. fmt.Println(err.Error())
  6592. return err.Error()
  6593. }
  6594. str := string(respBytes)
  6595. fmt.Println(str)
  6596. return str
  6597. }
  6598. // 生成基础报文
  6599. func SetGdInputMessage(timestamp int64, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, cainfo string) map[string]interface{} {
  6600. // 生成签名
  6601. tempTime := time.Unix(timestamp, 0)
  6602. //timeFormat := tempTime.Format("20060102150405")
  6603. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  6604. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  6605. month := time.Unix(1557042972, 0).Format("1")
  6606. year := time.Now().Format("2006")
  6607. month = time.Now().Format("01")
  6608. day := time.Now().Format("02")
  6609. hour := time.Now().Format("15")
  6610. min := time.Now().Format("04")
  6611. sec := time.Now().Format("05")
  6612. msec := time.Now().Format("000")
  6613. // 生成输入报文
  6614. inputMessage := make(map[string]interface{})
  6615. inputMessage["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  6616. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  6617. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  6618. inputMessage["recer_sys_code"] = "MBS_LOCAL" // 接收方系统代码
  6619. inputMessage["dev_no"] = "1" // 设备编号
  6620. inputMessage["dev_safe_info"] = "1" // 设备安全信息
  6621. inputMessage["cainfo"] = cainfo // 数字签名信息
  6622. inputMessage["signtype"] = "SM3" // 签名类型
  6623. inputMessage["infver"] = "1.0.0" // 接收方系统代码
  6624. inputMessage["opter_type"] = "1" // 经办人类别
  6625. inputMessage["opter"] = doctor // 经办人
  6626. inputMessage["opter_name"] = doctor // 经办人姓名
  6627. inputMessage["inf_time"] = timeFormatOne // 交易时间
  6628. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  6629. inputMessage["fixmedins_name"] = org_name
  6630. inputMessage["fixmedins_soft_fcty"] = "深圳市领透科技有限公司" //定点医药机构名称
  6631. //定点医药机构名称
  6632. inputMessage["sign_no"] = "" //交易签到流水号
  6633. return inputMessage
  6634. }
  6635. 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) {
  6636. nonce := GetRandomString(32)
  6637. timestamp := time.Now().Unix()
  6638. signature := setSignature(timestamp, nonce, params.SecretKey)
  6639. // 生成输入报文
  6640. inputMessage := SetGdInputMessage(timestamp, params.FixmedinsName, params.OpterName, params.FixmedinsCode, params.InsuplcAdmdvs, params.MdtrtareaAdmvs, params.Cainfo)
  6641. //inputMessage := SetJSInputMessage(timestamp, params.FixmedinsName, params.OpterName, params.FixmedinsCode, params.InsuplcAdmdvs, params.MdtrtareaAdmvs, params.Cainfo)
  6642. input := make(map[string]interface{})
  6643. inputData := make(map[string]interface{})
  6644. patientDtosinputData := make(map[string]interface{})
  6645. fisEncounterDtosData := make(map[string]interface{})
  6646. fsiDiagnoseDtosDatas := make([]map[string]interface{}, 0)
  6647. fsiOrderDtosDatas := make([]map[string]interface{}, 0)
  6648. fsiOperationDtosData := make(map[string]interface{})
  6649. fsiOperationDtosDatas := make([]map[string]interface{}, 0)
  6650. //就诊信息
  6651. fisEncounterDtosData["mdtrt_id"] = fed.MdtrtID
  6652. fisEncounterDtosData["medins_id"] = fed.MedinsID
  6653. fisEncounterDtosData["medins_name"] = fed.MedinsName
  6654. fisEncounterDtosData["medins_admdvs"] = fed.MedinsAdmdvs
  6655. fisEncounterDtosData["medins_type"] = fed.MedinsType
  6656. fisEncounterDtosData["medins_lv"] = fed.MedinsLv
  6657. fisEncounterDtosData["wardarea_codg"] = fed.WardareaCodg
  6658. fisEncounterDtosData["wardno"] = fed.Wardno
  6659. fisEncounterDtosData["bedno"] = fed.Bedno
  6660. fisEncounterDtosData["adm_date"] = fed.AdmDate
  6661. fisEncounterDtosData["dscg_date"] = fed.DscgDate
  6662. fisEncounterDtosData["dscg_main_dise_codg"] = fed.DscgMainDiseCodg
  6663. fisEncounterDtosData["dscg_main_dise_name"] = fed.DscgMainDiseName
  6664. for _, fdd := range fdds {
  6665. fsiDiagnoseDtosData := make(map[string]interface{})
  6666. //诊断集合
  6667. fsiDiagnoseDtosData["dise_id"] = fdd.DiseID
  6668. fsiDiagnoseDtosData["inout_dise_type"] = fdd.InoutDiseType
  6669. fsiDiagnoseDtosData["maindise_flag"] = fdd.MaindiseFlag
  6670. fsiDiagnoseDtosData["dias_srt_no"] = fdd.DiasSrtNo
  6671. fsiDiagnoseDtosData["dise_codg"] = fdd.DiseCodg
  6672. fsiDiagnoseDtosData["dise_name"] = fdd.DiseName
  6673. fsiDiagnoseDtosData["dise_date"] = fdd.DiseDate
  6674. fsiDiagnoseDtosDatas = append(fsiDiagnoseDtosDatas, fsiDiagnoseDtosData)
  6675. }
  6676. fisEncounterDtosData["fsi_diagnose_dtos"] = fsiDiagnoseDtosDatas
  6677. fisEncounterDtosData["dr_codg"] = fed.DrCodg
  6678. fisEncounterDtosData["adm_dept_codg"] = fed.AdmDeptCodg
  6679. fisEncounterDtosData["adm_dept_name"] = fed.AdmDeptName
  6680. fisEncounterDtosData["dscg_dept_codg"] = fed.DscgDeptCodg
  6681. fisEncounterDtosData["dscg_dept_name"] = fed.DscgDeptName
  6682. fisEncounterDtosData["med_mdtrt_type"] = fed.MedMdtrtType
  6683. fisEncounterDtosData["med_type"] = fed.MedType
  6684. for _, fod := range fods {
  6685. fsiOrderDtosData := make(map[string]interface{})
  6686. //医嘱集合
  6687. fsiOrderDtosData["rx_id"] = fod.RxID
  6688. fsiOrderDtosData["rxno"] = fod.Rxno
  6689. fsiOrderDtosData["grpno"] = fod.Grpno
  6690. fsiOrderDtosData["long_drord_flag"] = fod.LongDrordFlag
  6691. fsiOrderDtosData["hilist_type"] = fod.HilistType
  6692. fsiOrderDtosData["chrg_type"] = fod.ChrgType
  6693. fsiOrderDtosData["drord_bhvr"] = fod.DrordBhvr
  6694. fsiOrderDtosData["hilist_code"] = fod.HilistCode
  6695. fsiOrderDtosData["hilist_name"] = fod.HosplistName
  6696. fsiOrderDtosData["hilist_dosform"] = fod.HilistDosform
  6697. fsiOrderDtosData["hilist_lv"] = fod.HilistLv
  6698. fsiOrderDtosData["hilist_pric"] = fod.HilistPric
  6699. fsiOrderDtosData["lv1_hosp_item_pric"] = fod.Lv1HospItemPric
  6700. fsiOrderDtosData["lv2_hosp_item_pric"] = fod.Lv2HospItemPric
  6701. fsiOrderDtosData["lv3_hosp_item_pric"] = fod.Lv3HospItemPric
  6702. fsiOrderDtosData["hilist_memo"] = fod.HilistMemo
  6703. fsiOrderDtosData["hosplist_code"] = fod.HosplistCode
  6704. fsiOrderDtosData["hosplist_name"] = fod.HosplistName
  6705. fsiOrderDtosData["hosplist_dosform"] = fod.HosplistDosform
  6706. fsiOrderDtosData["cnt"] = fod.Cnt
  6707. fsiOrderDtosData["pric"] = fod.Pric
  6708. fsiOrderDtosData["sumamt"] = fod.Sumamt
  6709. fsiOrderDtosData["ownpay_amt"] = fod.OwnpayAmt
  6710. fsiOrderDtosData["selfpay_amt"] = fod.SelfpayAmt
  6711. fsiOrderDtosData["spec"] = fod.Spec
  6712. fsiOrderDtosData["spec_unt"] = fod.SpecUnt
  6713. fsiOrderDtosData["drord_begn_date"] = fod.DrordBegnDate
  6714. fsiOrderDtosData["drord_stop_date"] = fod.DrordStopDate
  6715. fsiOrderDtosData["drord_dept_codg"] = fod.DrordDeptCodg
  6716. fsiOrderDtosData["drord_dept_name"] = fod.DrordDeptName
  6717. fsiOrderDtosData["drord_dr_codg"] = fod.DrordDrCodg
  6718. fsiOrderDtosData["drord_dr_name"] = fod.DrordDrName
  6719. fsiOrderDtosData["drord_dr_profttl"] = fod.DrordDrProfttl
  6720. fsiOrderDtosData["curr_drord_flag"] = fod.CurrDrordFlag
  6721. fsiOrderDtosDatas = append(fsiOrderDtosDatas, fsiOrderDtosData)
  6722. }
  6723. fisEncounterDtosData["fsi_order_dtos"] = fsiOrderDtosDatas
  6724. fisEncounterDtosData["matn_stas"] = fed.MatnStas
  6725. fisEncounterDtosData["medfee_sumamt"] = fed.MedfeeSumamt
  6726. fisEncounterDtosData["ownpay_amt"] = fed.OwnpayAmt
  6727. fisEncounterDtosData["selfpay_amt"] = fed.SelfpayAmt
  6728. fisEncounterDtosData["acct_payamt"] = fed.AcctPayamt
  6729. fisEncounterDtosData["ma_amt"] = fed.MaAmt
  6730. fisEncounterDtosData["hifp_payamt"] = fed.HifpPayamt
  6731. fisEncounterDtosData["setl_totlnum"] = fed.SetlTotlnum
  6732. fisEncounterDtosData["insutype"] = fed.Insutype
  6733. fisEncounterDtosData["reim_flag"] = fed.ReimFlag
  6734. fisEncounterDtosData["out_setl_flag"] = fed.OutSetlFlag
  6735. //手术操作
  6736. for _, fopd := range fopds {
  6737. fsiOperationDtosData["setl_list_oprn_id"] = fopd.Setl_list_oprn_id
  6738. fsiOperationDtosData["oprn_code"] = fopd.Oprn_code
  6739. fsiOperationDtosData["oprn_name"] = fopd.Oprn_name
  6740. fsiOperationDtosData["main_oprn_flag"] = fopd.Main_oprn_flag
  6741. fsiOperationDtosData["oprn_date"] = fopd.Oprn_date
  6742. fsiOperationDtosData["anst_way"] = fopd.Anst_way
  6743. fsiOperationDtosData["oper_dr_name"] = fopd.Oper_dr_name
  6744. fsiOperationDtosData["oper_dr_code"] = fopd.Oper_dr_code
  6745. fsiOperationDtosData["anst_dr_name"] = fopd.Anst_dr_name
  6746. fsiOperationDtosData["anst_dr_code"] = fopd.Anst_dr_code
  6747. fsiOperationDtosDatas = append(fsiOperationDtosDatas, fsiOperationDtosData)
  6748. }
  6749. fisEncounterDtosData["fsi_operation_dtos"] = fsiOperationDtosDatas
  6750. patientDtosinputData["patn_id"] = pd.PatnID
  6751. patientDtosinputData["patn_name"] = pd.PatnName
  6752. patientDtosinputData["gend"] = pd.Gend
  6753. patientDtosinputData["brdy"] = pd.Brdy
  6754. patientDtosinputData["poolarea"] = pd.Poolarea
  6755. patientDtosinputData["curr_mdtrt_id"] = pd.CurrMdtrtID
  6756. patientDtosinputData["fsi_his_data_dto"] = ""
  6757. patientDtosinputData["fsi_encounter_dtos"] = fisEncounterDtosData
  6758. inputData["syscode"] = "LinkDialysis"
  6759. inputData["trig_scen"] = trig_scen
  6760. inputData["rule_ids"] = ""
  6761. inputData["task_id"] = ""
  6762. inputData["patient_dtos"] = patientDtosinputData
  6763. input["data"] = inputData
  6764. inputMessage["infno"] = "3101"
  6765. inputMessage["input"] = input //交易输入
  6766. bytesData, err := json.Marshal(inputMessage)
  6767. fmt.Println(string(bytesData))
  6768. if err != nil {
  6769. fmt.Println(err.Error())
  6770. return err.Error(), ""
  6771. }
  6772. reader := bytes.NewReader(bytesData)
  6773. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6774. gdyb_url := beego.AppConfig.String("gdyb_url")
  6775. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6776. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6777. url := gdyb_url + "3101"
  6778. request, err := http.NewRequest("POST", url, reader)
  6779. if err != nil {
  6780. fmt.Println(err.Error())
  6781. return err.Error(), ""
  6782. }
  6783. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6784. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6785. request.Header.Set("x-tif-signature", signature)
  6786. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6787. request.Header.Set("x-tif-nonce", nonce)
  6788. client := http.Client{}
  6789. resp, err := client.Do(request)
  6790. if err != nil {
  6791. fmt.Println(err.Error())
  6792. return err.Error(), ""
  6793. }
  6794. respBytes, err := ioutil.ReadAll(resp.Body)
  6795. if err != nil {
  6796. fmt.Println(err.Error())
  6797. return err.Error(), ""
  6798. }
  6799. str := string(respBytes)
  6800. fmt.Println(str)
  6801. return str, string(bytesData)
  6802. }
  6803. 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) {
  6804. nonce := GetRandomString(32)
  6805. timestamp := time.Now().Unix()
  6806. signature := setSignature(timestamp, nonce, params.SecretKey)
  6807. // 生成输入报文
  6808. inputMessage := SetGdInputMessage(timestamp, params.FixmedinsName, params.OpterName, params.FixmedinsCode, params.InsuplcAdmdvs, params.MdtrtareaAdmvs, params.Cainfo)
  6809. input := make(map[string]interface{})
  6810. inputData := make(map[string]interface{})
  6811. patientDtosinputData := make(map[string]interface{})
  6812. fisEncounterDtosData := make(map[string]interface{})
  6813. fsiDiagnoseDtosDatas := make([]map[string]interface{}, 0)
  6814. fsiOrderDtosDatas := make([]map[string]interface{}, 0)
  6815. fsiOperationDtosData := make(map[string]interface{})
  6816. fsiOperationDtosDatas := make([]map[string]interface{}, 0)
  6817. //就诊信息
  6818. fisEncounterDtosData["mdtrt_id"] = fed.MdtrtID
  6819. fisEncounterDtosData["medins_id"] = fed.MedinsID
  6820. fisEncounterDtosData["medins_name"] = fed.MedinsName
  6821. fisEncounterDtosData["medins_admdvs"] = fed.MedinsAdmdvs
  6822. fisEncounterDtosData["medins_type"] = fed.MedinsType
  6823. fisEncounterDtosData["medins_lv"] = fed.MedinsLv
  6824. fisEncounterDtosData["wardarea_codg"] = fed.WardareaCodg
  6825. fisEncounterDtosData["wardno"] = fed.Wardno
  6826. fisEncounterDtosData["bedno"] = fed.Bedno
  6827. fisEncounterDtosData["adm_date"] = fed.AdmDate
  6828. fisEncounterDtosData["dscg_date"] = fed.DscgDate
  6829. fisEncounterDtosData["dscg_main_dise_codg"] = fed.DscgMainDiseCodg
  6830. fisEncounterDtosData["dscg_main_dise_name"] = fed.DscgMainDiseName
  6831. for _, fdd := range fdds {
  6832. fsiDiagnoseDtosData := make(map[string]interface{})
  6833. //诊断集合
  6834. fsiDiagnoseDtosData["dise_id"] = fdd.DiseID
  6835. fsiDiagnoseDtosData["inout_dise_type"] = fdd.InoutDiseType
  6836. fsiDiagnoseDtosData["maindise_flag"] = fdd.MaindiseFlag
  6837. fsiDiagnoseDtosData["dias_srt_no"] = fdd.DiasSrtNo
  6838. fsiDiagnoseDtosData["dise_codg"] = fdd.DiseCodg
  6839. fsiDiagnoseDtosData["dise_name"] = fdd.DiseName
  6840. fsiDiagnoseDtosData["dise_date"] = fdd.DiseDate
  6841. fsiDiagnoseDtosDatas = append(fsiDiagnoseDtosDatas, fsiDiagnoseDtosData)
  6842. }
  6843. fisEncounterDtosData["fsi_diagnose_dtos"] = fsiDiagnoseDtosDatas
  6844. fisEncounterDtosData["dr_codg"] = fed.DrCodg
  6845. fisEncounterDtosData["adm_dept_codg"] = fed.AdmDeptCodg
  6846. fisEncounterDtosData["adm_dept_name"] = fed.AdmDeptName
  6847. fisEncounterDtosData["dscg_dept_codg"] = fed.DscgDeptCodg
  6848. fisEncounterDtosData["dscg_dept_name"] = fed.DscgDeptName
  6849. fisEncounterDtosData["med_mdtrt_type"] = fed.MedMdtrtType
  6850. fisEncounterDtosData["med_type"] = fed.MedType
  6851. for _, fod := range fods {
  6852. fsiOrderDtosData := make(map[string]interface{})
  6853. //医嘱集合
  6854. fsiOrderDtosData["rx_id"] = fod.RxID
  6855. fsiOrderDtosData["rxno"] = fod.Rxno
  6856. fsiOrderDtosData["grpno"] = fod.Grpno
  6857. fsiOrderDtosData["long_drord_flag"] = fod.LongDrordFlag
  6858. fsiOrderDtosData["hilist_type"] = fod.HilistType
  6859. fsiOrderDtosData["chrg_type"] = fod.ChrgType
  6860. fsiOrderDtosData["drord_bhvr"] = fod.DrordBhvr
  6861. fsiOrderDtosData["hilist_code"] = fod.HosplistCode
  6862. fsiOrderDtosData["hilist_name"] = fod.HosplistName
  6863. fsiOrderDtosData["hilist_dosform"] = fod.HilistDosform
  6864. fsiOrderDtosData["hilist_lv"] = fod.HilistLv
  6865. fsiOrderDtosData["hilist_pric"] = fod.HilistPric
  6866. fsiOrderDtosData["lv1_hosp_item_pric"] = fod.Lv1HospItemPric
  6867. fsiOrderDtosData["lv2_hosp_item_pric"] = fod.Lv2HospItemPric
  6868. fsiOrderDtosData["lv3_hosp_item_pric"] = fod.Lv3HospItemPric
  6869. fsiOrderDtosData["hilist_memo"] = fod.HilistMemo
  6870. fsiOrderDtosData["hosplist_code"] = fod.HosplistCode
  6871. fsiOrderDtosData["hosplist_name"] = fod.HosplistName
  6872. fsiOrderDtosData["hosplist_dosform"] = fod.HosplistDosform
  6873. fsiOrderDtosData["cnt"] = fod.Cnt
  6874. fsiOrderDtosData["pric"] = fod.Pric
  6875. fsiOrderDtosData["sumamt"] = fod.Sumamt
  6876. fsiOrderDtosData["ownpay_amt"] = fod.OwnpayAmt
  6877. fsiOrderDtosData["selfpay_amt"] = fod.SelfpayAmt
  6878. fsiOrderDtosData["spec"] = fod.Spec
  6879. fsiOrderDtosData["spec_unt"] = fod.SpecUnt
  6880. fsiOrderDtosData["drord_begn_date"] = fod.DrordBegnDate
  6881. fsiOrderDtosData["drord_stop_date"] = fod.DrordStopDate
  6882. fsiOrderDtosData["drord_dept_codg"] = fod.DrordDeptCodg
  6883. fsiOrderDtosData["drord_dept_name"] = fod.DrordDeptName
  6884. fsiOrderDtosData["drord_dr_codg"] = fod.DrordDrCodg
  6885. fsiOrderDtosData["drord_dr_name"] = fod.DrordDrName
  6886. fsiOrderDtosData["drord_dr_profttl"] = fod.DrordDrProfttl
  6887. fsiOrderDtosData["curr_drord_flag"] = fod.CurrDrordFlag
  6888. fsiOrderDtosDatas = append(fsiOrderDtosDatas, fsiOrderDtosData)
  6889. }
  6890. fisEncounterDtosData["fsi_order_dtos"] = fsiOrderDtosDatas
  6891. fisEncounterDtosData["matn_stas"] = fed.MatnStas
  6892. fisEncounterDtosData["medfee_sumamt"] = fed.MedfeeSumamt
  6893. fisEncounterDtosData["ownpay_amt"] = fed.OwnpayAmt
  6894. fisEncounterDtosData["selfpay_amt"] = fed.SelfpayAmt
  6895. fisEncounterDtosData["acct_payamt"] = fed.AcctPayamt
  6896. fisEncounterDtosData["ma_amt"] = fed.MaAmt
  6897. fisEncounterDtosData["hifp_payamt"] = fed.HifpPayamt
  6898. fisEncounterDtosData["setl_totlnum"] = fed.SetlTotlnum
  6899. fisEncounterDtosData["insutype"] = fed.Insutype
  6900. fisEncounterDtosData["reim_flag"] = fed.ReimFlag
  6901. fisEncounterDtosData["out_setl_flag"] = fed.OutSetlFlag
  6902. //手术操作
  6903. for _, fopd := range fopds {
  6904. fsiOperationDtosData["setl_list_oprn_id"] = fopd.Setl_list_oprn_id
  6905. fsiOperationDtosData["oprn_code"] = fopd.Oprn_code
  6906. fsiOperationDtosData["oprn_name"] = fopd.Oprn_name
  6907. fsiOperationDtosData["main_oprn_flag"] = fopd.Main_oprn_flag
  6908. fsiOperationDtosData["oprn_date"] = fopd.Oprn_date
  6909. fsiOperationDtosData["anst_way"] = fopd.Anst_way
  6910. fsiOperationDtosData["oper_dr_name"] = fopd.Oper_dr_name
  6911. fsiOperationDtosData["oper_dr_code"] = fopd.Oper_dr_code
  6912. fsiOperationDtosData["anst_dr_name"] = fopd.Anst_dr_name
  6913. fsiOperationDtosData["anst_dr_code"] = fopd.Anst_dr_code
  6914. fsiOperationDtosDatas = append(fsiOperationDtosDatas, fsiOperationDtosData)
  6915. }
  6916. fisEncounterDtosData["fsi_operation_dtos"] = fsiOperationDtosDatas
  6917. patientDtosinputData["patn_id"] = pd.PatnID
  6918. patientDtosinputData["patn_name"] = pd.PatnName
  6919. patientDtosinputData["gend"] = pd.Gend
  6920. patientDtosinputData["brdy"] = pd.Brdy
  6921. patientDtosinputData["poolarea"] = pd.Poolarea
  6922. patientDtosinputData["curr_mdtrt_id"] = pd.CurrMdtrtID
  6923. patientDtosinputData["fsi_his_data_dto"] = ""
  6924. patientDtosinputData["fsi_encounter_dtos"] = fisEncounterDtosData
  6925. inputData["syscode"] = "LinkDialysis"
  6926. inputData["trig_scen"] = trig_scen
  6927. inputData["rule_ids"] = ""
  6928. inputData["task_id"] = ""
  6929. inputData["patient_dtos"] = patientDtosinputData
  6930. input["data"] = inputData
  6931. inputMessage["infno"] = "3102"
  6932. inputMessage["input"] = input //交易输入
  6933. bytesData, err := json.Marshal(inputMessage)
  6934. fmt.Println(string(bytesData))
  6935. if err != nil {
  6936. fmt.Println(err.Error())
  6937. return err.Error(), ""
  6938. }
  6939. reader := bytes.NewReader(bytesData)
  6940. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6941. gdyb_url := beego.AppConfig.String("gdyb_url")
  6942. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6943. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6944. url := gdyb_url + "3102"
  6945. request, err := http.NewRequest("POST", url, reader)
  6946. if err != nil {
  6947. fmt.Println(err.Error())
  6948. return err.Error(), ""
  6949. }
  6950. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6951. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6952. request.Header.Set("x-tif-signature", signature)
  6953. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6954. request.Header.Set("x-tif-nonce", nonce)
  6955. client := http.Client{}
  6956. resp, err := client.Do(request)
  6957. if err != nil {
  6958. fmt.Println(err.Error())
  6959. return err.Error(), ""
  6960. }
  6961. respBytes, err := ioutil.ReadAll(resp.Body)
  6962. if err != nil {
  6963. fmt.Println(err.Error())
  6964. return err.Error(), ""
  6965. }
  6966. str := string(respBytes)
  6967. fmt.Println(str)
  6968. return str, string(bytesData)
  6969. }
  6970. // 分页函数
  6971. func paginate(data []map[string]interface{}, pageSize int) [][]map[string]interface{} {
  6972. var pages [][]map[string]interface{}
  6973. totalItems := len(data)
  6974. for i := 0; i < totalItems; i += pageSize {
  6975. end := i + pageSize
  6976. if end > totalItems {
  6977. end = totalItems
  6978. }
  6979. pages = append(pages, data[i:end])
  6980. }
  6981. return pages
  6982. }