gdyb_service.go 251KB

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