gdyb_service.go 235KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137
  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. if org_id == 10138 {
  2598. inputData["dscg_way"] = "9" // 民族 必填
  2599. inputData["resp_nurs_code"] = "N441623001432" // 民族 必填
  2600. }
  2601. inputData["patn_cert_type"] = struct4101.PatnCertType // 患者证件类别 必填
  2602. inputData["certno"] = struct4101.Certno // 证件号码 必填
  2603. inputData["prfs"] = struct4101.Prfs // 职业 必填
  2604. inputData["curr_addr"] = "" // 现住址 必填
  2605. inputData["emp_name"] = "" // 单位名称 必填
  2606. inputData["emp_addr"] = "" // 单位地址 必填
  2607. inputData["emp_tel"] = "" // 单位电话 必填
  2608. inputData["poscode"] = "" // 邮编 必填
  2609. inputData["coner_name"] = struct4101.ConerName // 联系人姓名 必填
  2610. inputData["patn_rlts"] = struct4101.PatnRlts // 与患者关系 必填
  2611. inputData["coner_addr"] = struct4101.ConerAddr // 联系人地址 必填
  2612. inputData["coner_tel"] = struct4101.ConerTel // 联系人电话 必填
  2613. inputData["hi_type"] = struct4101.HiType // 医保类型 必填
  2614. inputData["insuplc"] = struct4101.Insuplc // 参保地 必填
  2615. inputData["sp_psn_type"] = "" // 特殊人员类型 必填
  2616. inputData["nwb_adm_type"] = "" // 新生儿入院类型 必填
  2617. inputData["nwb_bir_wt"] = "" // 新生儿出生体重 必填
  2618. inputData["nwb_adm_wt"] = "" // 新生儿入院体重 必填
  2619. inputData["opsp_diag_caty"] = "" // 门诊慢特病诊断 必填
  2620. inputData["opsp_mdtrt_date"] = "" // 门诊慢特病就诊日期 必填
  2621. inputData["ipt_med_type"] = "" // 住院医疗类型 必填
  2622. inputData["adm_way"] = "" // 入院途径 必填
  2623. inputData["trt_type"] = "10" // 治疗类别 必填
  2624. inputData["adm_time"] = "" // 入院时间 必填
  2625. inputData["adm_caty"] = "A03.06" // 入院科别 必填
  2626. inputData["refldept_dept"] = "" // 转科科别 必填
  2627. inputData["dscg_time"] = "" // 出院时间 必填
  2628. inputData["dscg_caty"] = "A03.06" // 出院科别 必填
  2629. inputData["caty"] = "A03.06" // 出院科别 必填
  2630. inputData["act_ipt_days"] = "" // 实际住院天数 必填
  2631. inputData["otp_wm_dise"] = "" // 门(急) 诊西医诊断 必填
  2632. inputData["wm_dise_code"] = "" // 门(急) 诊中医诊断 必填
  2633. inputData["otp_tcm_dise"] = "" // 西医诊断疾病代码 必填
  2634. inputData["tcm_dise_code"] = "" // 中医诊断代码 必填
  2635. inputData["oprn_oprt_code_cnt"] = "" // 手术操作代码计数 必填
  2636. inputData["vent_used_dura"] = "" // 呼吸机使用时长 必填
  2637. inputData["pwcry_bfadm_coma_dura"] = "" // 颅脑损伤患者入院前昏迷时长 必填
  2638. inputData["pwcry_afadm_coma_dura"] = "" // 颅脑损伤患者入院后昏迷时长 必填
  2639. inputData["bld_cat"] = "" // 输血品种 必填
  2640. inputData["bld_amt"] = "" // 输血量 必填
  2641. inputData["bld_unt"] = "" // 输血计量单位 必填
  2642. inputData["spga_nurscare_days"] = "" // 特级护理天数 必填
  2643. inputData["lv1_nurscare_days"] = "" // 一级护理天数 必填
  2644. inputData["scd_nurscare_days"] = "" // 二级护理天数 必填
  2645. inputData["lv3_nurscare_days"] = "" // 三级护理天数 必填
  2646. inputData["acp_medins_name"] = "" // 拟接收机构名称 必填
  2647. inputData["acp_optins_code"] = "" // 拟接收机构代码 必填
  2648. inputData["bill_code"] = struct4101.BillCode // 票据代码 必填
  2649. inputData["bill_no"] = struct4101.BillNo // 票据号码 必填
  2650. inputData["biz_sn"] = struct4101.BizSn // 业务流水号 必填
  2651. inputData["days_rinp_flag_31"] = "" // 出院 31 天内再住院计划标志 必填
  2652. inputData["days_rinp_pup_31"] = "" // 出院 31 天内再住院目的 必填
  2653. inputData["chfpdr_name"] = struct4101.DoctorName // 主诊医师姓名 必填
  2654. inputData["chfpdr_code"] = struct4101.DoctorCode // 主诊医师代码 必填
  2655. inputData["setl_begn_date"] = struct4101.SetlBegnDate // 结算开始日期 必填
  2656. inputData["setl_end_date"] = struct4101.SetlEndDate // 结算结束日期 必填
  2657. inputData["psn_selfpay"] = struct4101.PsnSelfPay // 个人自付 必填
  2658. inputData["psn_ownpay"] = struct4101.PsnOwnPay // 个人自费 必填
  2659. inputData["acct_pay"] = struct4101.AcctPay // 个人账户支出 必填
  2660. inputData["hi_paymtd"] = struct4101.HiPaymtd // 医保支付方式 必填
  2661. inputData["hsorg"] = struct4101.Hsorg // 医保机构 必填
  2662. inputData["hsorg_opter"] = struct4101.HsorgOpter // 医保机构经办人 必填
  2663. inputData["medins_fill_dept"] = struct4101.MedinsFillDept // 医疗机构填报部门 必填
  2664. inputData["medins_fill_psn"] = struct4101.MedinsFillPsn // 医疗机构填报人 必填
  2665. inputData["psn_cashpay"] = struct4101.PsnCashpay // 医疗机构填报人 必填
  2666. payinfo := make([]map[string]interface{}, 0) // 基金支付信息
  2667. for _, item := range struct4101.CustomStruct {
  2668. payinfotemp := make(map[string]interface{})
  2669. 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" {
  2670. payinfotemp["fund_pay_type"] = item.FundPayType // 基金支付类型 必填
  2671. payinfotemp["fund_payamt"] = item.FundPayamt // 基金支付金额
  2672. payinfo = append(payinfo, payinfotemp)
  2673. }
  2674. }
  2675. opspdiseinfo := make([]map[string]interface{}, 0) // 门诊慢特病诊断信息
  2676. opspdiseinfotemp := make(map[string]interface{})
  2677. opspdiseinfotemp["diag_name"] = struct4101.Diseinfo[len(struct4101.Diseinfo)-1].DiagName // 诊断名称 必填
  2678. opspdiseinfotemp["diag_code"] = struct4101.Diseinfo[len(struct4101.Diseinfo)-1].DiagCode // 诊断代码 必填
  2679. opspdiseinfotemp["oprn_oprt_name"] = "血液透析" // 手术操作名称 必填
  2680. opspdiseinfotemp["oprn_oprt_code"] = "39.9500" // 手术操作代码 必填
  2681. opspdiseinfo = append(opspdiseinfo, opspdiseinfotemp)
  2682. diseinfo := make([]map[string]interface{}, 0) // 住院诊断信息
  2683. //for _, item := range struct4101.Diseinfo {
  2684. // diseinfotemp := make(map[string]interface{})
  2685. // diseinfotemp["maindiag_flag"] = item.MaindiagFlag // 手术操作代码 必填
  2686. // diseinfotemp["diag_type"] = item.DiagType // 诊断类别 必填
  2687. // diseinfotemp["diag_code"] = item.DiagCode // 诊断代码 必填
  2688. // diseinfotemp["diag_name"] = item.DiagName // 诊断名称 必填
  2689. // diseinfotemp["adm_cond_type"] = "3" // 入院病情类型 必填
  2690. // diseinfo = append(diseinfo, diseinfotemp)
  2691. //}
  2692. iteminfo := make([]map[string]interface{}, 0)
  2693. for _, item := range struct4101.IteminfoStruct {
  2694. iteminfotemp := make(map[string]interface{})
  2695. iteminfotemp["med_chrgitm"] = item.MedChrgitm // 医疗收费项目 必填
  2696. iteminfotemp["amt"] = item.Amt // 金额 必填
  2697. iteminfotemp["claa_sumfee"] = item.ClaaSumfee // 甲类费用合计 必填
  2698. iteminfotemp["clab_amt"] = item.ClabAmt // 乙类金额 必填
  2699. iteminfotemp["fulamt_ownpay_amt"] = item.FulamtOwnpayAmt // 全自费金额 必填
  2700. iteminfotemp["oth_amt"] = item.OthAmt // 其他金额 必填
  2701. iteminfo = append(iteminfo, iteminfotemp)
  2702. }
  2703. oprninfo := make([]map[string]interface{}, 0) // 手术操作信息
  2704. oprninfotemp := make(map[string]interface{})
  2705. oprninfotemp["oprn_oprt_type"] = "" // 手术操作类别 必填
  2706. oprninfotemp["oprn_oprt_name"] = "" // 手术操作名称 必填
  2707. oprninfotemp["oprn_oprt_code"] = "" // 手术操作代码 必填
  2708. oprninfotemp["oprn_oprt_date"] = "" // 手术操作日期 必填
  2709. oprninfotemp["anst_way"] = "" // 麻醉方式 必填
  2710. oprninfotemp["oper_dr_name"] = "" // 术者医师姓名 必填
  2711. oprninfotemp["oper_dr_code"] = "" // 术者医师代码 必填
  2712. oprninfotemp["anst_dr_name"] = "" // 麻醉医师姓名 必填
  2713. oprninfotemp["anst_dr_code"] = "" // 麻醉医师代码 必填
  2714. oprninfo = append(oprninfo, oprninfotemp)
  2715. icuinfo := make([]map[string]interface{}, 0) // 重症监护信息
  2716. icuinfotemp := make(map[string]interface{})
  2717. icuinfotemp["scs_cutd_ward_type"] = "" // 重症监护病房类型 必填
  2718. icuinfotemp["scs_cutd_inpool_time"] = "" // 重症监护进入时间 必填
  2719. icuinfotemp["scs_cutd_exit_time"] = "" // 重症监护退出时间 必填
  2720. icuinfotemp["scs_cutd_sum_dura"] = "" // 重症监护合计时长 必填
  2721. icuinfo = append(icuinfo, icuinfotemp)
  2722. input["setlinfo"] = inputData
  2723. input["payinfo"] = payinfo
  2724. input["opspdiseinfo"] = opspdiseinfo
  2725. input["diseinfo"] = diseinfo
  2726. input["iteminfo"] = iteminfo
  2727. inputMessage["input"] = input //交易输入
  2728. bytesData, err := json.Marshal(inputMessage)
  2729. fmt.Println(string(bytesData))
  2730. if err != nil {
  2731. fmt.Println(err.Error())
  2732. return err.Error(), ""
  2733. }
  2734. reader := bytes.NewReader(bytesData)
  2735. gdyb_url := beego.AppConfig.String("gdyb_url")
  2736. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2737. //url := gdyb_url + "4101"
  2738. var url string
  2739. if fixmedins_code == "H15049901371" {
  2740. url = gdyb_url
  2741. } else {
  2742. url = gdyb_url + "4101A"
  2743. }
  2744. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/4101"
  2745. request, err := http.NewRequest("POST", url, reader)
  2746. if err != nil {
  2747. fmt.Println(err.Error())
  2748. return err.Error(), ""
  2749. }
  2750. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2751. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2752. request.Header.Set("x-tif-signature", signature)
  2753. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2754. request.Header.Set("x-tif-nonce", nonce)
  2755. client := http.Client{}
  2756. resp, err := client.Do(request)
  2757. if err != nil {
  2758. fmt.Println(err.Error())
  2759. return err.Error(), ""
  2760. }
  2761. respBytes, err := ioutil.ReadAll(resp.Body)
  2762. if err != nil {
  2763. fmt.Println(err.Error())
  2764. return err.Error(), ""
  2765. }
  2766. str := string(respBytes)
  2767. fmt.Println(str)
  2768. return str, string(bytesData)
  2769. }
  2770. 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) {
  2771. // 生成签名
  2772. nonce := GetRandomString(32)
  2773. timestamp := time.Now().Unix()
  2774. signature := setSignature(timestamp, nonce, secret_key)
  2775. // 生成输入报文
  2776. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2777. input := make(map[string]interface{})
  2778. inputData := make(map[string]interface{})
  2779. inputMessage["infno"] = "4101A" // 交易编码
  2780. year := time.Now().Format("2006")
  2781. month := time.Now().Format("01")
  2782. day := time.Now().Format("02")
  2783. inputData["mdtrt_id"] = struct4101.MdtrtId // 就诊 ID 必填(来自2201接口返回)
  2784. inputData["setl_id"] = struct4101.SetlId // 结算 ID 必填
  2785. inputData["psn_no"] = struct4101.PsnNo // 结算 ID 必填
  2786. inputData["fixmedins_name"] = org_name // 定点医药机构名称 必填
  2787. inputData["fixmedins_code"] = fixmedins_code // 定点医药机构编码 必填
  2788. inputData["hi_setl_lv"] = "" // 医保结算等级
  2789. inputData["hi_no"] = struct4101.PsnNo // 医保编号
  2790. inputData["medcasno"] = struct4101.PsnNo // 病案号 必填
  2791. inputData["dcla_time"] = year + "-" + month + "-" + day // 申报时间 必填
  2792. inputData["psn_name"] = struct4101.PsnName // 人员姓名 必填
  2793. inputData["gend"] = struct4101.Gend // 性别 必填
  2794. inputData["brdy"] = struct4101.Brdy // 出生日期 必填
  2795. inputData["age"] = struct4101.Age // 年龄 必填
  2796. inputData["ntly"] = struct4101.Ntly // 国籍 必填
  2797. inputData["nwb_age"] = "" // 年龄 必填
  2798. inputData["naty"] = struct4101.Naty // 民族 必填
  2799. inputData["patn_cert_type"] = struct4101.PatnCertType // 患者证件类别 必填
  2800. inputData["certno"] = struct4101.Certno // 证件号码 必填
  2801. inputData["prfs"] = struct4101.Prfs // 职业 必填
  2802. inputData["curr_addr"] = "" // 现住址 必填
  2803. inputData["emp_name"] = "" // 单位名称 必填
  2804. inputData["emp_addr"] = "" // 单位地址 必填
  2805. inputData["emp_tel"] = "" // 单位电话 必填
  2806. inputData["poscode"] = "" // 邮编 必填
  2807. inputData["coner_name"] = struct4101.ConerName // 联系人姓名 必填
  2808. inputData["patn_rlts"] = struct4101.PatnRlts // 与患者关系 必填
  2809. inputData["coner_addr"] = struct4101.ConerAddr // 联系人地址 必填
  2810. inputData["coner_tel"] = struct4101.ConerTel // 联系人电话 必填
  2811. inputData["hi_type"] = struct4101.HiType // 医保类型 必填
  2812. inputData["insuplc"] = struct4101.Insuplc // 参保地 必填
  2813. inputData["sp_psn_type"] = "" // 特殊人员类型 必填
  2814. inputData["nwb_adm_type"] = "" // 新生儿入院类型 必填
  2815. inputData["nwb_bir_wt"] = "" // 新生儿出生体重 必填
  2816. inputData["nwb_adm_wt"] = "" // 新生儿入院体重 必填
  2817. inputData["opsp_diag_caty"] = "" // 门诊慢特病诊断 必填
  2818. inputData["opsp_mdtrt_date"] = "" // 门诊慢特病就诊日期 必填
  2819. inputData["ipt_med_type"] = "" // 住院医疗类型 必填
  2820. inputData["adm_way"] = "" // 入院途径 必填
  2821. inputData["trt_type"] = "10" // 治疗类别 必填
  2822. inputData["adm_time"] = struct4101.AdmTime // 入院时间 必填
  2823. inputData["adm_caty"] = struct4101.AdmCaty // 入院科别 必填
  2824. inputData["refldept_dept"] = "" // 转科科别 必填
  2825. inputData["dscg_time"] = struct4101.AdmEndTime // 出院时间 必填
  2826. inputData["dscg_caty"] = struct4101.DscgCaty // 出院科别 必填
  2827. inputData["act_ipt_days"] = "" // 实际住院天数 必填
  2828. inputData["otp_wm_dise"] = "" // 门(急) 诊西医诊断 必填
  2829. inputData["wm_dise_code"] = "" // 门(急) 诊中医诊断 必填
  2830. inputData["otp_tcm_dise"] = "" // 西医诊断疾病代码 必填
  2831. inputData["tcm_dise_code"] = "" // 中医诊断代码 必填
  2832. inputData["oprn_oprt_code_cnt"] = "" // 手术操作代码计数 必填
  2833. inputData["vent_used_dura"] = "" // 呼吸机使用时长 必填
  2834. inputData["pwcry_bfadm_coma_dura"] = "" // 颅脑损伤患者入院前昏迷时长 必填
  2835. inputData["pwcry_afadm_coma_dura"] = "" // 颅脑损伤患者入院后昏迷时长 必填
  2836. inputData["bld_cat"] = "" // 输血品种 必填
  2837. inputData["bld_amt"] = "" // 输血量 必填
  2838. inputData["bld_unt"] = "" // 输血计量单位 必填
  2839. inputData["spga_nurscare_days"] = "" // 特级护理天数 必填
  2840. inputData["lv1_nurscare_days"] = "" // 一级护理天数 必填
  2841. inputData["scd_nurscare_days"] = "" // 二级护理天数 必填
  2842. inputData["lv3_nurscare_days"] = "" // 三级护理天数 必填
  2843. inputData["acp_medins_name"] = "" // 拟接收机构名称 必填
  2844. inputData["acp_optins_code"] = "" // 拟接收机构代码 必填
  2845. inputData["bill_code"] = struct4101.BillCode // 票据代码 必填
  2846. inputData["bill_no"] = struct4101.BillNo // 票据号码 必填
  2847. inputData["biz_sn"] = struct4101.BizSn // 业务流水号 必填
  2848. inputData["days_rinp_flag_31"] = "" // 出院 31 天内再住院计划标志 必填
  2849. inputData["days_rinp_pup_31"] = "" // 出院 31 天内再住院目的 必填
  2850. inputData["chfpdr_name"] = struct4101.DoctorName // 主诊医师姓名 必填
  2851. inputData["chfpdr_code"] = struct4101.DoctorCode // 主诊医师代码 必填
  2852. inputData["setl_begn_date"] = struct4101.SetlBegnDate // 结算开始日期 必填
  2853. inputData["setl_end_date"] = struct4101.SetlEndDate // 结算结束日期 必填
  2854. inputData["psn_selfpay"] = struct4101.PsnSelfPay // 个人自付 必填
  2855. inputData["psn_ownpay"] = struct4101.PsnOwnPay // 个人自费 必填
  2856. inputData["acct_pay"] = struct4101.AcctPay // 个人账户支出 必填
  2857. inputData["hi_paymtd"] = struct4101.HiPaymtd // 医保支付方式 必填
  2858. inputData["hsorg"] = struct4101.Hsorg // 医保机构 必填
  2859. inputData["hsorg_opter"] = struct4101.HsorgOpter // 医保机构经办人 必填
  2860. inputData["medins_fill_dept"] = struct4101.MedinsFillDept // 医疗机构填报部门 必填
  2861. inputData["medins_fill_psn"] = struct4101.MedinsFillPsn // 医疗机构填报人 必填
  2862. inputData["psn_cashpay"] = struct4101.PsnCashpay // 医疗机构填报人 必填
  2863. payinfo := make([]map[string]interface{}, 0) // 基金支付信息
  2864. for _, item := range struct4101.CustomStruct {
  2865. payinfotemp := make(map[string]interface{})
  2866. 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" {
  2867. payinfotemp["fund_pay_type"] = item.FundPayType // 基金支付类型 必填
  2868. payinfotemp["fund_payamt"] = item.FundPayamt // 基金支付金额
  2869. payinfo = append(payinfo, payinfotemp)
  2870. }
  2871. }
  2872. opspdiseinfo := make([]map[string]interface{}, 0) // 门诊慢特病诊断信息
  2873. opspdiseinfotemp := make(map[string]interface{})
  2874. opspdiseinfotemp["diag_name"] = struct4101.Diseinfo[len(struct4101.Diseinfo)-1].DiagName // 诊断名称 必填
  2875. opspdiseinfotemp["diag_code"] = struct4101.Diseinfo[len(struct4101.Diseinfo)-1].DiagCode // 诊断代码 必填
  2876. opspdiseinfotemp["oprn_oprt_name"] = "血液透析" // 手术操作名称 必填
  2877. opspdiseinfotemp["oprn_oprt_code"] = "39.9500" // 手术操作代码 必填
  2878. opspdiseinfo = append(opspdiseinfo, opspdiseinfotemp)
  2879. diseinfo := make([]map[string]interface{}, 0) // 住院诊断信息
  2880. for _, item := range struct4101.Diseinfo {
  2881. diseinfotemp := make(map[string]interface{})
  2882. diseinfotemp["maindiag_flag"] = item.MaindiagFlag // 手术操作代码 必填
  2883. diseinfotemp["diag_type"] = item.DiagType // 诊断类别 必填
  2884. diseinfotemp["diag_code"] = item.DiagCode // 诊断代码 必填
  2885. diseinfotemp["diag_name"] = item.DiagName // 诊断名称 必填
  2886. diseinfotemp["adm_cond_type"] = "3" // 入院病情类型 必填
  2887. diseinfo = append(diseinfo, diseinfotemp)
  2888. }
  2889. iteminfo := make([]map[string]interface{}, 0)
  2890. for _, item := range struct4101.IteminfoStruct {
  2891. iteminfotemp := make(map[string]interface{})
  2892. iteminfotemp["med_chrgitm"] = item.MedChrgitm // 医疗收费项目 必填
  2893. iteminfotemp["amt"] = item.Amt // 金额 必填
  2894. iteminfotemp["claa_sumfee"] = item.ClaaSumfee // 甲类费用合计 必填
  2895. iteminfotemp["clab_amt"] = item.ClabAmt // 乙类金额 必填
  2896. iteminfotemp["fulamt_ownpay_amt"] = item.FulamtOwnpayAmt // 全自费金额 必填
  2897. iteminfotemp["oth_amt"] = item.OthAmt // 其他金额 必填
  2898. iteminfo = append(iteminfo, iteminfotemp)
  2899. }
  2900. oprninfo := make([]map[string]interface{}, 0) // 手术操作信息
  2901. oprninfotemp := make(map[string]interface{})
  2902. oprninfotemp["oprn_oprt_type"] = "" // 手术操作类别 必填
  2903. oprninfotemp["oprn_oprt_name"] = "" // 手术操作名称 必填
  2904. oprninfotemp["oprn_oprt_code"] = "" // 手术操作代码 必填
  2905. oprninfotemp["oprn_oprt_date"] = "" // 手术操作日期 必填
  2906. oprninfotemp["anst_way"] = "" // 麻醉方式 必填
  2907. oprninfotemp["oper_dr_name"] = "" // 术者医师姓名 必填
  2908. oprninfotemp["oper_dr_code"] = "" // 术者医师代码 必填
  2909. oprninfotemp["anst_dr_name"] = "" // 麻醉医师姓名 必填
  2910. oprninfotemp["anst_dr_code"] = "" // 麻醉医师代码 必填
  2911. oprninfo = append(oprninfo, oprninfotemp)
  2912. icuinfo := make([]map[string]interface{}, 0) // 重症监护信息
  2913. icuinfotemp := make(map[string]interface{})
  2914. icuinfotemp["scs_cutd_ward_type"] = "" // 重症监护病房类型 必填
  2915. icuinfotemp["scs_cutd_inpool_time"] = "" // 重症监护进入时间 必填
  2916. icuinfotemp["scs_cutd_exit_time"] = "" // 重症监护退出时间 必填
  2917. icuinfotemp["scs_cutd_sum_dura"] = "" // 重症监护合计时长 必填
  2918. icuinfo = append(icuinfo, icuinfotemp)
  2919. input["setlinfo"] = inputData
  2920. input["payinfo"] = payinfo
  2921. input["opspdiseinfo"] = opspdiseinfo
  2922. input["diseinfo"] = diseinfo
  2923. input["iteminfo"] = iteminfo
  2924. inputMessage["input"] = input //交易输入
  2925. bytesData, err := json.Marshal(inputMessage)
  2926. fmt.Println(string(bytesData))
  2927. if err != nil {
  2928. fmt.Println(err.Error())
  2929. return err.Error(), ""
  2930. }
  2931. reader := bytes.NewReader(bytesData)
  2932. gdyb_url := beego.AppConfig.String("gdyb_url")
  2933. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2934. //url := gdyb_url + "4101"
  2935. var url string
  2936. if fixmedins_code == "H15049901371" {
  2937. url = gdyb_url
  2938. } else {
  2939. url = gdyb_url + "4101A"
  2940. }
  2941. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/4101"
  2942. request, err := http.NewRequest("POST", url, reader)
  2943. if err != nil {
  2944. fmt.Println(err.Error())
  2945. return err.Error(), ""
  2946. }
  2947. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2948. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2949. request.Header.Set("x-tif-signature", signature)
  2950. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2951. request.Header.Set("x-tif-nonce", nonce)
  2952. client := http.Client{}
  2953. resp, err := client.Do(request)
  2954. if err != nil {
  2955. fmt.Println(err.Error())
  2956. return err.Error(), ""
  2957. }
  2958. respBytes, err := ioutil.ReadAll(resp.Body)
  2959. if err != nil {
  2960. fmt.Println(err.Error())
  2961. return err.Error(), ""
  2962. }
  2963. str := string(respBytes)
  2964. fmt.Println(str)
  2965. return str, string(bytesData)
  2966. }
  2967. 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) {
  2968. // 生成签名
  2969. nonce := GetRandomString(32)
  2970. timestamp := time.Now().Unix()
  2971. signature := setSignature(timestamp, nonce, secret_key)
  2972. // 生成输入报文
  2973. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2974. input := make(map[string]interface{})
  2975. inputData := make(map[string]interface{})
  2976. inputMessage["infno"] = "4101A" // 交易编码
  2977. year := time.Now().Format("2006")
  2978. month := time.Now().Format("01")
  2979. day := time.Now().Format("02")
  2980. inputData["psn_no"] = struct4101.PsnNo // 结算 ID 必填
  2981. inputData["mdtrt_id"] = struct4101.MdtrtId // 就诊 ID 必填(来自2201接口返回)
  2982. inputData["setl_id"] = struct4101.SetlId // 结算 ID 必填
  2983. inputData["hi_no"] = struct4101.PsnNo // 医保编号
  2984. inputData["medcasno"] = struct4101.PsnNo // 病案号 必填
  2985. inputData["dcla_time"] = year + "-" + month + "-" + day // 申报时间 必填
  2986. inputData["ntly"] = struct4101.Ntly // 国籍 必填
  2987. inputData["prfs"] = struct4101.Prfs // 职业 必填
  2988. inputData["curr_addr"] = "" // 现住址 必填
  2989. inputData["emp_name"] = "" // 单位名称 必填
  2990. inputData["emp_addr"] = "" // 单位地址 必填
  2991. inputData["emp_tel"] = ""
  2992. inputData["poscode"] = "" // 邮编 必填
  2993. inputData["coner_name"] = "" // 联系人姓名 必填
  2994. inputData["patn_rlts"] = "" // 与患者关系 必填
  2995. inputData["coner_addr"] = "" // 联系人地址 必填
  2996. inputData["coner_tel"] = ""
  2997. inputData["nwb_adm_type"] = "" // 新生儿入院类型 必填
  2998. inputData["nwb_bir_wt"] = "" // 新生儿出生体重 必填
  2999. inputData["nwb_adm_wt"] = "" // 新生儿入院体重 必填
  3000. inputData["mul_nwb_bir_wt"] = "" // 新生儿入院体重 必填
  3001. inputData["mul_nwb_adm_wt"] = "" // 新生儿入院体重 必填
  3002. inputData["opsp_diag_caty"] = "" // 门诊慢特病诊断 必填
  3003. inputData["opsp_mdtrt_date"] = "" // 门诊慢特病就诊日期 必填
  3004. inputData["adm_way"] = "" // 入院途径 必填
  3005. inputData["trt_type"] = "" // 治疗类别 必填
  3006. inputData["adm_time"] = "" // 入院时间 必填
  3007. inputData["refldept_dept"] = "" // 转科科别 必填
  3008. inputData["dscg_time"] = "" // 出院时间 必填
  3009. inputData["dscg_caty"] = "" // 出院科别 必填
  3010. inputData["otp_wm_dise"] = "" // 门(急) 诊西医诊断 必填
  3011. inputData["wm_dise_code"] = "" // 门(急) 诊中医诊断 必填
  3012. inputData["otp_tcm_dise"] = "" // 西医诊断疾病代码 必填
  3013. inputData["tcm_dise_code"] = "" // 中医诊断代码 必填
  3014. inputData["vent_used_dura"] = "" // 呼吸机使用时长 必填
  3015. inputData["pwcry_bfadm_coma_dura"] = "" // 颅脑损伤患者入院前昏迷时长 必填
  3016. inputData["pwcry_afadm_coma_dura"] = "" // 颅脑损伤患者入院后昏迷时长 必填
  3017. inputData["spga_nurscare_days"] = "" // 特级护理天数 必填
  3018. inputData["lv1_nurscare_days"] = "" // 一级护理天数 必填
  3019. inputData["scd_nurscare_days"] = "" // 二级护理天数 必填
  3020. inputData["lv3_nurscare_days"] = "" // 三级护理天数 必填
  3021. inputData["acp_medins_name"] = "" // 拟接收机构名称 必填
  3022. inputData["acp_optins_code"] = "" // 拟接收机构代码 必填
  3023. inputData["bill_code"] = struct4101.BillCode // 票据代码 必填
  3024. inputData["bill_no"] = struct4101.BillNo // 票据号码 必填
  3025. inputData["biz_sn"] = struct4101.BizSn // 业务流水号 必填
  3026. inputData["hi_paymtd"] = "1" // 业务流水号 必填
  3027. inputData["days_rinp_flag_31"] = "" // 出院 31 天内再住院计划标志 必填
  3028. inputData["days_rinp_pup_31"] = "" // 出院 31 天内再住院目的 必填
  3029. //inputData["chfpdr_name"] = struct4101.DoctorName // 主诊医师姓名 必填
  3030. //inputData["chfpdr_code"] = struct4101.DoctorCode // 主诊医师代码 必填
  3031. inputData["setl_begn_date"] = struct4101.SetlBegnDate // 结算开始日期 必填
  3032. inputData["setl_end_date"] = struct4101.SetlEndDate // 结算结束日期 必填
  3033. inputData["medins_fill_dept"] = struct4101.MedinsFillDept // 医疗机构填报部门 必填
  3034. inputData["medins_fill_psn"] = struct4101.MedinsFillPsn // 医疗机构填报人 必填
  3035. //payinfo := make([]map[string]interface{}, 0) // 基金支付信息
  3036. //for _, item := range struct4101.CustomStruct {
  3037. // payinfotemp := make(map[string]interface{})
  3038. // 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" {
  3039. // payinfotemp["fund_pay_type"] = item.FundPayType // 基金支付类型 必填
  3040. // payinfotemp["fund_payamt"] = item.FundPayamt // 基金支付金额
  3041. // payinfo = append(payinfo, payinfotemp)
  3042. // }
  3043. //}
  3044. opspdiseinfo := make([]map[string]interface{}, 0) // 门诊慢特病诊断信息
  3045. opspdiseinfotemp := make(map[string]interface{})
  3046. opspdiseinfotemp["diag_name"] = struct4101.Diseinfo[len(struct4101.Diseinfo)-1].DiagName // 诊断名称 必填
  3047. opspdiseinfotemp["diag_code"] = struct4101.Diseinfo[len(struct4101.Diseinfo)-1].DiagCode // 诊断代码 必填
  3048. opspdiseinfotemp["oprn_oprt_name"] = "血液透析" // 手术操作名称 必填
  3049. opspdiseinfotemp["oprn_oprt_code"] = "39.9500" // 手术操作代码 必填
  3050. opspdiseinfo = append(opspdiseinfo, opspdiseinfotemp)
  3051. //diseinfo := make([]map[string]interface{}, 0) // 住院诊断信息
  3052. //for _, item := range struct4101.Diseinfo {
  3053. // diseinfotemp := make(map[string]interface{})
  3054. // diseinfotemp["maindiag_flag"] = item.MaindiagFlag // 手术操作代码 必填
  3055. // diseinfotemp["diag_type"] = item.DiagType // 诊断类别 必填
  3056. // diseinfotemp["diag_code"] = item.DiagCode // 诊断代码 必填
  3057. // diseinfotemp["diag_name"] = item.DiagName // 诊断名称 必填
  3058. // diseinfotemp["adm_cond_type"] = "3" // 入院病情类型 必填
  3059. // diseinfo = append(diseinfo, diseinfotemp)
  3060. //}
  3061. //iteminfo := make([]map[string]interface{}, 0)
  3062. //for _, item := range struct4101.IteminfoStruct {
  3063. // iteminfotemp := make(map[string]interface{})
  3064. // iteminfotemp["med_chrgitm"] = item.MedChrgitm // 医疗收费项目 必填
  3065. // iteminfotemp["amt"] = item.Amt // 金额 必填
  3066. // iteminfotemp["claa_sumfee"] = item.ClaaSumfee // 甲类费用合计 必填
  3067. // iteminfotemp["clab_amt"] = item.ClabAmt // 乙类金额 必填
  3068. // iteminfotemp["fulamt_ownpay_amt"] = item.FulamtOwnpayAmt // 全自费金额 必填
  3069. // iteminfotemp["oth_amt"] = item.OthAmt // 其他金额 必填
  3070. // iteminfo = append(iteminfo, iteminfotemp)
  3071. //}
  3072. oprninfo := make([]map[string]interface{}, 0) // 手术操作信息
  3073. oprninfotemp := make(map[string]interface{})
  3074. oprninfotemp["oprn_oprt_type"] = "" // 手术操作类别 必填
  3075. oprninfotemp["oprn_oprt_name"] = "" // 手术操作名称 必填
  3076. oprninfotemp["oprn_oprt_code"] = "" // 手术操作代码 必填
  3077. oprninfotemp["oprn_oprt_date"] = "" // 手术操作日期 必填
  3078. oprninfotemp["anst_way"] = "" // 麻醉方式 必填
  3079. oprninfotemp["oper_dr_name"] = "" // 术者医师姓名 必填
  3080. oprninfotemp["oper_dr_code"] = "" // 术者医师代码 必填
  3081. oprninfotemp["anst_dr_name"] = "" // 麻醉医师姓名 必填
  3082. oprninfotemp["anst_dr_code"] = "" // 麻醉医师代码 必填
  3083. oprninfo = append(oprninfo, oprninfotemp)
  3084. icuinfo := make([]map[string]interface{}, 0) // 重症监护信息
  3085. icuinfotemp := make(map[string]interface{})
  3086. icuinfotemp["scs_cutd_ward_type"] = "" // 重症监护病房类型 必填
  3087. icuinfotemp["scs_cutd_inpool_time"] = "" // 重症监护进入时间 必填
  3088. icuinfotemp["scs_cutd_exit_time"] = "" // 重症监护退出时间 必填
  3089. icuinfotemp["scs_cutd_sum_dura"] = "" // 重症监护合计时长 必填
  3090. icuinfo = append(icuinfo, icuinfotemp)
  3091. input["setlinfo"] = inputData
  3092. input["opspdiseinfo"] = opspdiseinfo
  3093. //input["diseinfo"] = payinfo
  3094. //input["oprninfo"] = payinfo
  3095. //input["icuinfo"] = payinfo
  3096. //input["bldinfo"] = payinfo
  3097. inputMessage["input"] = input //交易输入
  3098. bytesData, err := json.Marshal(inputMessage)
  3099. fmt.Println(string(bytesData))
  3100. if err != nil {
  3101. fmt.Println(err.Error())
  3102. return err.Error(), ""
  3103. }
  3104. reader := bytes.NewReader(bytesData)
  3105. gdyb_url := beego.AppConfig.String("gdyb_url")
  3106. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3107. //url := gdyb_url + "4101"
  3108. var url string
  3109. if fixmedins_code == "H15049901371" {
  3110. url = gdyb_url
  3111. } else {
  3112. url = gdyb_url + "4101A"
  3113. }
  3114. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/4101"
  3115. request, err := http.NewRequest("POST", url, reader)
  3116. if err != nil {
  3117. fmt.Println(err.Error())
  3118. return err.Error(), ""
  3119. }
  3120. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3121. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3122. request.Header.Set("x-tif-signature", signature)
  3123. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3124. request.Header.Set("x-tif-nonce", nonce)
  3125. client := http.Client{}
  3126. resp, err := client.Do(request)
  3127. if err != nil {
  3128. fmt.Println(err.Error())
  3129. return err.Error(), ""
  3130. }
  3131. respBytes, err := ioutil.ReadAll(resp.Body)
  3132. if err != nil {
  3133. fmt.Println(err.Error())
  3134. return err.Error(), ""
  3135. }
  3136. str := string(respBytes)
  3137. fmt.Println(str)
  3138. return str, string(bytesData)
  3139. }
  3140. //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 {
  3141. // // 生成签名
  3142. // nonce := GetRandomString(32)
  3143. // timestamp := time.Now().Unix()
  3144. // signature := setSignature(timestamp, nonce, secret_key)
  3145. // tempTime := time.Unix(timestamp, 0)
  3146. // //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  3147. //
  3148. // timeFormatTwo := tempTime.Format("2006-01-02")
  3149. //
  3150. // t := time.Now()
  3151. // last := time.Date(t.Year(), time.December, 31, 0, 0, 0, 0, time.UTC)
  3152. // tm := time.Unix(last.Unix(), 0)
  3153. //
  3154. // // 生成输入报文
  3155. // inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3156. // input := make(map[string]interface{})
  3157. // inputData := make(map[string]interface{})
  3158. //
  3159. // inputData2 := make(map[string]interface{})
  3160. //
  3161. // inputMessage["infno"] = "7101" // 交易编码
  3162. // inputData["hosp_rxno"] = psnNo // 人员编号 (来自1101接口返回)
  3163. // inputData["init_rxno"] = insutype // 险种类型(来自1101接口返回)
  3164. // inputData["rx_type_code"] = sick_code // 险种类型(来自1101接口返回)
  3165. // inputData["prsc_time"] = sick_name // 险种类型(来自1101接口返回)
  3166. // inputData["rx_drug_nums"] = insuplc_admdvs // 险种类型(来自1101接口返回)
  3167. // inputData["rx_way_codg"] = fixmedins_code // 险种类型(来自1101接口返回)
  3168. // inputData["rx_way_name"] = org_name // 险种类型(来自1101接口返回)
  3169. // inputData["rx_freq_codg"] = timeFormatTwo // 险种类型(来自1101接口返回)
  3170. // inputData["rx_freq_name"] = doctor_id // 开始时间
  3171. // inputData["rx_dosunt"] = doctor // 开始时间
  3172. // inputData["rx_doscnt"] = timeFormatTwo // 医师编码
  3173. // inputData["rx_drord_dscr"] = "" // 医师编码
  3174. // inputData["valid_days"] = "" // 医师编码
  3175. // inputData["valid_end_time"] = tm.Format("2006-01-02") // 医师编码
  3176. // inputData["rept_flag"] = tm.Format("2006-01-02") // 医师编码
  3177. // inputData["max_rept_cnt"] = tm.Format("2006-01-02") // 医师编码
  3178. // inputData["reptd_cnt"] = tm.Format("2006-01-02") // 医师编码
  3179. // inputData["min_inrv_days"] = tm.Format("2006-01-02") // 医师编码
  3180. // inputData["dr_sign_info"] = tm.Format("2006-01-02") // 医师编码
  3181. // inputData["phar_sign_info"] = tm.Format("2006-01-02") // 医师编码
  3182. // inputData["fixmedins_sign_info"] = tm.Format("2006-01-02") // 医师编码
  3183. // inputData["rx_cotn_flag"] = tm.Format("2006-01-02") // 医师编码
  3184. // inputData["rx_file"] = tm.Format("2006-01-02") // 医师编码
  3185. // input["data"] = inputData
  3186. //
  3187. //
  3188. // inputData2["med_list_codg"] = psnNo // 人员编号 (来自1101接口返回)
  3189. // inputData2["fixmedins_hilist_id"] = insutype // 险种类型(来自1101接口返回)
  3190. // inputData["hosp_prep_flag"] = sick_code // 险种类型(来自1101接口返回)
  3191. // inputData["rx_item_type_code"] = sick_name // 险种类型(来自1101接口返回)
  3192. // inputData["rx_item_type_name"] = insuplc_admdvs // 险种类型(来自1101接口返回)
  3193. // inputData["tcmdrug_type_name"] = fixmedins_code // 险种类型(来自1101接口返回)
  3194. // inputData["tcmdrug_type_code"] = org_name // 险种类型(来自1101接口返回)
  3195. // inputData["tcmherb_foote"] = timeFormatTwo // 险种类型(来自1101接口返回)
  3196. // inputData["medn_type_code"] = doctor_id // 开始时间
  3197. // inputData["medn_type_name"] = doctor // 开始时间
  3198. // inputData["main_medc_flag"] = timeFormatTwo // 医师编码
  3199. // inputData["urgt_flag"] = "" // 医师编码
  3200. // inputData["bas_medn_flag"] = "" // 医师编码
  3201. // inputData["imp_drug_flag"] = tm.Format("2006-01-02") // 医师编码
  3202. // inputData["prod_barc"] = tm.Format("2006-01-02") // 医师编码
  3203. // inputData["drug_prodname"] = tm.Format("2006-01-02") // 医师编码
  3204. //
  3205. // inputData["genname_codg"] = tm.Format("2006-01-02") // 医师编码
  3206. // inputData["drug_genname"] = tm.Format("2006-01-02") // 医师编码
  3207. // inputData["chemname"] = tm.Format("2006-01-02") // 医师编码
  3208. //
  3209. // inputData["drugstdcode"] = tm.Format("2006-01-02") // 医师编码
  3210. // inputData["drug_dosform"] = tm.Format("2006-01-02") // 医师编码
  3211. //
  3212. //
  3213. // inputData["drug_spec"] = tm.Format("2006-01-02") // 医师编码
  3214. // inputData["prdr_name"] = tm.Format("2006-01-02") // 医师编码
  3215. //
  3216. //
  3217. // inputData["drug_pric"] = tm.Format("2006-01-02") // 医师编码
  3218. // inputData["drug_cnt"] = tm.Format("2006-01-02") // 医师编码
  3219. // inputData["drug_cnt_unit"] = tm.Format("2006-01-02") // 医师编码
  3220. // inputData["drug_sumamt"] = tm.Format("2006-01-02") // 医师编码
  3221. // inputData["medc_way_codg"] = tm.Format("2006-01-02") // 医师编码
  3222. // inputData["medc_way_dscr"] = tm.Format("2006-01-02") // 医师编码
  3223. // inputData["medc_starttime"] = tm.Format("2006-01-02") // 医师编码
  3224. //
  3225. // inputData["medc_endtime"] = tm.Format("2006-01-02") // 医师编码
  3226. //
  3227. //
  3228. // inputData["medc_days"] = tm.Format("2006-01-02") // 医师编码
  3229. // inputData["drug_dosunt"] = tm.Format("2006-01-02") // 医师编码
  3230. // inputData["sin_doscnt"] = tm.Format("2006-01-02") // 医师编码
  3231. // inputData["sin_dosunt"] = tm.Format("2006-01-02") // 医师编码
  3232. // inputData["used_frqu_codg"] = tm.Format("2006-01-02") // 医师编码
  3233. //
  3234. //
  3235. // inputData["used_frqu_name"] = tm.Format("2006-01-02") // 医师编码
  3236. // inputData["drug_totlnt"] = tm.Format("2006-01-02") // 医师编码
  3237. //
  3238. // inputData["drug_totlnt_emp"] = tm.Format("2006-01-02") // 医师编码
  3239. // inputData["dise_codg"] = tm.Format("2006-01-02") // 医师编码
  3240. // inputData["drug_res"] = tm.Format("2006-01-02") // 医师编码
  3241. // inputData["drug_limit"] = tm.Format("2006-01-02") // 医师编码
  3242. //
  3243. //
  3244. //
  3245. //
  3246. //
  3247. //
  3248. //
  3249. //
  3250. //
  3251. // input["rxdrugdetail"] = inputData2
  3252. //
  3253. //
  3254. //
  3255. //
  3256. // inputMessage["input"] = input //交易输入
  3257. // bytesData, err := json.Marshal(inputMessage)
  3258. // fmt.Println(string(bytesData))
  3259. // if err != nil {
  3260. // fmt.Println(err.Error())
  3261. // return err.Error()
  3262. // }
  3263. // reader := bytes.NewReader(bytesData)
  3264. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2503"
  3265. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2503"
  3266. // gdyb_url := beego.AppConfig.String("gdyb_url")
  3267. // gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3268. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  3269. // url := gdyb_url + "2503"
  3270. //
  3271. // request, err := http.NewRequest("POST", url, reader)
  3272. // if err != nil {
  3273. // fmt.Println(err.Error())
  3274. // return err.Error()
  3275. // }
  3276. //
  3277. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3278. // request.Header.Set("x-tif-paasid", gdyb_paasid)
  3279. // request.Header.Set("x-tif-signature", signature)
  3280. // request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3281. // request.Header.Set("x-tif-nonce", nonce)
  3282. //
  3283. // client := http.Client{}
  3284. // resp, err := client.Do(request)
  3285. // if err != nil {
  3286. // fmt.Println(err.Error())
  3287. // return err.Error()
  3288. // }
  3289. // respBytes, err := ioutil.ReadAll(resp.Body)
  3290. // if err != nil {
  3291. // fmt.Println(err.Error())
  3292. // return err.Error()
  3293. // }
  3294. // str := string(respBytes)
  3295. // fmt.Println(str)
  3296. // return str
  3297. //}
  3298. // 生成签名
  3299. func setSignature(timestamp int64, nonce string, secret_key string) string {
  3300. fmt.Println(timestamp)
  3301. fmt.Println(nonce)
  3302. fmt.Println(secret_key)
  3303. fmt.Println(strconv.FormatInt(timestamp, 10))
  3304. fmt.Println(time.Now().UnixNano() / 1e6)
  3305. str := strconv.FormatInt(timestamp, 10) + secret_key + nonce + strconv.FormatInt(timestamp, 10)
  3306. hash := sha256.New()
  3307. //输入数据
  3308. hash.Write([]byte(str))
  3309. //计算哈希值
  3310. bytes := hash.Sum(nil)
  3311. //将字符串编码为16进制格式,返回字符串
  3312. hashCode := hex.EncodeToString(bytes)
  3313. //返回哈希值
  3314. return hashCode
  3315. }
  3316. const charset = "abcdefghijklmnopqrstuvwxyz" +
  3317. "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
  3318. var seededRand *rand.Rand = rand.New(
  3319. rand.NewSource(time.Now().UnixNano()))
  3320. // 生成随机字符串
  3321. func GetRandomString(l int) string {
  3322. //str := "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
  3323. //bytes := []byte(str)
  3324. //result := []byte{}
  3325. //r := rand.New(rand.NewSource(time.Now().UnixNano()))
  3326. //for i := 0; i < l; i++ {
  3327. // result = append(result, bytes[r.Intn(len(bytes))])
  3328. //}
  3329. return String(32)
  3330. }
  3331. func StringWithCharset(length int, charset string) string {
  3332. b := make([]byte, length)
  3333. for i := range b {
  3334. b[i] = charset[seededRand.Intn(len(charset))]
  3335. }
  3336. return string(b)
  3337. }
  3338. func String(length int) string {
  3339. return StringWithCharset(length, charset)
  3340. }
  3341. // 生成基础报文
  3342. func SetInputMessage(nonce string, timestamp int64, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) map[string]interface{} {
  3343. // 生成签名
  3344. tempTime := time.Unix(timestamp, 0)
  3345. //timeFormat := tempTime.Format("20060102150405")
  3346. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  3347. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  3348. month := time.Unix(1557042972, 0).Format("1")
  3349. year := time.Now().Format("2006")
  3350. month = time.Now().Format("01")
  3351. day := time.Now().Format("02")
  3352. hour := time.Now().Format("15")
  3353. min := time.Now().Format("04")
  3354. sec := time.Now().Format("05")
  3355. msec := time.Now().Format("000")
  3356. // 生成输入报文
  3357. inputMessage := make(map[string]interface{})
  3358. inputMessage["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  3359. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  3360. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  3361. inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  3362. inputMessage["dev_no"] = "" // 设备编号
  3363. inputMessage["dev_safe_info"] = "" // 设备安全信息
  3364. inputMessage["cainfo"] = "" // 数字签名信息
  3365. inputMessage["signtype"] = "MOCK" // 签名类型
  3366. inputMessage["infver"] = "V1.0" // 接收方系统代码
  3367. inputMessage["opter_type"] = "1" // 经办人类别
  3368. inputMessage["opter"] = doctor // 经办人
  3369. inputMessage["opter_name"] = doctor // 经办人姓名
  3370. inputMessage["inf_time"] = timeFormatOne // 交易时间
  3371. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  3372. inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  3373. if mdtrtarea_admvs == "440100" {
  3374. inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号
  3375. } else {
  3376. inputMessage["sign_no"] = "" //交易签到流水号
  3377. }
  3378. return inputMessage
  3379. }
  3380. 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{} {
  3381. // 生成签名
  3382. tempTime := time.Unix(timestamp, 0)
  3383. //timeFormat := tempTime.Format("20060102150405")
  3384. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  3385. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  3386. // 生成输入报文
  3387. inputMessage := make(map[string]interface{})
  3388. inputMessage["msgid"] = msg_id // 发送方报文 ID
  3389. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  3390. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  3391. inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  3392. inputMessage["dev_no"] = "" // 设备编号
  3393. inputMessage["dev_safe_info"] = "" // 设备安全信息
  3394. inputMessage["cainfo"] = "" // 数字签名信息
  3395. inputMessage["signtype"] = "SM3" // 签名类型
  3396. inputMessage["infver"] = "V1.0" // 接收方系统代码
  3397. inputMessage["opter_type"] = "1" // 经办人类别
  3398. inputMessage["opter"] = doctor // 经办人
  3399. inputMessage["opter_name"] = doctor // 经办人姓名
  3400. inputMessage["inf_time"] = timeFormatOne // 交易时间
  3401. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  3402. inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  3403. if mdtrtarea_admvs == "440100" {
  3404. inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号
  3405. } else {
  3406. inputMessage["sign_no"] = "" //交易签到流水号
  3407. }
  3408. return inputMessage
  3409. }
  3410. 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{} {
  3411. // 生成签名
  3412. tempTime := time.Unix(timestamp, 0)
  3413. //timeFormat := tempTime.Format("20060102150405")
  3414. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  3415. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  3416. month := time.Unix(1557042972, 0).Format("1")
  3417. year := time.Now().Format("2006")
  3418. month = time.Now().Format("01")
  3419. day := time.Now().Format("02")
  3420. hour := time.Now().Format("15")
  3421. min := time.Now().Format("04")
  3422. sec := time.Now().Format("05")
  3423. msec := time.Now().Format("000")
  3424. // 生成输入报文
  3425. inputMessage := make(map[string]interface{})
  3426. inputMessage["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  3427. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  3428. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  3429. inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  3430. inputMessage["dev_no"] = "" // 设备编号
  3431. inputMessage["dev_safe_info"] = "" // 设备安全信息
  3432. inputMessage["cainfo"] = "" // 数字签名信息
  3433. inputMessage["signtype"] = "SM3" // 签名类型
  3434. inputMessage["infver"] = "V1.0" // 接收方系统代码
  3435. inputMessage["opter_type"] = "1" // 经办人类别
  3436. inputMessage["opter"] = doctor // 经办人
  3437. inputMessage["opter_name"] = doctor // 经办人姓名
  3438. inputMessage["inf_time"] = timeFormatOne // 交易时间
  3439. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  3440. inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  3441. if mdtrtarea_admvs == "440100" {
  3442. inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号
  3443. } else {
  3444. inputMessage["sign_no"] = sign_no //交易签到流水号
  3445. }
  3446. return inputMessage
  3447. }
  3448. func postFile(filename string, target_url string) (*http.Response, error) {
  3449. body_buf := bytes.NewBufferString("")
  3450. body_writer := multipart.NewWriter(body_buf)
  3451. // use the body_writer to write the Part headers to the buffer
  3452. _, err := body_writer.CreateFormFile("userfile", filename)
  3453. if err != nil {
  3454. fmt.Println("error writing to buffer")
  3455. return nil, err
  3456. }
  3457. // the file data will be the second part of the body
  3458. fh, err := os.Open(filename)
  3459. if err != nil {
  3460. fmt.Println("error opening file")
  3461. return nil, err
  3462. }
  3463. // need to know the boundary to properly close the part myself.
  3464. boundary := body_writer.Boundary()
  3465. //close_string := fmt.Sprintf("\r\n--%s--\r\n", boundary)
  3466. close_buf := bytes.NewBufferString(fmt.Sprintf("\r\n--%s--\r\n", boundary))
  3467. // use multi-reader to defer the reading of the file data until
  3468. // writing to the socket buffer.
  3469. request_reader := io.MultiReader(body_buf, fh, close_buf)
  3470. fi, err := fh.Stat()
  3471. if err != nil {
  3472. fmt.Printf("Error Stating file: %s", filename)
  3473. return nil, err
  3474. }
  3475. req, err := http.NewRequest("POST", target_url, request_reader)
  3476. if err != nil {
  3477. return nil, err
  3478. }
  3479. // Set headers for multipart, and Content Length
  3480. req.Header.Add("Content-Type", "multipart/form-data; boundary="+boundary)
  3481. req.ContentLength = fi.Size() + int64(body_buf.Len()) + int64(close_buf.Len())
  3482. return http.DefaultClient.Do(req)
  3483. }
  3484. //func Gdyb1201(psnNo string, org_name string, doctor string) string {
  3485. // // 生成签名
  3486. // nonce := GetRandomString(32)
  3487. // timestamp := time.Now().Unix()
  3488. // signature := setSignature(timestamp, nonce)
  3489. //
  3490. // // 生成输入报文
  3491. // inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, "")
  3492. // input := make(map[string]interface{})
  3493. // inputData := make(map[string]interface{})
  3494. // inputMessage["infno"] = "1201" // 交易编码
  3495. // inputData["fixmedins_type"] = psnNo // 人员编号 (来自1101接口返回)
  3496. // inputData["fixmedins_name"] = org_name // 人员编号 (来自1101接口返回)
  3497. // inputData["fixmedins_code"] = "" // 人员编号 (来自1101接口返回)
  3498. //
  3499. // input["medinsinfo"] = inputData
  3500. // inputMessage["input"] = input //交易输入
  3501. //
  3502. // bytesData, err := json.Marshal(inputMessage)
  3503. // fmt.Println(string(bytesData))
  3504. // if err != nil {
  3505. // fmt.Println(err.Error())
  3506. // return err.Error()
  3507. // }
  3508. // reader := bytes.NewReader(bytesData)
  3509. //
  3510. // url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1201"
  3511. // request, err := http.NewRequest("POST", url, reader)
  3512. // if err != nil {
  3513. // fmt.Println(err.Error())
  3514. // return err.Error()
  3515. // }
  3516. //
  3517. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3518. // request.Header.Set("x-tif-paasid", "test_hosp")
  3519. // request.Header.Set("x-tif-signature", signature)
  3520. // request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3521. // request.Header.Set("x-tif-nonce", nonce)
  3522. //
  3523. // client := http.Client{}
  3524. // resp, err := client.Do(request)
  3525. // if err != nil {
  3526. // fmt.Println(err.Error())
  3527. // return err.Error()
  3528. // }
  3529. // respBytes, err := ioutil.ReadAll(resp.Body)
  3530. // if err != nil {
  3531. // fmt.Println(err.Error())
  3532. // return err.Error()
  3533. // }
  3534. // str := string(respBytes)
  3535. // fmt.Println(str)
  3536. // return str
  3537. //}
  3538. func newfileUploadRequest(uri string, params map[string]string, paramName, path string) (*http.Request, error) {
  3539. file, err := os.Open(path)
  3540. if err != nil {
  3541. return nil, err
  3542. }
  3543. defer file.Close()
  3544. body := &bytes.Buffer{}
  3545. writer := multipart.NewWriter(body)
  3546. part, err := writer.CreateFormFile(paramName, filepath.Base(path))
  3547. if err != nil {
  3548. return nil, err
  3549. }
  3550. _, err = io.Copy(part, file)
  3551. for key, val := range params {
  3552. _ = writer.WriteField(key, val)
  3553. }
  3554. err = writer.Close()
  3555. if err != nil {
  3556. return nil, err
  3557. }
  3558. req, err := http.NewRequest("POST", uri, body)
  3559. req.Header.Set("Content-Type", writer.FormDataContentType())
  3560. return req, err
  3561. }
  3562. func CreateMedicalInsuranceCostCompareRecord(record *models.MedicalInsuranceCostCompare) error {
  3563. err := writeDb.Save(&record).Error
  3564. return err
  3565. }
  3566. //func Gdyb5203(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  3567. // // 生成签名
  3568. // nonce := GetRandomString(32)
  3569. // timestamp := time.Now().Unix()
  3570. // signature := setSignature(timestamp, nonce, secret_key)
  3571. //
  3572. // // 生成输入报文
  3573. // inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3574. // input := make(map[string]interface{})
  3575. // inputData := make(map[string]interface{})
  3576. // inputMessage["infno"] = "5203" // 交易编码
  3577. //
  3578. // inputData["fixmedins_type"] = "1"
  3579. // inputData["fixmedins_name"] = org_name
  3580. // inputData["fixmedins_code"] = fixmedins_code
  3581. // input["medinsinfo"] = inputData
  3582. // inputMessage["input"] = input //交易输入
  3583. //
  3584. // bytesData, err := json.Marshal(inputMessage)
  3585. // fmt.Println(string(bytesData))
  3586. // if err != nil {
  3587. // fmt.Println(err.Error())
  3588. // return err.Error()
  3589. // }
  3590. // reader := bytes.NewReader(bytesData)
  3591. // url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1201"
  3592. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1201"
  3593. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  3594. // request, err := http.NewRequest("POST", url, reader)
  3595. // if err != nil {
  3596. // fmt.Println(err.Error())
  3597. // return err.Error()
  3598. // }
  3599. //
  3600. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3601. // request.Header.Set("x-tif-paasid", "sg03_prd")
  3602. // request.Header.Set("x-tif-signature", signature)
  3603. // request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3604. // request.Header.Set("x-tif-nonce", nonce)
  3605. //
  3606. // client := http.Client{}
  3607. // resp, err := client.Do(request)
  3608. // if err != nil {
  3609. // fmt.Println(err.Error())
  3610. // return err.Error()
  3611. // }
  3612. // respBytes, err := ioutil.ReadAll(resp.Body)
  3613. // if err != nil {
  3614. // fmt.Println(err.Error())
  3615. // return err.Error()
  3616. // }
  3617. // fmt.Println(string(respBytes))
  3618. // str := string(respBytes)
  3619. // return str
  3620. //}
  3621. func CreatePsnRecord(record *models.GdybPsnRecord) {
  3622. writeDb.Save(&record)
  3623. return
  3624. }
  3625. func GetPsnRecordById(id int64) (record models.GdybPsnRecord, err error) {
  3626. err = readDb.Model(&models.GdybPsnRecord{}).Where("id = ?").First(&record).Error
  3627. return
  3628. }
  3629. func CreatePsnNCDSRecord(record *models.GdybPsnNcdsRecord) {
  3630. writeDb.Save(&record)
  3631. return
  3632. }
  3633. func GetPsnNCDSRecordById(id int64) (record models.GdybPsnNcdsRecord, err error) {
  3634. err = readDb.Model(&models.GdybPsnNcdsRecord{}).Where("id = ?", id).First(&record).Error
  3635. return
  3636. }
  3637. func GetPatientsByIds(ids []string, current_org_id int64) (patients []*models.Patients, err error) {
  3638. err = readDb.Model(&models.Patients{}).Where("id IN (?) AND user_org_id = ?", ids, current_org_id).Find(&patients).Error
  3639. return
  3640. }
  3641. 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 {
  3642. // 生成签名
  3643. nonce := GetRandomString(32)
  3644. timestamp := time.Now().Unix()
  3645. signature := setSignature(timestamp, nonce, secret_key)
  3646. // 生成输入报文
  3647. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3648. input := make(map[string]interface{})
  3649. inputData := make(map[string]interface{})
  3650. inputMessage["infno"] = "2601" // 交易编码
  3651. inputData["psn_no"] = psnNo
  3652. inputData["omsgid"] = omsgid
  3653. inputData["oinfno"] = oinfno
  3654. input["data"] = inputData
  3655. inputMessage["input"] = input //交易输入
  3656. bytesData, err := json.Marshal(inputMessage)
  3657. fmt.Println(string(bytesData))
  3658. if err != nil {
  3659. fmt.Println(err.Error())
  3660. return err.Error()
  3661. }
  3662. reader := bytes.NewReader(bytesData)
  3663. gdyb_url := beego.AppConfig.String("gdyb_url")
  3664. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3665. url := gdyb_url + "2601"
  3666. request, err := http.NewRequest("POST", url, reader)
  3667. if err != nil {
  3668. fmt.Println(err.Error())
  3669. return err.Error()
  3670. }
  3671. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3672. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3673. request.Header.Set("x-tif-signature", signature)
  3674. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3675. request.Header.Set("x-tif-nonce", nonce)
  3676. client := http.Client{}
  3677. resp, err := client.Do(request)
  3678. if err != nil {
  3679. fmt.Println(err.Error())
  3680. return err.Error()
  3681. }
  3682. respBytes, err := ioutil.ReadAll(resp.Body)
  3683. if err != nil {
  3684. fmt.Println(err.Error())
  3685. return err.Error()
  3686. }
  3687. str := string(respBytes)
  3688. fmt.Println(str)
  3689. return str
  3690. }
  3691. // 人员信息版本3
  3692. 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 {
  3693. //生成签名
  3694. nonce := GetRandomString(32)
  3695. timestamp := time.Now().Unix()
  3696. signature := setSignature(timestamp, nonce, secret_key)
  3697. //生成输入报文
  3698. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3699. input := make(map[string]interface{})
  3700. inputData := make(map[string]interface{})
  3701. inputMessage["infno"] = "1101" // 交易编码
  3702. if certificates == 3 {
  3703. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  3704. inputData["certno"] = "01836483" // 证件号码
  3705. inputData["psn_cert_type"] = "01" // 人员证件类型
  3706. inputData["mdtrt_cert_no"] = "01836483" // 就诊凭证编号
  3707. } else {
  3708. if certificates == 1 {
  3709. if id_card_type == 1 {
  3710. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  3711. inputData["card_sn"] = card_sn // 卡识别码
  3712. inputData["certno"] = certNo // 证件号码
  3713. inputData["psn_cert_type"] = "01" // 人员证件类型
  3714. inputData["mdtrt_cert_no"] = cardNumber // 就诊凭证编号
  3715. } else {
  3716. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  3717. inputData["card_sn"] = "" // 卡识别码
  3718. inputData["certno"] = certNo // 证件号码
  3719. inputData["psn_cert_type"] = "01" // 人员证件类型
  3720. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  3721. }
  3722. } else if certificates == 6 {
  3723. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  3724. inputData["card_sn"] = "" // 卡识别码
  3725. inputData["certno"] = certNo // 证件号码
  3726. inputData["psn_cert_type"] = "17" // 人员证件类型
  3727. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  3728. }
  3729. }
  3730. inputData["begntime"] = "" // 开始时间
  3731. inputData["psn_name"] = name // 人员姓名
  3732. input["data"] = inputData
  3733. inputMessage["input"] = input //交易输入
  3734. bytesData, err := json.Marshal(inputMessage)
  3735. fmt.Println(string(bytesData))
  3736. if err != nil {
  3737. fmt.Println(err.Error())
  3738. return err.Error()
  3739. }
  3740. reader := bytes.NewReader(bytesData)
  3741. gdyb_url := beego.AppConfig.String("gdyb_url")
  3742. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3743. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  3744. //url := gdyb_url + "1101"
  3745. var url string
  3746. if fixmedins_code == "H15049901371" {
  3747. url = gdyb_url
  3748. } else {
  3749. url = gdyb_url + "1101"
  3750. }
  3751. fmt.Println(url)
  3752. fmt.Println(gdyb_paasid)
  3753. fmt.Println(secret_key)
  3754. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  3755. request, err := http.NewRequest("POST", url, reader)
  3756. if err != nil {
  3757. fmt.Println(err.Error())
  3758. return err.Error()
  3759. }
  3760. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3761. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3762. request.Header.Set("x-tif-signature", signature)
  3763. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3764. request.Header.Set("x-tif-nonce", nonce)
  3765. client := http.Client{}
  3766. resp, err := client.Do(request)
  3767. if err != nil {
  3768. fmt.Println(err.Error())
  3769. return err.Error()
  3770. }
  3771. respBytes, err := ioutil.ReadAll(resp.Body)
  3772. if err != nil {
  3773. fmt.Println(err.Error())
  3774. return err.Error()
  3775. }
  3776. fmt.Println(string(respBytes))
  3777. str := string(respBytes)
  3778. return str
  3779. }
  3780. 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 {
  3781. //生成签名
  3782. nonce := GetRandomString(32)
  3783. timestamp := time.Now().Unix()
  3784. signature := setSignature(timestamp, nonce, secret_key)
  3785. //生成输入报文
  3786. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3787. input := make(map[string]interface{})
  3788. inputData := make(map[string]interface{})
  3789. inputMessage["infno"] = "1101" // 交易编码
  3790. if certificates == 3 {
  3791. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  3792. inputData["certno"] = "01836483" // 证件号码
  3793. inputData["psn_cert_type"] = "01" // 人员证件类型
  3794. inputData["mdtrt_cert_no"] = "01836483" // 就诊凭证编号
  3795. } else {
  3796. if certificates == 1 {
  3797. if id_card_type == 1 {
  3798. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  3799. inputData["card_sn"] = "" // 卡识别码
  3800. inputData["certno"] = certNo // 证件号码
  3801. inputData["psn_cert_type"] = "01" // 人员证件类型
  3802. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  3803. } else {
  3804. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  3805. inputData["card_sn"] = "" // 卡识别码
  3806. inputData["certno"] = certNo // 证件号码
  3807. inputData["psn_cert_type"] = "" // 人员证件类型
  3808. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  3809. }
  3810. } else if certificates == 6 {
  3811. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  3812. inputData["card_sn"] = "" // 卡识别码
  3813. inputData["certno"] = certNo // 证件号码
  3814. inputData["psn_cert_type"] = "" // 人员证件类型
  3815. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  3816. }
  3817. }
  3818. inputData["begntime"] = "" // 开始时间
  3819. inputData["psn_name"] = "" // 人员姓名
  3820. input["data"] = inputData
  3821. inputMessage["input"] = input //交易输入
  3822. bytesData, err := json.Marshal(inputMessage)
  3823. fmt.Println(string(bytesData))
  3824. if err != nil {
  3825. fmt.Println(err.Error())
  3826. return err.Error()
  3827. }
  3828. reader := bytes.NewReader(bytesData)
  3829. gdyb_url := beego.AppConfig.String("gdyb_url")
  3830. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3831. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  3832. //url := gdyb_url + "1101"
  3833. var url string
  3834. if fixmedins_code == "H15049901371" {
  3835. url = gdyb_url
  3836. } else {
  3837. url = gdyb_url + "1101"
  3838. }
  3839. fmt.Println(url)
  3840. fmt.Println(gdyb_paasid)
  3841. fmt.Println(secret_key)
  3842. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  3843. request, err := http.NewRequest("POST", url, reader)
  3844. if err != nil {
  3845. fmt.Println(err.Error())
  3846. return err.Error()
  3847. }
  3848. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3849. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3850. request.Header.Set("x-tif-signature", signature)
  3851. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3852. request.Header.Set("x-tif-nonce", nonce)
  3853. client := http.Client{}
  3854. resp, err := client.Do(request)
  3855. if err != nil {
  3856. fmt.Println(err.Error())
  3857. return err.Error()
  3858. }
  3859. respBytes, err := ioutil.ReadAll(resp.Body)
  3860. if err != nil {
  3861. fmt.Println(err.Error())
  3862. return err.Error()
  3863. }
  3864. fmt.Println(string(respBytes))
  3865. str := string(respBytes)
  3866. return str
  3867. }
  3868. 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 {
  3869. //生成签名
  3870. nonce := GetRandomString(32)
  3871. timestamp := time.Now().Unix()
  3872. signature := setSignature(timestamp, nonce, secret_key)
  3873. //生成输入报文
  3874. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3875. input := make(map[string]interface{})
  3876. inputData := make(map[string]interface{})
  3877. inputMessage["infno"] = "1101" // 交易编码
  3878. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  3879. inputData["card_sn"] = card_sn // 卡识别码
  3880. inputData["certno"] = certNo // 证件号码
  3881. inputData["psn_cert_type"] = "01" // 人员证件类型
  3882. inputData["mdtrt_cert_no"] = cardNumber // 就诊凭证编号
  3883. inputData["begntime"] = "" // 开始时间
  3884. inputData["psn_name"] = name // 人员姓名
  3885. input["data"] = inputData
  3886. inputMessage["input"] = input //交易输入
  3887. bytesData, err := json.Marshal(inputMessage)
  3888. fmt.Println(string(bytesData))
  3889. if err != nil {
  3890. fmt.Println(err.Error())
  3891. return err.Error()
  3892. }
  3893. reader := bytes.NewReader(bytesData)
  3894. gdyb_url := beego.AppConfig.String("gdyb_url")
  3895. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3896. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  3897. //url := gdyb_url + "1101"
  3898. var url string
  3899. if fixmedins_code == "H15049901371" {
  3900. url = gdyb_url
  3901. } else {
  3902. url = gdyb_url + "1101"
  3903. }
  3904. fmt.Println(url)
  3905. fmt.Println(gdyb_paasid)
  3906. fmt.Println(secret_key)
  3907. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  3908. request, err := http.NewRequest("POST", url, reader)
  3909. if err != nil {
  3910. fmt.Println(err.Error())
  3911. return err.Error()
  3912. }
  3913. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3914. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3915. request.Header.Set("x-tif-signature", signature)
  3916. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3917. request.Header.Set("x-tif-nonce", nonce)
  3918. client := http.Client{}
  3919. resp, err := client.Do(request)
  3920. if err != nil {
  3921. fmt.Println(err.Error())
  3922. return err.Error()
  3923. }
  3924. respBytes, err := ioutil.ReadAll(resp.Body)
  3925. if err != nil {
  3926. fmt.Println(err.Error())
  3927. return err.Error()
  3928. }
  3929. fmt.Println(string(respBytes))
  3930. str := string(respBytes)
  3931. return str
  3932. }
  3933. 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) {
  3934. //生成签名
  3935. nonce := GetRandomString(32)
  3936. timestamp := time.Now().Unix()
  3937. signature := setSignature(timestamp, nonce, secret_key)
  3938. //生成输入报文
  3939. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3940. input := make(map[string]interface{})
  3941. inputData := make(map[string]interface{})
  3942. inputMessage["infno"] = "1101" // 交易编码
  3943. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  3944. inputData["card_sn"] = "" // 卡识别码
  3945. inputData["certno"] = idNo // 证件号码
  3946. inputData["psn_cert_type"] = "01" // 人员证件类型
  3947. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  3948. inputData["begntime"] = "" // 开始时间
  3949. inputData["psn_name"] = user_name // 人员姓名
  3950. input["data"] = inputData
  3951. inputMessage["input"] = input //交易输入
  3952. bytesData, err := json.Marshal(inputMessage)
  3953. fmt.Println(string(bytesData))
  3954. if err != nil {
  3955. fmt.Println(err.Error())
  3956. return err.Error(), ""
  3957. }
  3958. reader := bytes.NewReader(bytesData)
  3959. gdyb_url := beego.AppConfig.String("gdyb_url")
  3960. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3961. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  3962. //url := gdyb_url + "1101"
  3963. var url string
  3964. if fixmedins_code == "H15049901371" {
  3965. url = gdyb_url
  3966. } else {
  3967. url = gdyb_url + "1101"
  3968. }
  3969. fmt.Println(url)
  3970. fmt.Println(gdyb_paasid)
  3971. fmt.Println(secret_key)
  3972. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  3973. request, err := http.NewRequest("POST", url, reader)
  3974. if err != nil {
  3975. fmt.Println(err.Error())
  3976. return err.Error(), ""
  3977. }
  3978. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3979. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3980. request.Header.Set("x-tif-signature", signature)
  3981. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3982. request.Header.Set("x-tif-nonce", nonce)
  3983. client := http.Client{}
  3984. resp, err := client.Do(request)
  3985. if err != nil {
  3986. fmt.Println(err.Error())
  3987. return err.Error(), ""
  3988. }
  3989. respBytes, err := ioutil.ReadAll(resp.Body)
  3990. if err != nil {
  3991. fmt.Println(err.Error())
  3992. return err.Error(), ""
  3993. }
  3994. fmt.Println(string(respBytes))
  3995. str := string(respBytes)
  3996. return str, string(bytesData)
  3997. }
  3998. 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) {
  3999. //生成签名
  4000. nonce := GetRandomString(32)
  4001. timestamp := time.Now().Unix()
  4002. signature := setSignature(timestamp, nonce, secret_key)
  4003. //生成输入报文
  4004. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4005. input := make(map[string]interface{})
  4006. inputData := make(map[string]interface{})
  4007. inputMessage["infno"] = "1101" // 交易编码
  4008. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  4009. inputData["card_sn"] = "" // 卡识别码
  4010. inputData["certno"] = idNo // 证件号码
  4011. inputData["psn_cert_type"] = "01" // 人员证件类型
  4012. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  4013. inputData["begntime"] = "" // 开始时间
  4014. inputData["psn_name"] = user_name // 人员姓名
  4015. input["data"] = inputData
  4016. inputMessage["input"] = input //交易输入
  4017. bytesData, err := json.Marshal(inputMessage)
  4018. fmt.Println(string(bytesData))
  4019. if err != nil {
  4020. fmt.Println(err.Error())
  4021. return err.Error(), ""
  4022. }
  4023. reader := bytes.NewReader(bytesData)
  4024. gdyb_url := beego.AppConfig.String("gdyb_url")
  4025. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4026. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4027. //url := gdyb_url + "1101"
  4028. var url string
  4029. if fixmedins_code == "H15049901371" {
  4030. url = gdyb_url
  4031. } else {
  4032. url = gdyb_url + "1101"
  4033. }
  4034. fmt.Println(url)
  4035. fmt.Println(gdyb_paasid)
  4036. fmt.Println(secret_key)
  4037. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4038. request, err := http.NewRequest("POST", url, reader)
  4039. if err != nil {
  4040. fmt.Println(err.Error())
  4041. return err.Error(), ""
  4042. }
  4043. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4044. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4045. request.Header.Set("x-tif-signature", signature)
  4046. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4047. request.Header.Set("x-tif-nonce", nonce)
  4048. client := http.Client{}
  4049. resp, err := client.Do(request)
  4050. if err != nil {
  4051. fmt.Println(err.Error())
  4052. return err.Error(), ""
  4053. }
  4054. respBytes, err := ioutil.ReadAll(resp.Body)
  4055. if err != nil {
  4056. fmt.Println(err.Error())
  4057. return err.Error(), ""
  4058. }
  4059. fmt.Println(string(respBytes))
  4060. str := string(respBytes)
  4061. return str, string(bytesData)
  4062. }
  4063. func Gdyb6101(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) (string, string) {
  4064. //生成签名
  4065. nonce := GetRandomString(32)
  4066. timestamp := time.Now().Unix()
  4067. signature := setSignature(timestamp, nonce, secret_key)
  4068. //生成输入报文
  4069. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4070. input := make(map[string]interface{})
  4071. inputData := make(map[string]interface{})
  4072. inputMessage["infno"] = "6101" // 交易编码
  4073. inputData["orgId"] = fixmedins_code // 就诊凭证类型
  4074. inputData["businessType"] = "01101" // 卡识别码
  4075. inputData["businessInfo"] = "" // 证件号码
  4076. inputData["operateorId"] = "01" // 人员证件类型
  4077. inputData["operateornName"] = doctor // 就诊凭证编号
  4078. inputData["officeId"] = "01" // 开始时间
  4079. inputData["officeName"] = "血透" // 人员姓名
  4080. inputData["deviceType"] = "" // 人员姓名
  4081. input["InData"] = inputData
  4082. inputMessage["input"] = input //交易输入
  4083. bytesData, err := json.Marshal(inputMessage)
  4084. fmt.Println(string(bytesData))
  4085. if err != nil {
  4086. fmt.Println(err.Error())
  4087. return err.Error(), ""
  4088. }
  4089. reader := bytes.NewReader(bytesData)
  4090. gdyb_url := beego.AppConfig.String("gdyb_url")
  4091. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4092. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4093. //url := gdyb_url + "1101"
  4094. var url string
  4095. if fixmedins_code == "H15049901371" {
  4096. url = gdyb_url
  4097. } else {
  4098. url = gdyb_url + "1101"
  4099. }
  4100. fmt.Println(url)
  4101. fmt.Println(gdyb_paasid)
  4102. fmt.Println(secret_key)
  4103. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4104. request, err := http.NewRequest("POST", url, reader)
  4105. if err != nil {
  4106. fmt.Println(err.Error())
  4107. return err.Error(), ""
  4108. }
  4109. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4110. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4111. request.Header.Set("x-tif-signature", signature)
  4112. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4113. request.Header.Set("x-tif-nonce", nonce)
  4114. client := http.Client{}
  4115. resp, err := client.Do(request)
  4116. if err != nil {
  4117. fmt.Println(err.Error())
  4118. return err.Error(), ""
  4119. }
  4120. respBytes, err := ioutil.ReadAll(resp.Body)
  4121. if err != nil {
  4122. fmt.Println(err.Error())
  4123. return err.Error(), ""
  4124. }
  4125. fmt.Println(string(respBytes))
  4126. str := string(respBytes)
  4127. return str, string(bytesData)
  4128. }
  4129. // 人员信息版本4
  4130. 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) {
  4131. //生成签名
  4132. nonce := GetRandomString(32)
  4133. timestamp := time.Now().Unix()
  4134. //signature := setSignature(timestamp, nonce, secret_key)
  4135. //生成输入报文
  4136. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4137. input := make(map[string]interface{})
  4138. inputData := make(map[string]interface{})
  4139. inputMessage["infno"] = "1101" // 交易编码
  4140. if certificates == 3 {
  4141. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  4142. inputData["certno"] = certNo // 证件号码
  4143. inputData["psn_cert_type"] = "99" // 人员证件类型
  4144. } else {
  4145. if id_card_type == 1 {
  4146. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  4147. inputData["card_sn"] = "" // 卡识别码
  4148. inputData["certno"] = "" // 证件号码
  4149. inputData["psn_cert_type"] = "" // 人员证件类型
  4150. } else {
  4151. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  4152. inputData["card_sn"] = "" // 卡识别码
  4153. inputData["certno"] = certNo // 证件号码
  4154. inputData["psn_cert_type"] = "1" // 人员证件类型
  4155. }
  4156. }
  4157. inputData["mdtrt_cert_no"] = "" // 就诊凭证编号
  4158. inputData["begntime"] = "" // 开始时间
  4159. inputData["psn_name"] = "" // 人员姓名
  4160. input["data"] = inputData
  4161. inputMessage["input"] = input //交易输入
  4162. bytesData, err := json.Marshal(inputMessage)
  4163. fmt.Println(string(bytesData))
  4164. if err != nil {
  4165. fmt.Println(err.Error())
  4166. return err.Error(), ""
  4167. }
  4168. var json2 string
  4169. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  4170. out, err := cmd.Output()
  4171. if err != nil {
  4172. fmt.Println("error:", err.Error())
  4173. }
  4174. fmt.Println(string(out))
  4175. return string(out), string(bytesData)
  4176. }
  4177. func StrPtr(s string) uintptr {
  4178. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  4179. }
  4180. 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 {
  4181. //生成签名
  4182. nonce := GetRandomString(32)
  4183. timestamp := time.Now().Unix()
  4184. signature := setSignature(timestamp, nonce, secret_key)
  4185. //生成输入报文
  4186. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4187. input := make(map[string]interface{})
  4188. inputData := make(map[string]interface{})
  4189. inputMessage["infno"] = "90991" // 交易编码
  4190. inputData["fixmedins_code"] = fixmedins_code // 就诊凭证编号
  4191. inputData["psn_no"] = psn_no // 开始时间
  4192. inputData["card_pwd"] = pwd // 人员姓名
  4193. inputData["sscno"] = card_number // 人员姓名
  4194. input["data"] = inputData
  4195. inputMessage["input"] = input //交易输入
  4196. bytesData, err := json.Marshal(inputMessage)
  4197. fmt.Println(string(bytesData))
  4198. if err != nil {
  4199. fmt.Println(err.Error())
  4200. return err.Error()
  4201. }
  4202. reader := bytes.NewReader(bytesData)
  4203. gdyb_url := beego.AppConfig.String("gdyb_url")
  4204. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4205. url := gdyb_url + "90991"
  4206. request, err := http.NewRequest("POST", url, reader)
  4207. if err != nil {
  4208. fmt.Println(err.Error())
  4209. return err.Error()
  4210. }
  4211. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4212. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4213. request.Header.Set("x-tif-signature", signature)
  4214. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4215. request.Header.Set("x-tif-nonce", nonce)
  4216. client := http.Client{}
  4217. resp, err := client.Do(request)
  4218. if err != nil {
  4219. fmt.Println(err.Error())
  4220. return err.Error()
  4221. }
  4222. respBytes, err := ioutil.ReadAll(resp.Body)
  4223. if err != nil {
  4224. fmt.Println(err.Error())
  4225. return err.Error()
  4226. }
  4227. fmt.Println(string(respBytes))
  4228. str := string(respBytes)
  4229. return str
  4230. }
  4231. func Gdyb90100(psn_no string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  4232. //生成签名
  4233. nonce := GetRandomString(32)
  4234. timestamp := time.Now().Unix()
  4235. signature := setSignature(timestamp, nonce, secret_key)
  4236. //生成输入报文
  4237. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4238. input := make(map[string]interface{})
  4239. inputData := make(map[string]interface{})
  4240. inputMessage["infno"] = "90100" // 交易编码
  4241. inputData["psn_no"] = psn_no // 开始时间
  4242. input["data"] = inputData
  4243. inputMessage["input"] = input //交易输入
  4244. bytesData, err := json.Marshal(inputMessage)
  4245. fmt.Println(string(bytesData))
  4246. if err != nil {
  4247. fmt.Println(err.Error())
  4248. return err.Error()
  4249. }
  4250. reader := bytes.NewReader(bytesData)
  4251. gdyb_url := beego.AppConfig.String("gdyb_url")
  4252. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4253. url := gdyb_url + "90100"
  4254. request, err := http.NewRequest("POST", url, reader)
  4255. if err != nil {
  4256. fmt.Println(err.Error())
  4257. return err.Error()
  4258. }
  4259. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4260. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4261. request.Header.Set("x-tif-signature", signature)
  4262. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4263. request.Header.Set("x-tif-nonce", nonce)
  4264. client := http.Client{}
  4265. resp, err := client.Do(request)
  4266. if err != nil {
  4267. fmt.Println(err.Error())
  4268. return err.Error()
  4269. }
  4270. respBytes, err := ioutil.ReadAll(resp.Body)
  4271. if err != nil {
  4272. fmt.Println(err.Error())
  4273. return err.Error()
  4274. }
  4275. fmt.Println(string(respBytes))
  4276. str := string(respBytes)
  4277. return str
  4278. }
  4279. 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) {
  4280. //生成签名
  4281. nonce := GetRandomString(32)
  4282. timestamp := time.Now().Unix()
  4283. signature := setSignature(timestamp, nonce, secret_key)
  4284. //生成输入报文
  4285. inputMessage := SetInputMessageTwo(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, sign)
  4286. input := make(map[string]interface{})
  4287. inputData := make(map[string]interface{})
  4288. inputMessage["infno"] = "3260" // 交易编码
  4289. inputData["sign"] = sign // 就诊凭证编号
  4290. inputData["trt_year"] = year // 就诊凭证编号
  4291. inputData["trt_month"] = month // 开始时间
  4292. inputData["startrow"] = count // 人员姓名
  4293. input["data"] = inputData
  4294. inputMessage["input"] = input //交易输入
  4295. var inputLog string
  4296. bytesData, err := json.Marshal(inputMessage)
  4297. inputLog = string(bytesData)
  4298. fmt.Println(string(bytesData))
  4299. if err != nil {
  4300. fmt.Println(err.Error())
  4301. return err.Error(), ""
  4302. }
  4303. reader := bytes.NewReader(bytesData)
  4304. gdyb_url := beego.AppConfig.String("gdyb_url")
  4305. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4306. var url string
  4307. if fixmedins_code == "H15049901371" {
  4308. url = gdyb_url
  4309. } else {
  4310. url = gdyb_url + "3260"
  4311. }
  4312. if insuplc_admdvs == "421300" {
  4313. var json2 string
  4314. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  4315. out, err := cmd.Output()
  4316. if err != nil {
  4317. fmt.Println("error:", err.Error())
  4318. }
  4319. fmt.Println(string(out))
  4320. return hex.EncodeToString(out), inputLog
  4321. } else {
  4322. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4323. request, err := http.NewRequest("POST", url, reader)
  4324. if err != nil {
  4325. fmt.Println(err.Error())
  4326. return err.Error(), ""
  4327. }
  4328. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4329. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4330. request.Header.Set("x-tif-signature", signature)
  4331. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4332. request.Header.Set("x-tif-nonce", nonce)
  4333. client := http.Client{}
  4334. resp, err := client.Do(request)
  4335. if err != nil {
  4336. fmt.Println(err.Error())
  4337. return err.Error(), ""
  4338. }
  4339. respBytes, err := ioutil.ReadAll(resp.Body)
  4340. if err != nil {
  4341. fmt.Println(err.Error())
  4342. return err.Error(), ""
  4343. }
  4344. fmt.Println(string(respBytes))
  4345. str := string(respBytes)
  4346. return str, inputLog
  4347. }
  4348. }
  4349. 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) {
  4350. //msg_month := time.Unix(1557042972, 0).Format("1")
  4351. //msg_year := time.Now().Format("2006")
  4352. //msg_month = time.Now().Format("01")
  4353. //day := time.Now().Format("02")
  4354. //
  4355. //hour := time.Now().Format("15")
  4356. //min := time.Now().Format("04")
  4357. //sec := time.Now().Format("05")
  4358. //
  4359. //msec := time.Now().Format("000")
  4360. //msg_id := fixmedins_code + msg_year + msg_month + day + hour + min + sec + msec + "0"
  4361. //生成输入报文
  4362. var curpage int
  4363. var pagesize int = 10
  4364. var start int = 1
  4365. var stop int
  4366. //pagecount := 10
  4367. pagecount := int(math.Ceil(float64(len(result3260.Output.Data)) / float64(pagesize)))
  4368. for curpage = 1; curpage <= pagecount; curpage++ {
  4369. //生成签名
  4370. nonce := GetRandomString(32)
  4371. timestamp := time.Now().Unix()
  4372. signature := setSignature(timestamp, nonce, secret_key)
  4373. inputMessage := SetInputMessageTwo(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, sign_no)
  4374. input := make(map[string]interface{})
  4375. inputData := make(map[string]interface{})
  4376. inputMessage["infno"] = "3261" // 交易编码
  4377. inputData["trt_year"] = year // 就诊凭证编号
  4378. inputData["trt_month"] = month // 开始时间
  4379. feedetail := make([]map[string]interface{}, 0)
  4380. if curpage == 1 {
  4381. start = 1
  4382. } else {
  4383. start = (curpage-1)*pagesize + 1
  4384. }
  4385. stop = curpage * pagesize
  4386. if stop > len(result3260.Output.Data) {
  4387. stop = len(result3260.Output.Data)
  4388. }
  4389. for _, item := range result3260.Output.Data[start-1 : stop] {
  4390. if item.MdtrtId != "out20230406681871" && item.MdtrtId != "out20230406681868" && item.MdtrtId != "out202306301104036" {
  4391. if item.SetlSn != "420100G9000712542625" {
  4392. feedetailInfo := make(map[string]interface{})
  4393. feedetailInfo["certno"] = item.Certno
  4394. feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  4395. feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  4396. feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  4397. feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  4398. feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  4399. feedetailInfo["cnfm_flag"] = "1" // 处方号
  4400. feedetail = append(feedetail, feedetailInfo)
  4401. }
  4402. }
  4403. }
  4404. for _, item := range result3260.Output.Data[start-1 : stop] {
  4405. if item.MdtrtId == "out20230406681871" {
  4406. feedetailInfo := make(map[string]interface{})
  4407. feedetailInfo["certno"] = item.Certno
  4408. feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  4409. feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  4410. feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  4411. feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  4412. feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  4413. feedetailInfo["cnfm_flag"] = "0" // 处方号
  4414. feedetail = append(feedetail, feedetailInfo)
  4415. }
  4416. }
  4417. for _, item := range result3260.Output.Data[start-1 : stop] {
  4418. if item.MdtrtId == "out20230406681868" {
  4419. feedetailInfo := make(map[string]interface{})
  4420. feedetailInfo["certno"] = item.Certno
  4421. feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  4422. feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  4423. feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  4424. feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  4425. feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  4426. feedetailInfo["cnfm_flag"] = "0" // 处方号
  4427. feedetail = append(feedetail, feedetailInfo)
  4428. }
  4429. }
  4430. //for _, item := range result3260.Output.Data[start-1 : stop] {
  4431. // if item.MdtrtId == "out20230418732788" {
  4432. // feedetailInfo := make(map[string]interface{})
  4433. // feedetailInfo["certno"] = item.Certno
  4434. // feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  4435. // feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  4436. // feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  4437. // feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  4438. // feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  4439. // feedetailInfo["cnfm_flag"] = "0" // 处方号
  4440. // feedetail = append(feedetail, feedetailInfo)
  4441. // }
  4442. //
  4443. //}
  4444. //for _, item := range result3260.Output.Data[start-1 : stop] {
  4445. // if item.SetlSn == "420100G9000712542625" {
  4446. // feedetailInfo := make(map[string]interface{})
  4447. // feedetailInfo["certno"] = item.Certno
  4448. // feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  4449. // feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  4450. // feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  4451. // feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  4452. // feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  4453. // feedetailInfo["cnfm_flag"] = "0" // 处方号
  4454. // feedetail = append(feedetail, feedetailInfo)
  4455. // }
  4456. //
  4457. //}
  4458. inputData["totalrow"] = 174 // 人员姓名
  4459. // 创建一个新的 Excel 文件
  4460. //f := excelize.NewFile()
  4461. // 创建一个工作表
  4462. //index := f.NewSheet("Sheet1")
  4463. //for index, item := range result3260.Output.Data[start-1 : stop] {
  4464. //// // 设置单元格的值
  4465. // in := strconv.FormatInt(int64(index+1),10)
  4466. // f.SetCellValue("Sheet1", "A" +in , item.Certno)
  4467. // f.SetCellValue("Sheet1", "B"+in, item.MdtrtId)
  4468. // f.SetCellValue("Sheet1", "C"+in, item.SetlSn)
  4469. //}
  4470. //
  4471. //
  4472. //// 设置活动工作表
  4473. //f.SetActiveSheet(index)
  4474. //in2 := strconv.FormatInt(int64(curpage+1),10)
  4475. //
  4476. //
  4477. //// 保存文件
  4478. //if err := f.SaveAs("output"+in2+".xlsx"); err != nil {
  4479. // panic(err)
  4480. //}
  4481. input["data"] = inputData
  4482. input["detail"] = feedetail
  4483. inputMessage["input"] = input //交易输入
  4484. //var inputLog string
  4485. bytesData, err := json.Marshal(inputMessage)
  4486. //inputLog = string(bytesData)
  4487. fmt.Println(string(bytesData))
  4488. if err != nil {
  4489. fmt.Println(err.Error())
  4490. return
  4491. }
  4492. reader := bytes.NewReader(bytesData)
  4493. gdyb_url := beego.AppConfig.String("gdyb_url")
  4494. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4495. var url string
  4496. if fixmedins_code == "H15049901371" {
  4497. url = gdyb_url
  4498. } else {
  4499. url = gdyb_url + "3261"
  4500. }
  4501. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4502. request, err := http.NewRequest("POST", url, reader)
  4503. if err != nil {
  4504. fmt.Println(err.Error())
  4505. return
  4506. }
  4507. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4508. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4509. request.Header.Set("x-tif-signature", signature)
  4510. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4511. request.Header.Set("x-tif-nonce", nonce)
  4512. client := http.Client{}
  4513. resp, err := client.Do(request)
  4514. if err != nil {
  4515. fmt.Println(err.Error())
  4516. return
  4517. }
  4518. respBytes, err := ioutil.ReadAll(resp.Body)
  4519. if err != nil {
  4520. fmt.Println(err.Error())
  4521. return
  4522. }
  4523. fmt.Println(string(respBytes))
  4524. str := string(respBytes)
  4525. fmt.Println(str)
  4526. //return str, inputLog, msg_id
  4527. }
  4528. return
  4529. }
  4530. 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) {
  4531. //生成签名
  4532. nonce := GetRandomString(32)
  4533. timestamp := time.Now().Unix()
  4534. signature := setSignature(timestamp, nonce, secret_key)
  4535. //生成输入报文
  4536. inputMessage := SetInputMessageTwo(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, sign_no)
  4537. input := make(map[string]interface{})
  4538. inputData := make(map[string]interface{})
  4539. inputMessage["infno"] = "3262" // 交易编码
  4540. inputData["trt_year"] = year // 就诊凭证编号
  4541. inputData["trt_month"] = "07" // 开始时间
  4542. inputData["otransid"] = "0" // 开始时间
  4543. input["data"] = inputData
  4544. inputMessage["input"] = input //交易输入
  4545. var inputLog string
  4546. bytesData, err := json.Marshal(inputMessage)
  4547. inputLog = string(bytesData)
  4548. fmt.Println(string(bytesData))
  4549. if err != nil {
  4550. fmt.Println(err.Error())
  4551. return err.Error(), ""
  4552. }
  4553. reader := bytes.NewReader(bytesData)
  4554. gdyb_url := beego.AppConfig.String("gdyb_url")
  4555. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4556. var url string
  4557. if fixmedins_code == "H15049901371" {
  4558. url = gdyb_url
  4559. } else {
  4560. url = gdyb_url + "3262"
  4561. }
  4562. if insuplc_admdvs == "421300" {
  4563. var json2 string
  4564. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  4565. out, err := cmd.Output()
  4566. if err != nil {
  4567. fmt.Println("error:", err.Error())
  4568. }
  4569. fmt.Println(string(out))
  4570. return hex.EncodeToString(out), inputLog
  4571. } else {
  4572. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4573. request, err := http.NewRequest("POST", url, reader)
  4574. if err != nil {
  4575. fmt.Println(err.Error())
  4576. return err.Error(), ""
  4577. }
  4578. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4579. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4580. request.Header.Set("x-tif-signature", signature)
  4581. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4582. request.Header.Set("x-tif-nonce", nonce)
  4583. client := http.Client{}
  4584. resp, err := client.Do(request)
  4585. if err != nil {
  4586. fmt.Println(err.Error())
  4587. return err.Error(), ""
  4588. }
  4589. respBytes, err := ioutil.ReadAll(resp.Body)
  4590. if err != nil {
  4591. fmt.Println(err.Error())
  4592. return err.Error(), ""
  4593. }
  4594. fmt.Println(string(respBytes))
  4595. str := string(respBytes)
  4596. return str, inputLog
  4597. }
  4598. }
  4599. 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) {
  4600. //生成签名
  4601. nonce := GetRandomString(32)
  4602. timestamp := time.Now().Unix()
  4603. signature := setSignature(timestamp, nonce, "d6Ad0P1B3z6Dsdst0gYAFPlz8YlIvFDx")
  4604. //生成输入报文
  4605. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4606. input := make(map[string]interface{})
  4607. inputData := make(map[string]interface{})
  4608. inputMessage["infno"] = "9001" // 交易编码
  4609. inputData["opter_no"] = admin_user_id // 就诊凭证编号
  4610. inputData["mac"] = "11-11-11-11-11" // 开始时间
  4611. inputData["ip"] = "11.11.11.11"
  4612. inputData["userid"] = "H44010400081"
  4613. month := time.Unix(1557042972, 0).Format("1")
  4614. year := time.Now().Format("2006")
  4615. month = time.Now().Format("01")
  4616. day := time.Now().Format("02")
  4617. hour := time.Now().Format("15")
  4618. min := time.Now().Format("04")
  4619. sec := time.Now().Format("05")
  4620. custom_time := year + month + day + hour + min + sec
  4621. inputData["currenttime"] = custom_time
  4622. var psd string
  4623. psd = custom_time + "Gzyb$867"
  4624. h := md5.New()
  4625. h.Write([]byte(psd))
  4626. inputData["password"] = strings.ToUpper(hex.EncodeToString(h.Sum(nil)))
  4627. input["data"] = inputData
  4628. inputMessage["input"] = input //交易输入
  4629. var inputLog string
  4630. bytesData, err := json.Marshal(inputMessage)
  4631. inputLog = string(bytesData)
  4632. fmt.Println(string(bytesData))
  4633. if err != nil {
  4634. fmt.Println(err.Error())
  4635. return err.Error(), ""
  4636. }
  4637. reader := bytes.NewReader(bytesData)
  4638. gdyb_url := beego.AppConfig.String("gdyb_url")
  4639. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4640. var url string
  4641. if fixmedins_code == "H15049901371" {
  4642. url = gdyb_url
  4643. } else {
  4644. url = gdyb_url + "9001"
  4645. }
  4646. if insuplc_admdvs == "421300" {
  4647. var json2 string
  4648. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  4649. out, err := cmd.Output()
  4650. if err != nil {
  4651. fmt.Println("error:", err.Error())
  4652. }
  4653. fmt.Println(string(out))
  4654. return hex.EncodeToString(out), inputLog
  4655. } else {
  4656. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4657. request, err := http.NewRequest("POST", url, reader)
  4658. if err != nil {
  4659. fmt.Println(err.Error())
  4660. return err.Error(), ""
  4661. }
  4662. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4663. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4664. request.Header.Set("x-tif-signature", signature)
  4665. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4666. request.Header.Set("x-tif-nonce", nonce)
  4667. fmt.Println(string(bytesData))
  4668. fmt.Println(gdyb_url)
  4669. fmt.Println(gdyb_paasid)
  4670. fmt.Println(request.Header)
  4671. client := http.Client{}
  4672. resp, err := client.Do(request)
  4673. if err != nil {
  4674. fmt.Println(err.Error())
  4675. return err.Error(), ""
  4676. }
  4677. respBytes, err := ioutil.ReadAll(resp.Body)
  4678. if err != nil {
  4679. fmt.Println(err.Error())
  4680. return err.Error(), ""
  4681. }
  4682. fmt.Println(string(respBytes))
  4683. str := string(respBytes)
  4684. return str, inputLog
  4685. }
  4686. }
  4687. 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) {
  4688. //生成签名
  4689. nonce := GetRandomString(32)
  4690. timestamp := time.Now().Unix()
  4691. signature := setSignature(timestamp, nonce, secret_key)
  4692. //生成输入报文
  4693. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4694. input := make(map[string]interface{})
  4695. inputData := make(map[string]interface{})
  4696. inputMessage["infno"] = "9001" // 交易编码
  4697. inputData["opter_no"] = admin_user_id // 就诊凭证编号
  4698. inputData["mac"] = GetMac() // 开始时间
  4699. inputData["ip"] = GetLocalIp()
  4700. input["signIn"] = inputData
  4701. inputMessage["input"] = input //交易输入
  4702. var inputLog string
  4703. bytesData, err := json.Marshal(inputMessage)
  4704. inputLog = string(bytesData)
  4705. fmt.Println(string(bytesData))
  4706. if err != nil {
  4707. fmt.Println(err.Error())
  4708. return err.Error(), ""
  4709. }
  4710. reader := bytes.NewReader(bytesData)
  4711. gdyb_url := beego.AppConfig.String("gdyb_url")
  4712. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4713. var url string
  4714. if fixmedins_code == "H15049901371" {
  4715. url = gdyb_url
  4716. } else {
  4717. url = gdyb_url + "9001"
  4718. }
  4719. if insuplc_admdvs == "421300" {
  4720. var json2 string
  4721. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  4722. out, err := cmd.Output()
  4723. if err != nil {
  4724. fmt.Println("error:", err.Error())
  4725. }
  4726. fmt.Println(string(out))
  4727. return hex.EncodeToString(out), inputLog
  4728. } else {
  4729. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4730. request, err := http.NewRequest("POST", url, reader)
  4731. if err != nil {
  4732. fmt.Println(err.Error())
  4733. return err.Error(), ""
  4734. }
  4735. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4736. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4737. request.Header.Set("x-tif-signature", signature)
  4738. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4739. request.Header.Set("x-tif-nonce", nonce)
  4740. fmt.Println(string(bytesData))
  4741. fmt.Println(gdyb_url)
  4742. fmt.Println(gdyb_paasid)
  4743. fmt.Println(request.Header)
  4744. client := http.Client{}
  4745. resp, err := client.Do(request)
  4746. if err != nil {
  4747. fmt.Println(err.Error())
  4748. return err.Error(), ""
  4749. }
  4750. respBytes, err := ioutil.ReadAll(resp.Body)
  4751. if err != nil {
  4752. fmt.Println(err.Error())
  4753. return err.Error(), ""
  4754. }
  4755. fmt.Println(string(respBytes))
  4756. str := string(respBytes)
  4757. return str, inputLog
  4758. }
  4759. }
  4760. // 获取本机ip
  4761. func GetLocalIp() string {
  4762. addrs, err := net.InterfaceAddrs()
  4763. if err != nil {
  4764. fmt.Println("get local ip failed")
  4765. }
  4766. for _, address := range addrs {
  4767. if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
  4768. if ipnet.IP.To4() != nil {
  4769. return ipnet.IP.String()
  4770. }
  4771. }
  4772. }
  4773. return ""
  4774. }
  4775. // 获取本机Mac
  4776. func GetMac() string {
  4777. interfaces, err := net.Interfaces()
  4778. if err != nil {
  4779. fmt.Println("Get loacl Mac failed")
  4780. }
  4781. for _, inter := range interfaces {
  4782. mac := inter.HardwareAddr
  4783. fmt.Println("+======" + mac.String())
  4784. if mac.String() != "" {
  4785. return mac.String()
  4786. }
  4787. }
  4788. return ""
  4789. }
  4790. // 人员基本信息
  4791. 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) {
  4792. //生成签名
  4793. fmt.Println("DDDDD")
  4794. nonce := GetRandomString(32)
  4795. timestamp := time.Now().Unix()
  4796. signature := setSignature(timestamp, nonce, secret_key)
  4797. //生成输入报文
  4798. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4799. input := make(map[string]interface{})
  4800. inputData := make(map[string]interface{})
  4801. inputMessage["infno"] = "1101" // 交易编码
  4802. if certificates == "3" {
  4803. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  4804. inputData["certno"] = certNo // 证件号码
  4805. inputData["psn_cert_type"] = "99" // 人员证件类型
  4806. } else {
  4807. if certificates == "1" {
  4808. if id_card_type == 1 {
  4809. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  4810. inputData["card_sn"] = "" // 卡识别码
  4811. inputData["certno"] = certNo // 证件号码
  4812. inputData["psn_cert_type"] = "01" // 人员证件类型
  4813. } else if id_card_type == 4 {
  4814. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  4815. inputData["certno"] = certNo // 证件号码
  4816. inputData["psn_cert_type"] = "01" // 人员证件类型
  4817. } else {
  4818. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  4819. inputData["card_sn"] = "" // 卡识别码
  4820. inputData["certno"] = certNo // 证件号码
  4821. inputData["psn_cert_type"] = "01" // 人员证件类型
  4822. }
  4823. } else if certificates == "6" {
  4824. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  4825. inputData["card_sn"] = "" // 卡识别码
  4826. inputData["certno"] = certNo // 证件号码
  4827. inputData["psn_cert_type"] = "17" // 人员证件类型
  4828. }
  4829. }
  4830. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  4831. inputData["begntime"] = "" // 开始时间
  4832. inputData["psn_name"] = "" // 人员姓名
  4833. input["data"] = inputData
  4834. inputMessage["input"] = input //交易输入
  4835. var inputLog string
  4836. bytesData, err := json.Marshal(inputMessage)
  4837. inputLog = string(bytesData)
  4838. fmt.Println(string(bytesData))
  4839. if err != nil {
  4840. fmt.Println(err.Error())
  4841. return err.Error(), ""
  4842. }
  4843. reader := bytes.NewReader(bytesData)
  4844. gdyb_url := beego.AppConfig.String("gdyb_url")
  4845. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4846. //DllDef := syscall.MustLoadDLL("yh_hb_sctrl.dll")
  4847. //Iinit := DllDef.MustFindProc("yh_hb_call")
  4848. //var str3 string
  4849. //ret, _, _ := Iinit.Call(StrPtr("1101"), StrPtr(string(bytesData)), StrPtr(str3))
  4850. //fmt.Println(ret)
  4851. //fmt.Println(str3)
  4852. //
  4853. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4854. var url string
  4855. if fixmedins_code == "H15049901371" {
  4856. url = gdyb_url
  4857. } else {
  4858. url = gdyb_url + "1101"
  4859. }
  4860. if insuplc_admdvs == "421300" {
  4861. var json2 string
  4862. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  4863. out, err := cmd.Output()
  4864. if err != nil {
  4865. fmt.Println("error:", err.Error())
  4866. }
  4867. fmt.Println(string(out))
  4868. return hex.EncodeToString(out), inputLog
  4869. } else {
  4870. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4871. request, err := http.NewRequest("POST", url, reader)
  4872. if err != nil {
  4873. fmt.Println(err.Error())
  4874. return err.Error(), ""
  4875. }
  4876. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4877. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4878. request.Header.Set("x-tif-signature", signature)
  4879. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4880. request.Header.Set("x-tif-nonce", nonce)
  4881. client := http.Client{}
  4882. resp, err := client.Do(request)
  4883. if err != nil {
  4884. fmt.Println(err.Error())
  4885. return err.Error(), ""
  4886. }
  4887. respBytes, err := ioutil.ReadAll(resp.Body)
  4888. if err != nil {
  4889. fmt.Println(err.Error())
  4890. return err.Error(), ""
  4891. }
  4892. fmt.Println(string(respBytes))
  4893. str := string(respBytes)
  4894. return str, inputLog
  4895. }
  4896. }
  4897. //func SetInputMessageFour(nonce string, timestamp int64, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) map[string]interface{} {
  4898. // // 生成签名
  4899. // //tempTime := time.Unix(timestamp, 0)
  4900. // //timeFormat := tempTime.Format("20060102150405")
  4901. // //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  4902. // //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  4903. //
  4904. // msec := time.Now().Format("000")
  4905. // fmt.Println(utils.GetNetTime())
  4906. // // 生成输入报文
  4907. // inputMessage := make(map[string]interface{})
  4908. // inputMessage["msgid"] = fixmedins_code + utils.GetNetTime() + msec + "0" // 发送方报文 ID
  4909. // inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  4910. // inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  4911. // inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  4912. // inputMessage["dev_no"] = "" // 设备编号
  4913. // inputMessage["dev_safe_info"] = "" // 设备安全信息
  4914. // inputMessage["cainfo"] = "" // 数字签名信息
  4915. // inputMessage["signtype"] = "SM3" // 签名类型
  4916. // inputMessage["infver"] = "V1.0" // 接收方系统代码
  4917. // inputMessage["opter_type"] = "1" // 经办人类别
  4918. // inputMessage["opter"] = doctor // 经办人
  4919. // inputMessage["opter_name"] = doctor // 经办人姓名
  4920. // inputMessage["inf_time"] = utils.GetNetTime() // 交易时间
  4921. // inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  4922. // inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  4923. // inputMessage["sign_no"] = "" //交易签到流水号
  4924. // return inputMessage
  4925. //}
  4926. func Gdyb5302(psnNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  4927. // 生成签名
  4928. nonce := GetRandomString(32)
  4929. timestamp := time.Now().Unix()
  4930. signature := setSignature(timestamp, nonce, secret_key)
  4931. // 生成输入报文
  4932. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4933. input := make(map[string]interface{})
  4934. inputData := make(map[string]interface{})
  4935. inputMessage["infno"] = "5302" // 交易编码
  4936. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  4937. inputData["biz_appy_type"] = "03" // 人员编号 (来自1101接口返回)
  4938. input["data"] = inputData
  4939. inputMessage["input"] = input //交易输入
  4940. bytesData, err := json.Marshal(inputMessage)
  4941. fmt.Println(string(bytesData))
  4942. if err != nil {
  4943. fmt.Println(err.Error())
  4944. return err.Error()
  4945. }
  4946. reader := bytes.NewReader(bytesData)
  4947. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  4948. gdyb_url := beego.AppConfig.String("gdyb_url")
  4949. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4950. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4951. url := gdyb_url + "5302"
  4952. request, err := http.NewRequest("POST", url, reader)
  4953. if err != nil {
  4954. fmt.Println(err.Error())
  4955. return err.Error()
  4956. }
  4957. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4958. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4959. request.Header.Set("x-tif-signature", signature)
  4960. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4961. request.Header.Set("x-tif-nonce", nonce)
  4962. client := http.Client{}
  4963. resp, err := client.Do(request)
  4964. if err != nil {
  4965. fmt.Println(err.Error())
  4966. return err.Error()
  4967. }
  4968. respBytes, err := ioutil.ReadAll(resp.Body)
  4969. if err != nil {
  4970. fmt.Println(err.Error())
  4971. return err.Error()
  4972. }
  4973. str := string(respBytes)
  4974. fmt.Println(str)
  4975. return str
  4976. }
  4977. func CreateSignIn(record *models.HisSignIn) (err error) {
  4978. err = writeDb.Save(&record).Error
  4979. return
  4980. }
  4981. func GetSignInInfo(code string) string {
  4982. var sign models.HisSignIn
  4983. err = readDb.Model(&models.HisSignIn{}).Where("fixmedins_code = ? AND status = 1", code).Last(&sign).Error
  4984. return sign.SignNo
  4985. }
  4986. func Gdyb3501(struct3501 models.Struct3501, secret_key string) string {
  4987. // 生成签名
  4988. nonce := GetRandomString(32)
  4989. timestamp := time.Now().Unix()
  4990. signature := setSignature(timestamp, nonce, secret_key)
  4991. // 生成输入报文
  4992. inputMessage := SetGdInputMessage(timestamp, struct3501.OrgName, struct3501.Opter, struct3501.FixmedinsHilistId, struct3501.InsuplcAdmdvs, struct3501.MdtrtareaAdmvs, struct3501.Cainfo)
  4993. input := make(map[string]interface{})
  4994. inputData := make(map[string]interface{})
  4995. inputMessage["infno"] = "3501" // 交易编码
  4996. inputData["med_list_codg"] = struct3501.MedListCodg // 定点医药机构目录编号
  4997. inputData["fixmedins_hilist_id"] = struct3501.FixmedinsHilistId // 定点医药机构目录编号
  4998. inputData["fixmedins_hilist_name"] = struct3501.OrgName // 定点医药机构目录名称
  4999. inputData["rx_flag"] = struct3501.RxFlag //
  5000. inputData["invdate"] = struct3501.Invdate // 人员编号 (来自1101接口返回)
  5001. inputData["inv_cnt"] = struct3501.InvCnt // 人员编号 (来自1101接口返回)
  5002. inputData["manu_lotnum"] = struct3501.ManuLotnum // 人员编号 (来自1101接口返回)
  5003. inputData["fixmedins_bchno"] = struct3501.FixmedinsBchno // 人员编号 (来自1101接口返回)
  5004. inputData["manu_date"] = struct3501.ManuDate // 人员编号 (来自1101接口返回)
  5005. inputData["expy_end"] = struct3501.ExpyEnd // 人员编号 (来自1101接口返回)
  5006. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  5007. input["invinfo"] = inputData
  5008. inputMessage["input"] = input //交易输入
  5009. bytesData, err := json.Marshal(inputMessage)
  5010. fmt.Println(string(bytesData))
  5011. if err != nil {
  5012. fmt.Println(err.Error())
  5013. return err.Error()
  5014. }
  5015. reader := bytes.NewReader(bytesData)
  5016. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  5017. gdyb_url := beego.AppConfig.String("gdyb_url")
  5018. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5019. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  5020. url := gdyb_url + "3501"
  5021. request, err := http.NewRequest("POST", url, reader)
  5022. if err != nil {
  5023. fmt.Println(err.Error())
  5024. return err.Error()
  5025. }
  5026. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5027. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5028. request.Header.Set("x-tif-signature", signature)
  5029. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5030. request.Header.Set("x-tif-nonce", nonce)
  5031. client := http.Client{}
  5032. resp, err := client.Do(request)
  5033. if err != nil {
  5034. fmt.Println(err.Error())
  5035. return err.Error()
  5036. }
  5037. respBytes, err := ioutil.ReadAll(resp.Body)
  5038. if err != nil {
  5039. fmt.Println(err.Error())
  5040. return err.Error()
  5041. }
  5042. str := string(respBytes)
  5043. fmt.Println(str)
  5044. return str
  5045. }
  5046. func Gdyb3502(struct3502 models.Struct3502, secret_key string) string {
  5047. // 生成签名
  5048. nonce := GetRandomString(32)
  5049. timestamp := time.Now().Unix()
  5050. signature := setSignature(timestamp, nonce, secret_key)
  5051. // 生成输入报文
  5052. inputMessage := SetGdInputMessage(timestamp, struct3502.OrgName, struct3502.Opter, struct3502.FixmedinsCode, struct3502.InsuplcAdmdvs, struct3502.MdtrtareaAdmvs, struct3502.Cainfo)
  5053. input := make(map[string]interface{})
  5054. inputData := make(map[string]interface{})
  5055. inputMessage["infno"] = "3502" // 交易编码
  5056. inputData["med_list_codg"] = struct3502.MedListCodg // 定点医药机构目录编号
  5057. inputData["inv_chg_type"] = struct3502.InvChgType // 定点医药机构目录编号
  5058. inputData["fixmedins_hilist_id"] = struct3502.FixmedinsCode // 定点医药机构目录编号
  5059. inputData["fixmedins_hilist_name"] = struct3502.OrgName // 定点医药机构目录名称
  5060. inputData["fixmedins_bchno"] = struct3502.FixmedinsBchno // 人员编号 (来自1101接口返回)
  5061. inputData["pric"] = struct3502.Pric // 人员编号 (来自1101接口返回)
  5062. inputData["cnt"] = struct3502.Cnt // 人员编号 (来自1101接口返回)
  5063. inputData["rx_flag"] = struct3502.RxFlag //
  5064. inputData["inv_chg_time"] = struct3502.InvChgTime // 人员编号 (来自1101接口返回)
  5065. inputData["inv_chg_opter_name"] = "" // 人员编号 (来自1101接口返回)
  5066. inputData["memo"] = struct3502.Memo // 人员编号 (来自1101接口返回)
  5067. inputData["trdn_flag"] = "" // 人员编号 (来自1101接口返回)
  5068. input["invinfo"] = inputData
  5069. inputMessage["input"] = input //交易输入
  5070. bytesData, err := json.Marshal(inputMessage)
  5071. fmt.Println(string(bytesData))
  5072. if err != nil {
  5073. fmt.Println(err.Error())
  5074. return err.Error()
  5075. }
  5076. reader := bytes.NewReader(bytesData)
  5077. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  5078. gdyb_url := beego.AppConfig.String("gdyb_url")
  5079. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5080. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  5081. url := gdyb_url + "3502"
  5082. request, err := http.NewRequest("POST", url, reader)
  5083. if err != nil {
  5084. fmt.Println(err.Error())
  5085. return err.Error()
  5086. }
  5087. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5088. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5089. request.Header.Set("x-tif-signature", signature)
  5090. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5091. request.Header.Set("x-tif-nonce", nonce)
  5092. client := http.Client{}
  5093. resp, err := client.Do(request)
  5094. if err != nil {
  5095. fmt.Println(err.Error())
  5096. return err.Error()
  5097. }
  5098. respBytes, err := ioutil.ReadAll(resp.Body)
  5099. if err != nil {
  5100. fmt.Println(err.Error())
  5101. return err.Error()
  5102. }
  5103. str := string(respBytes)
  5104. fmt.Println(str)
  5105. return str
  5106. }
  5107. func Gdyb3503(struct3503 models.Struct3503, secret_key string) string {
  5108. // 生成签名
  5109. nonce := GetRandomString(32)
  5110. timestamp := time.Now().Unix()
  5111. signature := setSignature(timestamp, nonce, secret_key)
  5112. // 生成输入报文
  5113. inputMessage := SetGdInputMessage(timestamp, struct3503.OrgName, struct3503.Opter, struct3503.FixmedinsHilistId, struct3503.InsuplcAdmdvs, struct3503.MdtrtareaAdmvs, struct3503.Cainfo)
  5114. input := make(map[string]interface{})
  5115. inputMessage["infno"] = "3503"
  5116. item := struct3503
  5117. feedetailInfo := make(map[string]interface{})
  5118. feedetailInfo["med_list_codg"] = item.MedListCodg
  5119. feedetailInfo["fixmedins_hilist_id"] = item.FixmedinsHilistId
  5120. feedetailInfo["fixmedins_hilist_name"] = item.FixmedinsHilistName
  5121. feedetailInfo["dynt_no"] = ""
  5122. feedetailInfo["fixmedins_bchno"] = item.FixmedinsBchno // 人员编号 (来自1101接口返回)
  5123. feedetailInfo["spler_name"] = item.SplerName // 人员编号 (来自1101接口返回)
  5124. feedetailInfo["spler_pmtno"] = "" // 人员编号 (来自1101接口返回)
  5125. feedetailInfo["manu_lotnum"] = item.ManuLotnum // 人员编号 (来自1101接口返回)
  5126. feedetailInfo["prodentp_name"] = item.ProdentpName // 人员编号 (来自1101接口返回)
  5127. feedetailInfo["aprvno"] = item.Aprvno // 人员编号 (来自1101接口返回)
  5128. feedetailInfo["manu_date"] = item.ManuDate // 人员编号 (来自1101接口返回)
  5129. feedetailInfo["expy_end"] = item.ExpyEnd // 人员编号 (来自1101接口返回)
  5130. feedetailInfo["finl_trns_pric"] = item.FinlTrnsPric // 人员编号 (来自1101接口返回)
  5131. feedetailInfo["purc_retn_cnt"] = item.PurcRetnCnt // 人员编号 (来自1101接口返回)
  5132. feedetailInfo["purc_invo_codg"] = item.PurcInvoCodg // 人员编号 (来自1101接口返回)
  5133. feedetailInfo["purc_invo_no"] = item.PurcInvoNo // 人员编号 (来自1101接口返回)
  5134. feedetailInfo["rx_flag"] = item.RxFlag // 人员编号 (来自1101接口返回)
  5135. feedetailInfo["purc_retn_stoin_time"] = item.PurcRetnStoinTime // 人员编号 (来自1101接口返回)
  5136. feedetailInfo["purc_retn_opter_name"] = item.PurcRetnOpterName // 人员编号 (来自1101接口返回)
  5137. feedetailInfo["prod_geay_flag"] = "" // 人员编号 (来自1101接口返回)
  5138. feedetailInfo["memo"] = "" // 人员编号 (来自1101接口返回)
  5139. input["purcinfo"] = feedetailInfo
  5140. inputMessage["input"] = input //交易输入
  5141. bytesData, err := json.Marshal(inputMessage)
  5142. fmt.Println(string(bytesData))
  5143. if err != nil {
  5144. fmt.Println(err.Error())
  5145. return err.Error()
  5146. }
  5147. reader := bytes.NewReader(bytesData)
  5148. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  5149. gdyb_url := beego.AppConfig.String("gdyb_url")
  5150. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5151. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  5152. url := gdyb_url + "3503"
  5153. request, err := http.NewRequest("POST", url, reader)
  5154. if err != nil {
  5155. fmt.Println(err.Error())
  5156. return err.Error()
  5157. }
  5158. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5159. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5160. request.Header.Set("x-tif-signature", signature)
  5161. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5162. request.Header.Set("x-tif-nonce", nonce)
  5163. client := http.Client{}
  5164. resp, err := client.Do(request)
  5165. if err != nil {
  5166. fmt.Println(err.Error())
  5167. return err.Error()
  5168. }
  5169. respBytes, err := ioutil.ReadAll(resp.Body)
  5170. if err != nil {
  5171. fmt.Println(err.Error())
  5172. return err.Error()
  5173. }
  5174. str := string(respBytes)
  5175. fmt.Println(str)
  5176. return str
  5177. }
  5178. func Gdyb3504(struct3504 models.Struct3504, secret_key string) string {
  5179. // 生成签名
  5180. nonce := GetRandomString(32)
  5181. timestamp := time.Now().Unix()
  5182. signature := setSignature(timestamp, nonce, secret_key)
  5183. // 生成输入报文
  5184. inputMessage := SetGdInputMessage(timestamp, struct3504.OrgName, struct3504.Opter, struct3504.FixmedinsCode, struct3504.InsuplcAdmdvs, struct3504.MdtrtareaAdmvs, struct3504.Cainfo)
  5185. input := make(map[string]interface{})
  5186. inputData := make(map[string]interface{})
  5187. inputMessage["infno"] = "3504" // 交易编码
  5188. inputData["med_list_codg"] = struct3504.MedListCodg // 定点医药机构目录编号
  5189. inputData["fixmedins_hilist_id"] = struct3504.FixmedinsHilistId // 定点医药机构目录编号
  5190. inputData["fixmedins_hilist_name"] = struct3504.FixmedinsHilistName // 定点医药机构目录名称
  5191. inputData["fixmedins_bchno"] = struct3504.FixmedinsBchno // 人员编号 (来自1101接口返回)
  5192. inputData["spler_name"] = struct3504.SplerName // 人员编号 (来自1101接口返回)
  5193. inputData["spler_pmtno"] = "" // 人员编号 (来自1101接口返回)
  5194. inputData["manu_date"] = struct3504.ManuDate // 人员编号 (来自1101接口返回)
  5195. inputData["expy_end"] = struct3504.ExpyEnd // 人员编号 (来自1101接口返回)
  5196. inputData["finl_trns_pric"] = struct3504.FinlTrnsPric // 人员编号 (来自1101接口返回)
  5197. inputData["purc_retn_cnt"] = struct3504.PurcRetnCnt // 人员编号 (来自1101接口返回)
  5198. inputData["purc_invo_codg"] = struct3504.PurcInvoCodg // 人员编号 (来自1101接口返回)
  5199. inputData["purc_invo_no"] = struct3504.PurcInvoNo // 人员编号 (来自1101接口返回)
  5200. inputData["rx_flag"] = struct3504.RxFlag
  5201. inputData["purc_retn_stoin_time"] = struct3504.PurcRetnStoin
  5202. inputData["purc_retn_opter_name"] = struct3504.PurcRetnStoin
  5203. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  5204. inputData["medins_prod_purc_no"] = "" // 人员编号 (来自1101接口返回)
  5205. input["purcinfo"] = inputData
  5206. inputMessage["input"] = input //交易输入
  5207. bytesData, err := json.Marshal(inputMessage)
  5208. fmt.Println(string(bytesData))
  5209. if err != nil {
  5210. fmt.Println(err.Error())
  5211. return err.Error()
  5212. }
  5213. reader := bytes.NewReader(bytesData)
  5214. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  5215. gdyb_url := beego.AppConfig.String("gdyb_url")
  5216. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5217. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  5218. url := gdyb_url + "3504"
  5219. request, err := http.NewRequest("POST", url, reader)
  5220. if err != nil {
  5221. fmt.Println(err.Error())
  5222. return err.Error()
  5223. }
  5224. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5225. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5226. request.Header.Set("x-tif-signature", signature)
  5227. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5228. request.Header.Set("x-tif-nonce", nonce)
  5229. client := http.Client{}
  5230. resp, err := client.Do(request)
  5231. if err != nil {
  5232. fmt.Println(err.Error())
  5233. return err.Error()
  5234. }
  5235. respBytes, err := ioutil.ReadAll(resp.Body)
  5236. if err != nil {
  5237. fmt.Println(err.Error())
  5238. return err.Error()
  5239. }
  5240. str := string(respBytes)
  5241. fmt.Println(str)
  5242. return str
  5243. }
  5244. func Gdyb3505(struct3505 models.Struct3505, secret_key string) string {
  5245. // 生成签名
  5246. nonce := GetRandomString(32)
  5247. timestamp := time.Now().Unix()
  5248. signature := setSignature(timestamp, nonce, secret_key)
  5249. // 生成输入报文
  5250. inputMessage := SetGdInputMessage(timestamp, struct3505.OrgName, struct3505.Opter, struct3505.FixmedinsHilistId, struct3505.InsuplcAdmdvs, struct3505.MdtrtareaAdmvs, struct3505.Cainfo)
  5251. input := make(map[string]interface{})
  5252. inputData := make(map[string]interface{})
  5253. inputMessage["infno"] = "3505" // 交易编码
  5254. inputData["med_list_codg"] = struct3505.MedListCodg // 定点医药机构目录编号
  5255. inputData["fixmedins_hilist_id"] = struct3505.FixmedinsHilistId // 定点医药机构目录编号
  5256. inputData["fixmedins_hilist_name"] = struct3505.OrgName // 定点医药机构目录名称
  5257. inputData["fixmedins_bchno"] = struct3505.FixmedinsBchno // 人员编号 (来自1101接口返回)
  5258. inputData["prsc_dr_cert_type"] = struct3505.PrscDrCertType // 人员编号 (来自1101接口返回)
  5259. inputData["prsc_dr_certno"] = struct3505.PrscDrCertno // 人员编号 (来自1101接口返回)
  5260. inputData["prsc_dr_name"] = struct3505.PrscDrName // 人员编号 (来自1101接口返回)
  5261. inputData["phar_cert_type"] = struct3505.PharCertType // 人员编号 (来自1101接口返回)
  5262. inputData["phar_certno"] = struct3505.PharCertno // 人员编号 (来自1101接口返回)
  5263. inputData["phar_name"] = struct3505.PharName // 人员编号 (来自1101接口返回)
  5264. inputData["phar_prac_cert_no"] = struct3505.PharPracCertNo // 人员编号 (来自1101接口返回)
  5265. inputData["hi_feesetl_type"] = struct3505.HiFeesetlType // 人员编号 (来自1101接口返回)
  5266. inputData["setl_id"] = struct3505.SetlId // 人员编号 (来自1101接口返回)
  5267. inputData["mdtrt_sn"] = struct3505.MdtrtSn // 人员编号 (来自1101接口返回)
  5268. inputData["psn_no"] = struct3505.PsnNo // 人员编号 (来自1101接口返回)
  5269. inputData["psn_cert_type"] = struct3505.PsnCertType // 人员编号 (来自1101接口返回)
  5270. inputData["certno"] = struct3505.CertNo // 人员编号 (来自1101接口返回)
  5271. inputData["psn_name"] = struct3505.PsnName // 人员编号 (来自1101接口返回)
  5272. inputData["manu_lotnum"] = struct3505.ManuLotnum // 人员编号 (来自1101接口返回)
  5273. inputData["manu_date"] = struct3505.ManuDate // 人员编号 (来自1101接口返回)
  5274. inputData["expy_end"] = struct3505.ExpyEnd // 人员编号 (来自1101接口返回)
  5275. inputData["rx_flag"] = struct3505.RxFlag // 人员编号 (来自1101接口返回)
  5276. inputData["trdn_flag"] = struct3505.TrdnFlag // 人员编号 (来自1101接口返回)
  5277. inputData["finl_trns_pric"] = struct3505.FinlTrnsPric // 人员编号 (来自1101接口返回)
  5278. inputData["rxno"] = struct3505.Rxno // 人员编号 (来自1101接口返回)
  5279. inputData["rx_circ_flag"] = struct3505.RxCircFlag // 人员编号 (来自1101接口返回)
  5280. inputData["rtal_docno"] = struct3505.RtalDocno // 人员编号 (来自1101接口返回)
  5281. inputData["stoout_no"] = struct3505.StooutNo // 人员编号 (来自1101接口返回)
  5282. inputData["bchno"] = struct3505.Bchno // 人员编号 (来自1101接口返回)
  5283. inputData["drug_trac_codg"] = struct3505.DrugTracCodg // 人员编号 (来自1101接口返回)
  5284. inputData["drug_prod_barc"] = struct3505.DrugProdBarc // 人员编号 (来自1101接口返回)
  5285. inputData["shelf_posi"] = struct3505.ShelfPosi // 人员编号 (来自1101接口返回)
  5286. inputData["sel_retn_cnt"] = struct3505.SelRetnCnt // 人员编号 (来自1101接口返回)
  5287. inputData["sel_retn_time"] = struct3505.SelRetnTime // 人员编号 (来自1101接口返回)
  5288. inputData["sel_retn_opter_name"] = struct3505.SelRetnOpterName // 人员编号 (来自1101接口返回)
  5289. inputData["memo"] = struct3505.Memo // 人员编号 (来自1101接口返回)
  5290. input["selinfo"] = inputData
  5291. inputMessage["input"] = input //交易输入
  5292. bytesData, err := json.Marshal(inputMessage)
  5293. fmt.Println(string(bytesData))
  5294. if err != nil {
  5295. fmt.Println(err.Error())
  5296. return err.Error()
  5297. }
  5298. reader := bytes.NewReader(bytesData)
  5299. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  5300. gdyb_url := beego.AppConfig.String("gdyb_url")
  5301. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5302. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  5303. url := gdyb_url + "3505"
  5304. request, err := http.NewRequest("POST", url, reader)
  5305. if err != nil {
  5306. fmt.Println(err.Error())
  5307. return err.Error()
  5308. }
  5309. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5310. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5311. request.Header.Set("x-tif-signature", signature)
  5312. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5313. request.Header.Set("x-tif-nonce", nonce)
  5314. client := http.Client{}
  5315. resp, err := client.Do(request)
  5316. if err != nil {
  5317. fmt.Println(err.Error())
  5318. return err.Error()
  5319. }
  5320. respBytes, err := ioutil.ReadAll(resp.Body)
  5321. if err != nil {
  5322. fmt.Println(err.Error())
  5323. return err.Error()
  5324. }
  5325. str := string(respBytes)
  5326. fmt.Println(str)
  5327. return str
  5328. }
  5329. func Gdyb3506(struct3506 models.Struct3506, secret_key string) string {
  5330. // 生成签名
  5331. nonce := GetRandomString(32)
  5332. timestamp := time.Now().Unix()
  5333. signature := setSignature(timestamp, nonce, secret_key)
  5334. // 生成输入报文
  5335. inputMessage := SetGdInputMessage(timestamp, struct3506.OrgName, struct3506.Opter, struct3506.FixmedinsCode, struct3506.InsuplcAdmdvs, struct3506.MdtrtareaAdmvs, struct3506.Cainfo)
  5336. input := make(map[string]interface{})
  5337. inputData := make(map[string]interface{})
  5338. inputMessage["infno"] = "3506" // 交易编码
  5339. inputData["med_list_codg"] = struct3506.MedListCodg // 定点医药机构目录编号
  5340. inputData["fixmedins_hilist_id"] = struct3506.FixmedinsHilistId // 定点医药机构目录编号
  5341. inputData["fixmedins_hilist_name"] = struct3506.OrgName // 定点医药机构目录名称
  5342. inputData["fixmedins_bchno"] = struct3506.FixmedinsBchno // 人员编号 (来自1101接口返回)
  5343. inputData["setl_id"] = struct3506.SetlId // 人员编号 (来自1101接口返回)
  5344. inputData["psn_no"] = struct3506.PsnNo // 人员编号 (来自1101接口返回)
  5345. inputData["psn_cert_type"] = struct3506.PsnCertType // 人员编号 (来自1101接口返回)
  5346. inputData["certno"] = struct3506.Certno // 人员编号 (来自1101接口返回)
  5347. inputData["psn_name"] = struct3506.PsnName // 人员编号 (来自1101接口返回)
  5348. inputData["manu_lotnum"] = struct3506.ManuLotnum // 人员编号 (来自1101接口返回)
  5349. inputData["manu_date"] = struct3506.ManuDate // 人员编号 (来自1101接口返回)
  5350. inputData["expy_end"] = struct3506.ExpyEnd // 人员编号 (来自1101接口返回)
  5351. inputData["rx_flag"] = struct3506.RxFlag // 人员编号 (来自1101接口返回)
  5352. inputData["trdn_flag"] = struct3506.TrdnFlag // 人员编号 (来自1101接口返回)
  5353. inputData["finl_trns_pric"] = struct3506.FinlTrnsPric // 人员编号 (来自1101接口返回)
  5354. inputData["sel_retn_cnt"] = struct3506.SelRetnCnt // 人员编号 (来自1101接口返回)
  5355. inputData["sel_retn_time"] = struct3506.SelRetnTime // 人员编号 (来自1101接口返回)
  5356. inputData["sel_retn_opter_name"] = struct3506.SelRetnOpterName // 人员编号 (来自1101接口返回)
  5357. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  5358. inputData["medins_prod_sel_no"] = "" // 人员编号 (来自1101接口返回)
  5359. input["selinfo"] = inputData
  5360. inputMessage["input"] = input //交易输入
  5361. bytesData, err := json.Marshal(inputMessage)
  5362. fmt.Println(string(bytesData))
  5363. if err != nil {
  5364. fmt.Println(err.Error())
  5365. return err.Error()
  5366. }
  5367. reader := bytes.NewReader(bytesData)
  5368. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  5369. gdyb_url := beego.AppConfig.String("gdyb_url")
  5370. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5371. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  5372. url := gdyb_url + "3506"
  5373. request, err := http.NewRequest("POST", url, reader)
  5374. if err != nil {
  5375. fmt.Println(err.Error())
  5376. return err.Error()
  5377. }
  5378. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5379. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5380. request.Header.Set("x-tif-signature", signature)
  5381. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5382. request.Header.Set("x-tif-nonce", nonce)
  5383. client := http.Client{}
  5384. resp, err := client.Do(request)
  5385. if err != nil {
  5386. fmt.Println(err.Error())
  5387. return err.Error()
  5388. }
  5389. respBytes, err := ioutil.ReadAll(resp.Body)
  5390. if err != nil {
  5391. fmt.Println(err.Error())
  5392. return err.Error()
  5393. }
  5394. str := string(respBytes)
  5395. fmt.Println(str)
  5396. return str
  5397. }
  5398. func Gdyb3507(struct3507 models.Struct3507, secret_key string) string {
  5399. // 生成签名
  5400. nonce := GetRandomString(32)
  5401. timestamp := time.Now().Unix()
  5402. signature := setSignature(timestamp, nonce, secret_key)
  5403. // 生成输入报文
  5404. inputMessage := SetGdInputMessage(timestamp, struct3507.OrgName, struct3507.Opter, struct3507.FixmedinsCode, struct3507.InsuplcAdmdvs, struct3507.MdtrtareaAdmvs, struct3507.Cainfo)
  5405. input := make(map[string]interface{})
  5406. inputData := make(map[string]interface{})
  5407. inputMessage["infno"] = "3507" // 交易编码
  5408. inputData["fixmedins_bchno"] = struct3507.FixmedinsCode // 人员编号 (来自1101接口返回)
  5409. inputData["inv_data_type"] = struct3507.InvDataType // 人员编号 (来自1101接口返回)
  5410. input["data"] = inputData
  5411. inputMessage["input"] = input //交易输入
  5412. bytesData, err := json.Marshal(inputMessage)
  5413. fmt.Println(string(bytesData))
  5414. if err != nil {
  5415. fmt.Println(err.Error())
  5416. return err.Error()
  5417. }
  5418. reader := bytes.NewReader(bytesData)
  5419. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  5420. gdyb_url := beego.AppConfig.String("gdyb_url")
  5421. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5422. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  5423. url := gdyb_url + "3507"
  5424. request, err := http.NewRequest("POST", url, reader)
  5425. if err != nil {
  5426. fmt.Println(err.Error())
  5427. return err.Error()
  5428. }
  5429. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5430. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5431. request.Header.Set("x-tif-signature", signature)
  5432. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5433. request.Header.Set("x-tif-nonce", nonce)
  5434. client := http.Client{}
  5435. resp, err := client.Do(request)
  5436. if err != nil {
  5437. fmt.Println(err.Error())
  5438. return err.Error()
  5439. }
  5440. respBytes, err := ioutil.ReadAll(resp.Body)
  5441. if err != nil {
  5442. fmt.Println(err.Error())
  5443. return err.Error()
  5444. }
  5445. str := string(respBytes)
  5446. fmt.Println(str)
  5447. return str
  5448. }
  5449. // 生成基础报文
  5450. func SetGdInputMessage(timestamp int64, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, cainfo string) map[string]interface{} {
  5451. // 生成签名
  5452. tempTime := time.Unix(timestamp, 0)
  5453. //timeFormat := tempTime.Format("20060102150405")
  5454. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  5455. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  5456. month := time.Unix(1557042972, 0).Format("1")
  5457. year := time.Now().Format("2006")
  5458. month = time.Now().Format("01")
  5459. day := time.Now().Format("02")
  5460. hour := time.Now().Format("15")
  5461. min := time.Now().Format("04")
  5462. sec := time.Now().Format("05")
  5463. msec := time.Now().Format("000")
  5464. // 生成输入报文
  5465. inputMessage := make(map[string]interface{})
  5466. inputMessage["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  5467. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  5468. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  5469. inputMessage["recer_sys_code"] = "MBS_LOCAL" // 接收方系统代码
  5470. inputMessage["dev_no"] = "1" // 设备编号
  5471. inputMessage["dev_safe_info"] = "1" // 设备安全信息
  5472. inputMessage["cainfo"] = cainfo // 数字签名信息
  5473. inputMessage["signtype"] = "SM3" // 签名类型
  5474. inputMessage["infver"] = "1.0.0" // 接收方系统代码
  5475. inputMessage["opter_type"] = "1" // 经办人类别
  5476. inputMessage["opter"] = doctor // 经办人
  5477. inputMessage["opter_name"] = doctor // 经办人姓名
  5478. inputMessage["inf_time"] = timeFormatOne // 交易时间
  5479. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  5480. inputMessage["fixmedins_name"] = org_name
  5481. inputMessage["fixmedins_soft_fcty"] = "深圳市领透科技有限公司" //定点医药机构名称
  5482. //定点医药机构名称
  5483. inputMessage["sign_no"] = "" //交易签到流水号
  5484. return inputMessage
  5485. }