gdyb_service.go 233KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095
  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"] = "2203" // 交易编码
  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 + "2203"
  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. //func Gdyb2206(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string, total string, org_name string, doctor string, secret_key string) string {
  1028. 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) {
  1029. // 生成签名
  1030. nonce := GetRandomString(32)
  1031. timestamp := time.Now().Unix()
  1032. signature := setSignature(timestamp, nonce, secret_key)
  1033. // 生成输入报文
  1034. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1035. input := make(map[string]interface{})
  1036. inputData := make(map[string]interface{})
  1037. inputMessage["infno"] = "2206" // 交易编码
  1038. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1039. if certificates == 3 {
  1040. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  1041. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1042. } else {
  1043. if id_card_type == 1 {
  1044. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  1045. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1046. } else if id_card_type == 4 {
  1047. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  1048. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1049. } else {
  1050. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  1051. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1052. }
  1053. }
  1054. if insuplc_admdvs == "421300" {
  1055. if med_type == "11" || med_type == "1112" || med_type == "1111" {
  1056. inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
  1057. } else if med_type == "14" {
  1058. inputData["med_type"] = "140110" // 医疗类别 11 普通门诊 12 门诊挂号
  1059. }
  1060. } else {
  1061. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  1062. }
  1063. inputData["medfee_sumamt"] = total // 医疗费总额
  1064. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  1065. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1066. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  1067. inputData["acct_used_flag"] = "0" // 个人账户使用标志 0否 1是
  1068. inputData["insutype"] = insutype // 险种类型
  1069. inputData["invono"] = "" // 发票号
  1070. inputData["dise_codg"] = "M07803" // 发票号
  1071. input["data"] = inputData
  1072. inputMessage["input"] = input //交易输入
  1073. var requestLog string
  1074. bytesData, err := json.Marshal(inputMessage)
  1075. requestLog = string(bytesData)
  1076. fmt.Println(string(bytesData))
  1077. if err != nil {
  1078. fmt.Println(err.Error())
  1079. return err.Error(), ""
  1080. }
  1081. reader := bytes.NewReader(bytesData)
  1082. gdyb_url := beego.AppConfig.String("gdyb_url")
  1083. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1084. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1085. //url := gdyb_url + "2206"
  1086. var url string
  1087. if fixmedins_code == "H15049901371" {
  1088. url = gdyb_url
  1089. } else {
  1090. url = gdyb_url + "2206"
  1091. }
  1092. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2206"
  1093. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2206"
  1094. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2206"
  1095. if insuplc_admdvs == "421300" {
  1096. var json2 string
  1097. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2206", string(bytesData), json2)
  1098. out, err := cmd.Output()
  1099. if err != nil {
  1100. fmt.Println("error:", err.Error())
  1101. }
  1102. fmt.Println(string(out))
  1103. return hex.EncodeToString(out), requestLog
  1104. } else {
  1105. request, err := http.NewRequest("POST", url, reader)
  1106. if err != nil {
  1107. fmt.Println(err.Error())
  1108. return err.Error(), ""
  1109. }
  1110. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1111. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1112. request.Header.Set("x-tif-signature", signature)
  1113. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1114. request.Header.Set("x-tif-nonce", nonce)
  1115. client := http.Client{}
  1116. resp, err := client.Do(request)
  1117. if err != nil {
  1118. fmt.Println(err.Error())
  1119. return err.Error(), ""
  1120. }
  1121. respBytes, err := ioutil.ReadAll(resp.Body)
  1122. if err != nil {
  1123. fmt.Println(err.Error())
  1124. return err.Error(), ""
  1125. }
  1126. str := string(respBytes)
  1127. fmt.Println(str)
  1128. return str, requestLog
  1129. }
  1130. }
  1131. // 门诊结算
  1132. 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) {
  1133. // 生成签名
  1134. nonce := GetRandomString(32)
  1135. timestamp := time.Now().Unix()
  1136. signature := setSignature(timestamp, nonce, secret_key)
  1137. // 生成输入报文
  1138. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1139. input := make(map[string]interface{})
  1140. inputData := make(map[string]interface{})
  1141. inputMessage["infno"] = "2207" // 交易编码
  1142. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1143. if certificates == 3 {
  1144. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  1145. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1146. } else {
  1147. if id_card_type == 1 {
  1148. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  1149. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1150. } else if id_card_type == 4 {
  1151. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  1152. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  1153. } else {
  1154. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  1155. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1156. }
  1157. }
  1158. if med_type == "1111" || med_type == "1112" {
  1159. med_type = "11"
  1160. }
  1161. if insuplc_admdvs == "421300" {
  1162. if med_type == "11" {
  1163. inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
  1164. } else if med_type == "14" {
  1165. inputData["med_type"] = "140101" // 医疗类别 11 普通门诊 12 门诊挂号
  1166. }
  1167. } else {
  1168. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  1169. }
  1170. inputData["medfee_sumamt"] = total // 医疗费总额
  1171. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  1172. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1173. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  1174. inputData["acct_used_flag"] = acct_used_flag // 个人账户使用标志 0否 1是
  1175. inputData["insutype"] = insutype // 险种类型
  1176. inputData["invono"] = "" // 发票号
  1177. inputData["fulamt_ownpay_amt"] = fulamt_ownpay_amt //
  1178. inputData["overlmt_selfpay"] = overlmt_selfpay //
  1179. inputData["preselfpay_amt"] = preselfpay_amt //
  1180. inputData["inscp_scp_amt"] = inscp_scp_amt //
  1181. input["data"] = inputData
  1182. inputMessage["input"] = input //交易输入
  1183. bytesData, err := json.Marshal(inputMessage)
  1184. fmt.Println(string(bytesData))
  1185. if err != nil {
  1186. fmt.Println(err.Error())
  1187. return err.Error(), ""
  1188. }
  1189. reader := bytes.NewReader(bytesData)
  1190. gdyb_url := beego.AppConfig.String("gdyb_url")
  1191. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1192. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1193. //url := gdyb_url + "2207"
  1194. var url string
  1195. if fixmedins_code == "H15049901371" {
  1196. url = gdyb_url
  1197. } else {
  1198. url = gdyb_url + "2207"
  1199. }
  1200. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2207"
  1201. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  1202. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  1203. if insuplc_admdvs == "421300" {
  1204. var json2 string
  1205. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2207", string(bytesData), json2)
  1206. out, err := cmd.Output()
  1207. if err != nil {
  1208. fmt.Println("error:", err.Error())
  1209. }
  1210. mjson, _ := json.Marshal(inputMessage)
  1211. str2 := string(mjson)
  1212. fmt.Println(string(out))
  1213. return hex.EncodeToString(out), str2
  1214. } else {
  1215. request, err := http.NewRequest("POST", url, reader)
  1216. if err != nil {
  1217. fmt.Println(err.Error())
  1218. return err.Error(), ""
  1219. }
  1220. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1221. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1222. request.Header.Set("x-tif-signature", signature)
  1223. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1224. request.Header.Set("x-tif-nonce", nonce)
  1225. client := http.Client{}
  1226. resp, err := client.Do(request)
  1227. if err != nil {
  1228. fmt.Println(err.Error())
  1229. return err.Error(), ""
  1230. }
  1231. respBytes, err := ioutil.ReadAll(resp.Body)
  1232. if err != nil {
  1233. fmt.Println(err.Error())
  1234. return err.Error(), ""
  1235. }
  1236. str := string(respBytes)
  1237. fmt.Println(str)
  1238. mjson, _ := json.Marshal(inputMessage)
  1239. str2 := string(mjson)
  1240. return str, str2
  1241. }
  1242. }
  1243. 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) {
  1244. // 生成签名
  1245. nonce := GetRandomString(32)
  1246. timestamp := time.Now().Unix()
  1247. signature := setSignature(timestamp, nonce, secret_key)
  1248. // 生成输入报文
  1249. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1250. input := make(map[string]interface{})
  1251. inputData := make(map[string]interface{})
  1252. inputMessage["infno"] = "2207A" // 交易编码
  1253. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1254. if certificates == 3 {
  1255. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  1256. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1257. } else {
  1258. if id_card_type == 1 {
  1259. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  1260. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1261. } else {
  1262. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  1263. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1264. }
  1265. }
  1266. if med_type == "1111" || med_type == "1112" {
  1267. med_type = "11"
  1268. }
  1269. if insuplc_admdvs == "421300" {
  1270. if med_type == "11" {
  1271. inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
  1272. } else if med_type == "14" {
  1273. inputData["med_type"] = "140101" // 医疗类别 11 普通门诊 12 门诊挂号
  1274. }
  1275. } else {
  1276. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  1277. }
  1278. inputData["medfee_sumamt"] = total // 医疗费总额
  1279. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  1280. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1281. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  1282. inputData["acct_used_flag"] = acct_used_flag // 个人账户使用标志 0否 1是
  1283. inputData["insutype"] = insutype // 险种类型
  1284. inputData["invono"] = "" // 发票号
  1285. inputData["fulamt_ownpay_amt"] = fulamt_ownpay_amt //
  1286. inputData["overlmt_selfpay"] = overlmt_selfpay //
  1287. inputData["preselfpay_amt"] = preselfpay_amt //
  1288. inputData["inscp_scp_amt"] = inscp_scp_amt //
  1289. input["data"] = inputData
  1290. inputMessage["input"] = input //交易输入
  1291. bytesData, err := json.Marshal(inputMessage)
  1292. fmt.Println(string(bytesData))
  1293. if err != nil {
  1294. fmt.Println(err.Error())
  1295. return err.Error(), ""
  1296. }
  1297. reader := bytes.NewReader(bytesData)
  1298. gdyb_url := beego.AppConfig.String("gdyb_url")
  1299. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1300. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1301. //url := gdyb_url + "2207"
  1302. var url string
  1303. if fixmedins_code == "H15049901371" {
  1304. url = gdyb_url
  1305. } else {
  1306. url = gdyb_url + "2207"
  1307. }
  1308. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2207"
  1309. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  1310. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  1311. if insuplc_admdvs == "421300" {
  1312. var json2 string
  1313. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2207", string(bytesData), json2)
  1314. out, err := cmd.Output()
  1315. if err != nil {
  1316. fmt.Println("error:", err.Error())
  1317. }
  1318. mjson, _ := json.Marshal(inputMessage)
  1319. str2 := string(mjson)
  1320. fmt.Println(string(out))
  1321. return hex.EncodeToString(out), str2
  1322. } else {
  1323. request, err := http.NewRequest("POST", url, reader)
  1324. if err != nil {
  1325. fmt.Println(err.Error())
  1326. return err.Error(), ""
  1327. }
  1328. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1329. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1330. request.Header.Set("x-tif-signature", signature)
  1331. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1332. request.Header.Set("x-tif-nonce", nonce)
  1333. client := http.Client{}
  1334. resp, err := client.Do(request)
  1335. if err != nil {
  1336. fmt.Println(err.Error())
  1337. return err.Error(), ""
  1338. }
  1339. respBytes, err := ioutil.ReadAll(resp.Body)
  1340. if err != nil {
  1341. fmt.Println(err.Error())
  1342. return err.Error(), ""
  1343. }
  1344. str := string(respBytes)
  1345. fmt.Println(str)
  1346. mjson, _ := json.Marshal(inputMessage)
  1347. str2 := string(mjson)
  1348. return str, str2
  1349. }
  1350. }
  1351. // 门诊结算撤销
  1352. 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) {
  1353. // 生成签名
  1354. nonce := GetRandomString(32)
  1355. timestamp := time.Now().Unix()
  1356. signature := setSignature(timestamp, nonce, secret_key)
  1357. // 生成输入报文
  1358. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1359. input := make(map[string]interface{})
  1360. inputData := make(map[string]interface{})
  1361. inputMessage["infno"] = "2208" // 交易编码
  1362. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1363. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1364. inputData["setl_id"] = setlId // 结算 ID
  1365. input["data"] = inputData
  1366. inputMessage["input"] = input //交易输入
  1367. bytesData, err := json.Marshal(inputMessage)
  1368. fmt.Println(string(bytesData))
  1369. if err != nil {
  1370. fmt.Println(err.Error())
  1371. return err.Error(), ""
  1372. }
  1373. reader := bytes.NewReader(bytesData)
  1374. gdyb_url := beego.AppConfig.String("gdyb_url")
  1375. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1376. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1377. //url := gdyb_url + "2208"
  1378. var url string
  1379. if fixmedins_code == "H15049901371" {
  1380. url = gdyb_url
  1381. } else {
  1382. url = gdyb_url + "2208"
  1383. }
  1384. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2208"
  1385. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2208"
  1386. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2208"
  1387. if insuplc_admdvs == "421300" {
  1388. var json2 string
  1389. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2208", string(bytesData), json2)
  1390. out, err := cmd.Output()
  1391. if err != nil {
  1392. fmt.Println("error:", err.Error())
  1393. }
  1394. mjson, _ := json.Marshal(inputMessage)
  1395. str2 := string(mjson)
  1396. fmt.Println(string(out))
  1397. return hex.EncodeToString(out), str2
  1398. } else {
  1399. request, err := http.NewRequest("POST", url, reader)
  1400. if err != nil {
  1401. fmt.Println(err.Error())
  1402. return err.Error(), ""
  1403. }
  1404. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1405. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1406. request.Header.Set("x-tif-signature", signature)
  1407. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1408. request.Header.Set("x-tif-nonce", nonce)
  1409. client := http.Client{}
  1410. resp, err := client.Do(request)
  1411. if err != nil {
  1412. fmt.Println(err.Error())
  1413. return err.Error(), ""
  1414. }
  1415. respBytes, err := ioutil.ReadAll(resp.Body)
  1416. if err != nil {
  1417. fmt.Println(err.Error())
  1418. return err.Error(), ""
  1419. }
  1420. str := string(respBytes)
  1421. fmt.Println(str)
  1422. mjson, _ := json.Marshal(inputMessage)
  1423. str2 := string(mjson)
  1424. return str, str2
  1425. }
  1426. }
  1427. //确认订单
  1428. func Gdyb6201(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, order models.HisOrder) string {
  1429. // 生成签名
  1430. nonce := GetRandomString(32)
  1431. timestamp := time.Now().Unix()
  1432. signature := setSignature(timestamp, nonce, secret_key)
  1433. // 生成输入报文
  1434. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1435. input := make(map[string]interface{})
  1436. inputData := make(map[string]interface{})
  1437. inputMessage["infno"] = "6201" // 交易编码
  1438. inputData["mdtrt_id"] = order.MdtrtId
  1439. inputData["chrg_bchno"] = order.Number
  1440. inputData["psn_no"] = order.PsnNo
  1441. inputData["psn_name"] = order.PsnName
  1442. inputData["psn_cert_type"] = order.PsnCertType
  1443. inputData["certno"] = order.Certno
  1444. inputData["insutype"] = order.Insutype
  1445. inputData["med_type"] = order.MedType
  1446. inputData["medfee_sumamt"] = order.MedfeeSumamt
  1447. inputData["fulamt_ownpay_amt"] = order.FulamtOwnpayAmt
  1448. inputData["overlmt_selfpay"] = order.OverlmtSelfPay
  1449. inputData["preselfpay_amt"] = order.PreselfpayAmt
  1450. inputData["inscp_scp_amt"] = order.InscpScpAmt
  1451. inputData["act_pay_dedc"] = order.ActPayDedc
  1452. inputData["hifp_pay"] = order.HifpPay
  1453. inputData["pool_prop_selfpay"] = order.PoolPropSelfpay
  1454. inputData["cvlserv_pay"] = order.CvlservPay
  1455. inputData["hifes_pay"] = order.HifesPay
  1456. inputData["hifmi_pay"] = order.HifmiPay
  1457. inputData["hifob_pay"] = order.HifobPay
  1458. inputData["maf_pay"] = order.MafPay
  1459. inputData["oth_pay"] = order.OthPay
  1460. inputData["fund_pay_sumamt"] = order.FundPaySumamt
  1461. inputData["psn_part_amt"] = order.PsnPartAmt
  1462. inputData["acct_pay"] = order.AcctPay
  1463. inputData["psn_cash_pay"] = order.PsnCashPay
  1464. inputData["hosp_part_amt"] = order.HospPartAmt
  1465. inputData["acct_mulaid_pay"] = order.AcctMulaidPay
  1466. input["data"] = inputData
  1467. inputMessage["input"] = input //交易输入
  1468. bytesData, err := json.Marshal(inputMessage)
  1469. fmt.Println(string(bytesData))
  1470. if err != nil {
  1471. fmt.Println(err.Error())
  1472. return err.Error()
  1473. }
  1474. reader := bytes.NewReader(bytesData)
  1475. gdyb_url := beego.AppConfig.String("gdyb_url")
  1476. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1477. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1478. url := gdyb_url + "6201"
  1479. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/6201"
  1480. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/6201"
  1481. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  1482. request, err := http.NewRequest("POST", url, reader)
  1483. if err != nil {
  1484. fmt.Println(err.Error())
  1485. return err.Error()
  1486. }
  1487. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1488. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1489. request.Header.Set("x-tif-signature", signature)
  1490. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1491. request.Header.Set("x-tif-nonce", nonce)
  1492. client := http.Client{}
  1493. resp, err := client.Do(request)
  1494. if err != nil {
  1495. fmt.Println(err.Error())
  1496. return err.Error()
  1497. }
  1498. respBytes, err := ioutil.ReadAll(resp.Body)
  1499. if err != nil {
  1500. fmt.Println(err.Error())
  1501. return err.Error()
  1502. }
  1503. str := string(respBytes)
  1504. fmt.Println(str)
  1505. return str
  1506. }
  1507. // 医药机构费用结算对总账 func Gdyb3201( org_name string, doctor string, secret_key string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) string {
  1508. func Gdyb3201(baseParams models.BaseParams, businessParams models.BusinessParams) string {
  1509. fmt.Println("11222333-----")
  1510. fmt.Println(baseParams)
  1511. fmt.Println(businessParams)
  1512. // 生成签名
  1513. nonce := GetRandomString(32)
  1514. timestamp := time.Now().Unix()
  1515. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1516. // 生成输入报文
  1517. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1518. input := make(map[string]interface{})
  1519. inputData := make(map[string]interface{})
  1520. inputMessage["infno"] = "3201" // 交易编码
  1521. inputData["insutype"] = businessParams.Insutype // 险种
  1522. inputData["clr_type"] = businessParams.ClrType // 就诊 ID(来自2201接口返回)
  1523. inputData["setl_optins"] = businessParams.SetlOptins // 结算经办机构
  1524. inputData["stmt_begndate"] = businessParams.StmtBegndate // 对帐开始时间
  1525. inputData["stmt_enddate"] = businessParams.StmtEnddate //对帐结束时间
  1526. inputData["medfee_sumamt"] = businessParams.MedfeeSumamt //医疗费总额
  1527. inputData["fund_pay_sumamt"] = businessParams.FundPaySumamt //基金支付总额
  1528. inputData["acct_pay"] = businessParams.AcctPay //个人账户支付金额
  1529. inputData["fixmedins_setl_cnt"] = businessParams.FixmedinsSetlCnt //定点医药机构结算笔数
  1530. inputData["refd_setl_flag"] = 0 // 就诊 ID(来自2201接口返回)
  1531. input["data"] = inputData
  1532. inputMessage["input"] = input //交易输入
  1533. bytesData, err := json.Marshal(inputMessage)
  1534. fmt.Println(string(bytesData))
  1535. if err != nil {
  1536. fmt.Println(err.Error())
  1537. return err.Error()
  1538. }
  1539. reader := bytes.NewReader(bytesData)
  1540. gdyb_url := beego.AppConfig.String("gdyb_url")
  1541. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1542. var url string
  1543. if baseParams.MdtrtareaAdmvs == "150499" {
  1544. url = gdyb_url
  1545. } else {
  1546. url = gdyb_url + "3201"
  1547. }
  1548. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1549. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3201"
  1550. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3201"
  1551. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3201"
  1552. request, err := http.NewRequest("POST", url, reader)
  1553. if err != nil {
  1554. fmt.Println(err.Error())
  1555. return err.Error()
  1556. }
  1557. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1558. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1559. request.Header.Set("x-tif-signature", signature)
  1560. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1561. request.Header.Set("x-tif-nonce", nonce)
  1562. client := http.Client{}
  1563. resp, err := client.Do(request)
  1564. if err != nil {
  1565. fmt.Println(err.Error())
  1566. return err.Error()
  1567. }
  1568. respBytes, err := ioutil.ReadAll(resp.Body)
  1569. if err != nil {
  1570. fmt.Println(err.Error())
  1571. return err.Error()
  1572. }
  1573. str := string(respBytes)
  1574. fmt.Println(str)
  1575. return str
  1576. }
  1577. type Params struct {
  1578. FileName string `json:"file_name"` //产品ID
  1579. In []byte `json:"in"` //
  1580. FixmedinsCode string `json:"fixmedins_code"` //调用环境生产为1 沙盒2
  1581. }
  1582. //文件上传
  1583. func Gdyb9101(baseParams models.BaseParams, file_name string, file_byte []byte) string {
  1584. // 生成签名
  1585. nonce := GetRandomString(32)
  1586. timestamp := time.Now().Unix()
  1587. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1588. //buf := new(bytes.Buffer)
  1589. //buf.ReadFrom(strings.NewReader(string(file_byte)))
  1590. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1591. input := make(map[string]interface{})
  1592. inputData := make(map[string]interface{})
  1593. inputMessage["infno"] = "9101" // 交易编码
  1594. inputData["file_name"] = file_name //文件名
  1595. inputData["in"] = file_byte //文件数据
  1596. inputData["fixmedins_code"] = baseParams.FixmedinsCode //编码
  1597. input["fsUploadIn"] = inputData
  1598. inputMessage["input"] = input //交易输入
  1599. bytesData, err := json.Marshal(inputMessage)
  1600. fmt.Println(string(bytesData))
  1601. if err != nil {
  1602. fmt.Println(err.Error())
  1603. return err.Error()
  1604. }
  1605. reader := bytes.NewReader(bytesData)
  1606. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/9101"
  1607. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9101"
  1608. gdyb_url := beego.AppConfig.String("gdyb_url")
  1609. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1610. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1611. url := gdyb_url + "9101"
  1612. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9101"
  1613. request, err := http.NewRequest("POST", url, reader)
  1614. if err != nil {
  1615. fmt.Println(err.Error())
  1616. return err.Error()
  1617. }
  1618. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1619. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1620. request.Header.Set("x-tif-signature", signature)
  1621. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1622. request.Header.Set("x-tif-nonce", nonce)
  1623. client := http.Client{}
  1624. resp, err := client.Do(request)
  1625. if err != nil {
  1626. fmt.Println(err.Error())
  1627. return err.Error()
  1628. }
  1629. respBytes, err := ioutil.ReadAll(resp.Body)
  1630. if err != nil {
  1631. fmt.Println(err.Error())
  1632. return err.Error()
  1633. }
  1634. str := string(respBytes)
  1635. fmt.Println(str)
  1636. return str
  1637. }
  1638. func Gdyb9102(baseParams models.BaseParams, file_name string, file_qury_no string) string {
  1639. // 生成签名
  1640. nonce := GetRandomString(32)
  1641. timestamp := time.Now().Unix()
  1642. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1643. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1644. input := make(map[string]interface{})
  1645. inputData := make(map[string]interface{})
  1646. inputMessage["infno"] = "9102" // 交易编码
  1647. inputData["file_name"] = file_name //文件名
  1648. inputData["file_qury_no"] = file_qury_no //文件数据
  1649. inputData["fixmedins_code"] = baseParams.FixmedinsCode //编码
  1650. input["fsDownloadIn"] = inputData
  1651. inputMessage["input"] = input //交易输入
  1652. bytesData, err := json.Marshal(inputMessage)
  1653. fmt.Println(string(bytesData))
  1654. if err != nil {
  1655. fmt.Println(err.Error())
  1656. return err.Error()
  1657. }
  1658. reader := bytes.NewReader(bytesData)
  1659. gdyb_url := beego.AppConfig.String("gdyb_url")
  1660. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1661. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1662. url := gdyb_url + "9102"
  1663. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/9102"
  1664. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9102"
  1665. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9102"
  1666. request, err := http.NewRequest("POST", url, reader)
  1667. if err != nil {
  1668. fmt.Println(err.Error())
  1669. return err.Error()
  1670. }
  1671. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1672. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1673. request.Header.Set("x-tif-signature", signature)
  1674. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1675. request.Header.Set("x-tif-nonce", nonce)
  1676. client := http.Client{}
  1677. resp, err := client.Do(request)
  1678. if err != nil {
  1679. fmt.Println(err.Error())
  1680. return err.Error()
  1681. }
  1682. respBytes, err := ioutil.ReadAll(resp.Body)
  1683. if err != nil {
  1684. fmt.Println(err.Error())
  1685. return err.Error()
  1686. }
  1687. str := string(respBytes)
  1688. fmt.Println(str)
  1689. return str
  1690. }
  1691. func Gdyb3202(baseParams models.BaseParams, businessParams models.BusinessParams) string {
  1692. // 生成签名
  1693. nonce := GetRandomString(32)
  1694. timestamp := time.Now().Unix()
  1695. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1696. // 生成输入报文
  1697. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1698. input := make(map[string]interface{})
  1699. inputData := make(map[string]interface{})
  1700. inputMessage["infno"] = "3202" // 交易编码
  1701. inputData["file_qury_no"] = businessParams.FileQuryNo // 险种
  1702. inputData["setl_optins"] = baseParams.InsuplcAdmdvs // 结算经办机构
  1703. inputData["stmt_begndate"] = businessParams.StmtBegndate // 对帐开始时间
  1704. inputData["stmt_enddate"] = businessParams.StmtEnddate //对帐结束时间
  1705. inputData["medfee_sumamt"] = businessParams.MedfeeSumamt //医疗费总额
  1706. inputData["fund_pay_sumamt"] = businessParams.FundPaySumamt //基金支付总额
  1707. inputData["cash_payamt"] = businessParams.CashPayamt //现金支付金额
  1708. inputData["fixmedins_setl_cnt"] = businessParams.FixmedinsSetlCnt //定点医药机构结算笔数
  1709. inputData["clr_type"] = "11" // 就诊 ID(来自2201接口返回)
  1710. inputData["refd_setl_flag"] = 1 // 就诊 ID(来自2201接口返回)
  1711. input["data"] = inputData
  1712. inputMessage["input"] = input //交易输入
  1713. bytesData, err := json.Marshal(inputMessage)
  1714. fmt.Println(string(bytesData))
  1715. if err != nil {
  1716. fmt.Println(err.Error())
  1717. return err.Error()
  1718. }
  1719. reader := bytes.NewReader(bytesData)
  1720. gdyb_url := beego.AppConfig.String("gdyb_url")
  1721. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1722. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1723. url := gdyb_url + "3202"
  1724. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3202"
  1725. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3202"
  1726. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3202"
  1727. request, err := http.NewRequest("POST", url, reader)
  1728. if err != nil {
  1729. fmt.Println(err.Error())
  1730. return err.Error()
  1731. }
  1732. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1733. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1734. request.Header.Set("x-tif-signature", signature)
  1735. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1736. request.Header.Set("x-tif-nonce", nonce)
  1737. client := http.Client{}
  1738. resp, err := client.Do(request)
  1739. if err != nil {
  1740. fmt.Println(err.Error())
  1741. return err.Error()
  1742. }
  1743. respBytes, err := ioutil.ReadAll(resp.Body)
  1744. if err != nil {
  1745. fmt.Println(err.Error())
  1746. return err.Error()
  1747. }
  1748. str := string(respBytes)
  1749. fmt.Println(str)
  1750. return str
  1751. }
  1752. func Gdyb5203(baseParams models.BaseParams, businessParams models.BusinessParams) string {
  1753. fmt.Println("~~~~~~1")
  1754. fmt.Println(baseParams)
  1755. fmt.Println(businessParams)
  1756. // 生成签名
  1757. nonce := GetRandomString(32)
  1758. timestamp := time.Now().Unix()
  1759. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1760. fmt.Println("~~~~~~2")
  1761. // 生成输入报文
  1762. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1763. input := make(map[string]interface{})
  1764. inputData := make(map[string]interface{})
  1765. inputMessage["infno"] = "5203" // 交易编码
  1766. inputData["psn_no"] = businessParams.PsnNo
  1767. inputData["setl_id"] = businessParams.SetlId
  1768. inputData["mdtrt_id"] = businessParams.MdtrtId
  1769. input["data"] = inputData
  1770. inputMessage["input"] = input //交易输入
  1771. bytesData, err := json.Marshal(inputMessage)
  1772. fmt.Println(string(bytesData))
  1773. fmt.Println("~~~~~~")
  1774. fmt.Println("~~~~~~")
  1775. fmt.Println(string(bytesData))
  1776. if err != nil {
  1777. fmt.Println(err.Error())
  1778. return err.Error()
  1779. }
  1780. reader := bytes.NewReader(bytesData)
  1781. gdyb_url := beego.AppConfig.String("gdyb_url")
  1782. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1783. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1784. //url := gdyb_url + "5203"
  1785. var url string
  1786. if baseParams.FixmedinsCode == "H15049901371" {
  1787. url = gdyb_url
  1788. } else {
  1789. url = gdyb_url + "5203"
  1790. }
  1791. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5203"
  1792. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
  1793. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
  1794. request, err := http.NewRequest("POST", url, reader)
  1795. if err != nil {
  1796. fmt.Println(err.Error())
  1797. return err.Error()
  1798. }
  1799. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1800. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1801. request.Header.Set("x-tif-signature", signature)
  1802. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1803. request.Header.Set("x-tif-nonce", nonce)
  1804. client := http.Client{}
  1805. resp, err := client.Do(request)
  1806. if err != nil {
  1807. fmt.Println(err.Error())
  1808. return err.Error()
  1809. }
  1810. respBytes, err := ioutil.ReadAll(resp.Body)
  1811. if err != nil {
  1812. fmt.Println(err.Error())
  1813. return err.Error()
  1814. }
  1815. str := string(respBytes)
  1816. fmt.Println(str)
  1817. return str
  1818. }
  1819. func Gdyb5204(baseParams models.BaseParams, businessParams models.BusinessParams) string {
  1820. // 生成签名
  1821. nonce := GetRandomString(32)
  1822. timestamp := time.Now().Unix()
  1823. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1824. // 生成输入报文
  1825. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1826. input := make(map[string]interface{})
  1827. inputData := make(map[string]interface{})
  1828. inputMessage["infno"] = "5204" // 交易编码
  1829. inputData["psn_no"] = businessParams.PsnNo
  1830. inputData["setl_id"] = businessParams.SetlId
  1831. inputData["mdtrt_id"] = businessParams.MdtrtId
  1832. input["data"] = inputData
  1833. inputMessage["input"] = input //交易输入
  1834. bytesData, err := json.Marshal(inputMessage)
  1835. fmt.Println(string(bytesData))
  1836. if err != nil {
  1837. fmt.Println(err.Error())
  1838. return err.Error()
  1839. }
  1840. reader := bytes.NewReader(bytesData)
  1841. gdyb_url := beego.AppConfig.String("gdyb_url")
  1842. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1843. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1844. //url := gdyb_url + "5203"
  1845. var url string
  1846. if baseParams.FixmedinsCode == "H15049901371" {
  1847. url = gdyb_url
  1848. } else {
  1849. url = gdyb_url + "5204"
  1850. }
  1851. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5203"
  1852. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
  1853. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
  1854. request, err := http.NewRequest("POST", url, reader)
  1855. if err != nil {
  1856. fmt.Println(err.Error())
  1857. return err.Error()
  1858. }
  1859. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1860. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1861. request.Header.Set("x-tif-signature", signature)
  1862. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1863. request.Header.Set("x-tif-nonce", nonce)
  1864. client := http.Client{}
  1865. resp, err := client.Do(request)
  1866. if err != nil {
  1867. fmt.Println(err.Error())
  1868. return err.Error()
  1869. }
  1870. respBytes, err := ioutil.ReadAll(resp.Body)
  1871. if err != nil {
  1872. fmt.Println(err.Error())
  1873. return err.Error()
  1874. }
  1875. str := string(respBytes)
  1876. fmt.Println(str)
  1877. return str
  1878. }
  1879. func Gdyb2001(baseParams models.BaseParams, psn_no string, insutype string, med_type string) string {
  1880. if med_type == "1111" || med_type == "1112" {
  1881. med_type = "11"
  1882. }
  1883. // 生成签名
  1884. nonce := GetRandomString(32)
  1885. timestamp := time.Now().Unix()
  1886. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1887. // 生成输入报文
  1888. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1889. input := make(map[string]interface{})
  1890. inputData := make(map[string]interface{})
  1891. inputMessage["infno"] = "2001" // 交易编码
  1892. inputData["psn_no"] = psn_no
  1893. inputData["insutype"] = insutype
  1894. inputData["fixmedins_code"] = baseParams.FixmedinsCode
  1895. inputData["med_type"] = med_type
  1896. inputData["begntime"] = "2021-01-01 00:00:00"
  1897. input["data"] = inputData
  1898. inputMessage["input"] = input //交易输入
  1899. bytesData, err := json.Marshal(inputMessage)
  1900. fmt.Println(string(bytesData))
  1901. if err != nil {
  1902. fmt.Println(err.Error())
  1903. return err.Error()
  1904. }
  1905. reader := bytes.NewReader(bytesData)
  1906. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3301"
  1907. gdyb_url := beego.AppConfig.String("gdyb_url")
  1908. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1909. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1910. url := gdyb_url
  1911. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3301"
  1912. request, err := http.NewRequest("POST", url, reader)
  1913. if err != nil {
  1914. fmt.Println(err.Error())
  1915. return err.Error()
  1916. }
  1917. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1918. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1919. request.Header.Set("x-tif-signature", signature)
  1920. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1921. request.Header.Set("x-tif-nonce", nonce)
  1922. client := http.Client{}
  1923. resp, err := client.Do(request)
  1924. if err != nil {
  1925. fmt.Println(err.Error())
  1926. return err.Error()
  1927. }
  1928. respBytes, err := ioutil.ReadAll(resp.Body)
  1929. if err != nil {
  1930. fmt.Println(err.Error())
  1931. return err.Error()
  1932. }
  1933. str := string(respBytes)
  1934. fmt.Println(str)
  1935. return str
  1936. }
  1937. func Gdyb3301(baseParams *models.BaseParams, name string, codg string, list_type_code string, start_time string, ent_time string, list_type string) string {
  1938. // 生成签名
  1939. nonce := GetRandomString(32)
  1940. timestamp := time.Now().Unix()
  1941. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1942. // 生成输入报文
  1943. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1944. input := make(map[string]interface{})
  1945. inputData := make(map[string]interface{})
  1946. inputMessage["infno"] = "3301" // 交易编码
  1947. inputData["fixmedins_hilist_id"] = codg
  1948. inputData["fixmedins_hilist_name"] = name
  1949. inputData["list_type"] = list_type
  1950. inputData["med_list_codg"] = codg
  1951. inputData["begndate"] = start_time
  1952. inputData["enddate"] = ent_time
  1953. inputData["aprvno"] = ""
  1954. inputData["dosform"] = ""
  1955. inputData["exct_cont"] = ""
  1956. inputData["item_cont"] = ""
  1957. inputData["prcunt"] = ""
  1958. inputData["spec"] = ""
  1959. inputData["pacspec"] = ""
  1960. inputData["memo"] = ""
  1961. input["data"] = inputData
  1962. inputMessage["input"] = input //交易输入
  1963. bytesData, err := json.Marshal(inputMessage)
  1964. fmt.Println(string(bytesData))
  1965. if err != nil {
  1966. fmt.Println(err.Error())
  1967. return err.Error()
  1968. }
  1969. reader := bytes.NewReader(bytesData)
  1970. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3301"
  1971. //
  1972. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3301"
  1973. gdyb_url := beego.AppConfig.String("gdyb_url")
  1974. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1975. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1976. url := gdyb_url + "3301"
  1977. request, err := http.NewRequest("POST", url, reader)
  1978. if err != nil {
  1979. fmt.Println(err.Error())
  1980. return err.Error()
  1981. }
  1982. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1983. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1984. request.Header.Set("x-tif-signature", signature)
  1985. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1986. request.Header.Set("x-tif-nonce", nonce)
  1987. client := http.Client{}
  1988. resp, err := client.Do(request)
  1989. if err != nil {
  1990. fmt.Println(err.Error())
  1991. return err.Error()
  1992. }
  1993. respBytes, err := ioutil.ReadAll(resp.Body)
  1994. if err != nil {
  1995. fmt.Println(err.Error())
  1996. return err.Error()
  1997. }
  1998. str := string(respBytes)
  1999. fmt.Println(str)
  2000. return str
  2001. }
  2002. func Gdyb3302(baseParams *models.BaseParams, name string, codg string, list_type_code string) string {
  2003. // 生成签名
  2004. nonce := GetRandomString(32)
  2005. timestamp := time.Now().Unix()
  2006. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  2007. // 生成输入报文
  2008. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  2009. input := make(map[string]interface{})
  2010. inputData := make(map[string]interface{})
  2011. inputMessage["infno"] = "3302" // 交易编码
  2012. inputData["fixmedins_code"] = baseParams.FixmedinsCode
  2013. inputData["fixmedins_hilist_id"] = codg
  2014. inputData["list_type"] = list_type_code
  2015. inputData["med_list_codg"] = codg
  2016. input["data"] = inputData
  2017. inputMessage["input"] = input //交易输入
  2018. bytesData, err := json.Marshal(inputMessage)
  2019. fmt.Println(string(bytesData))
  2020. if err != nil {
  2021. fmt.Println(err.Error())
  2022. return err.Error()
  2023. }
  2024. reader := bytes.NewReader(bytesData)
  2025. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3302"
  2026. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3302"
  2027. gdyb_url := beego.AppConfig.String("gdyb_url")
  2028. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2029. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2030. url := gdyb_url + "3302"
  2031. request, err := http.NewRequest("POST", url, reader)
  2032. if err != nil {
  2033. fmt.Println(err.Error())
  2034. return err.Error()
  2035. }
  2036. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2037. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2038. request.Header.Set("x-tif-signature", signature)
  2039. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2040. request.Header.Set("x-tif-nonce", nonce)
  2041. client := http.Client{}
  2042. resp, err := client.Do(request)
  2043. if err != nil {
  2044. fmt.Println(err.Error())
  2045. return err.Error()
  2046. }
  2047. respBytes, err := ioutil.ReadAll(resp.Body)
  2048. if err != nil {
  2049. fmt.Println(err.Error())
  2050. return err.Error()
  2051. }
  2052. str := string(respBytes)
  2053. fmt.Println(str)
  2054. return str
  2055. }
  2056. 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 {
  2057. // 生成签名
  2058. nonce := GetRandomString(32)
  2059. timestamp := time.Now().Unix()
  2060. signature := setSignature(timestamp, nonce, secret_key)
  2061. // 生成输入报文
  2062. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2063. input := make(map[string]interface{})
  2064. inputData := make(map[string]interface{})
  2065. inputMessage["infno"] = "2505"
  2066. inputData["psn_no"] = psnNo
  2067. inputData["biz_appy_type"] = "01"
  2068. inputData["begndate"] = start_time
  2069. inputData["enddate"] = end_time
  2070. inputData["fixmedins_code"] = fixmedins_code
  2071. inputData["fixmedins_name"] = org_name
  2072. inputData["tel"] = ""
  2073. inputData["addr"] = ""
  2074. inputData["agnter_name"] = ""
  2075. inputData["agnter_cert_type"] = ""
  2076. inputData["agnter_certno"] = ""
  2077. inputData["agnter_tel"] = ""
  2078. inputData["agnter_addr"] = ""
  2079. inputData["agnter_rlts"] = ""
  2080. inputData["fix_srt_no"] = "1"
  2081. inputData["memo"] = ""
  2082. input["data"] = inputData
  2083. inputMessage["input"] = input //交易输入
  2084. bytesData, err := json.Marshal(inputMessage)
  2085. if err != nil {
  2086. fmt.Println(err.Error())
  2087. return err.Error()
  2088. }
  2089. reader := bytes.NewReader(bytesData)
  2090. //fmt.Println(String(bytesData))
  2091. fmt.Println(string(bytesData))
  2092. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2505"
  2093. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2505"
  2094. gdyb_url := beego.AppConfig.String("gdyb_url")
  2095. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2096. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2097. url := gdyb_url + "2505"
  2098. request, err := http.NewRequest("POST", url, reader)
  2099. if err != nil {
  2100. fmt.Println(err.Error())
  2101. return err.Error()
  2102. }
  2103. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2104. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2105. request.Header.Set("x-tif-signature", signature)
  2106. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2107. request.Header.Set("x-tif-nonce", nonce)
  2108. client := http.Client{}
  2109. resp, err := client.Do(request)
  2110. if err != nil {
  2111. fmt.Println(err.Error())
  2112. return err.Error()
  2113. }
  2114. respBytes, err := ioutil.ReadAll(resp.Body)
  2115. if err != nil {
  2116. fmt.Println(err.Error())
  2117. return err.Error()
  2118. }
  2119. str := string(respBytes)
  2120. fmt.Println(str)
  2121. return str
  2122. }
  2123. 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 {
  2124. // 生成签名
  2125. nonce := GetRandomString(32)
  2126. timestamp := time.Now().Unix()
  2127. signature := setSignature(timestamp, nonce, secret_key)
  2128. // 生成输入报文
  2129. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2130. input := make(map[string]interface{})
  2131. inputData := make(map[string]interface{})
  2132. inputMessage["infno"] = "2506"
  2133. inputData["psn_no"] = psnNo
  2134. inputData["trt_dcla_detl_sn"] = trt_dcla_detl_sn
  2135. inputData["memo"] = ""
  2136. input["data"] = inputData
  2137. inputMessage["input"] = input //交易输入
  2138. bytesData, err := json.Marshal(inputMessage)
  2139. fmt.Println(string(bytesData))
  2140. if err != nil {
  2141. fmt.Println(err.Error())
  2142. return err.Error()
  2143. }
  2144. reader := bytes.NewReader(bytesData)
  2145. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2506"
  2146. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2506"
  2147. gdyb_url := beego.AppConfig.String("gdyb_url")
  2148. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2149. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2150. url := gdyb_url + "2506"
  2151. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  2152. request, err := http.NewRequest("POST", url, reader)
  2153. if err != nil {
  2154. fmt.Println(err.Error())
  2155. return err.Error()
  2156. }
  2157. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2158. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2159. request.Header.Set("x-tif-signature", signature)
  2160. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2161. request.Header.Set("x-tif-nonce", nonce)
  2162. client := http.Client{}
  2163. resp, err := client.Do(request)
  2164. if err != nil {
  2165. fmt.Println(err.Error())
  2166. return err.Error()
  2167. }
  2168. respBytes, err := ioutil.ReadAll(resp.Body)
  2169. if err != nil {
  2170. fmt.Println(err.Error())
  2171. return err.Error()
  2172. }
  2173. str := string(respBytes)
  2174. fmt.Println(str)
  2175. return str
  2176. }
  2177. 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 {
  2178. // 生成签名
  2179. nonce := GetRandomString(32)
  2180. timestamp := time.Now().Unix()
  2181. signature := setSignature(timestamp, nonce, secret_key)
  2182. //tempTime := time.Unix(timestamp, 0)
  2183. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2184. //timeFormatTwo := tempTime.Format("2006-01-02")
  2185. //t := time.Now()
  2186. //last := time.Date(t.Year(), time.December, 31, 0, 0, 0, 0, time.UTC)
  2187. //tm := time.Unix(last.Unix(), 0)
  2188. // 生成输入报文
  2189. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2190. input := make(map[string]interface{})
  2191. inputData := make(map[string]interface{})
  2192. inputMessage["infno"] = "2503" // 交易编码
  2193. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  2194. inputData["insutype"] = insutype // 险种类型(来自1101接口返回)
  2195. inputData["opsp_dise_code"] = sick_code // 险种类型(来自1101接口返回)
  2196. inputData["opsp_dise_name"] = sick_name // 险种类型(来自1101接口返回)
  2197. inputData["insu_optins"] = insuplc_admdvs // 险种类型(来自1101接口返回)
  2198. inputData["ide_fixmedins_no"] = hospital_code // 险种类型(来自1101接口返回)
  2199. inputData["ide_fixmedins_name"] = hospital_name // 险种类型(来自1101接口返回)
  2200. inputData["hosp_ide_date"] = check_time // 险种类型(来自1101接口返回)
  2201. inputData["diag_dr_codg"] = doctor_id // 开始时间
  2202. inputData["diag_dr_name"] = doctor // 开始时间
  2203. inputData["begndate"] = start_time // 医师编码
  2204. inputData["tel"] = "" // 医师编码
  2205. inputData["addr"] = "" // 医师编码
  2206. inputData["enddate"] = end_time // 医师编码
  2207. input["data"] = inputData
  2208. inputMessage["input"] = input //交易输入
  2209. bytesData, err := json.Marshal(inputMessage)
  2210. fmt.Println(string(bytesData))
  2211. if err != nil {
  2212. fmt.Println(err.Error())
  2213. return err.Error()
  2214. }
  2215. reader := bytes.NewReader(bytesData)
  2216. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2503"
  2217. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2503"
  2218. gdyb_url := beego.AppConfig.String("gdyb_url")
  2219. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2220. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2221. //url := gdyb_url + "2503"
  2222. var url string
  2223. if fixmedins_code == "H15049901371" {
  2224. url = gdyb_url
  2225. } else {
  2226. url = gdyb_url + "2503"
  2227. }
  2228. request, err := http.NewRequest("POST", url, reader)
  2229. if err != nil {
  2230. fmt.Println(err.Error())
  2231. return err.Error()
  2232. }
  2233. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2234. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2235. request.Header.Set("x-tif-signature", signature)
  2236. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2237. request.Header.Set("x-tif-nonce", nonce)
  2238. client := http.Client{}
  2239. resp, err := client.Do(request)
  2240. if err != nil {
  2241. fmt.Println(err.Error())
  2242. return err.Error()
  2243. }
  2244. respBytes, err := ioutil.ReadAll(resp.Body)
  2245. if err != nil {
  2246. fmt.Println(err.Error())
  2247. return err.Error()
  2248. }
  2249. str := string(respBytes)
  2250. fmt.Println(str)
  2251. return str
  2252. }
  2253. 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 {
  2254. // 生成签名
  2255. nonce := GetRandomString(32)
  2256. timestamp := time.Now().Unix()
  2257. signature := setSignature(timestamp, nonce, secret_key)
  2258. // 生成输入报文
  2259. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2260. input := make(map[string]interface{})
  2261. inputData := make(map[string]interface{})
  2262. inputMessage["infno"] = "2504" // 交易编码
  2263. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  2264. inputData["trt_dcla_detl_sn"] = trt_dcla_detl_sn // 人员编号 (来自1101接口返回)
  2265. inputData["memo"] = "撤销备案" // 人员编号 (来自1101接口返回)
  2266. input["data"] = inputData
  2267. inputMessage["input"] = input //交易输入
  2268. bytesData, err := json.Marshal(inputMessage)
  2269. fmt.Println(string(bytesData))
  2270. if err != nil {
  2271. fmt.Println(err.Error())
  2272. return err.Error()
  2273. }
  2274. reader := bytes.NewReader(bytesData)
  2275. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2504"
  2276. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2504"
  2277. gdyb_url := beego.AppConfig.String("gdyb_url")
  2278. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2279. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2280. url := gdyb_url + "2504"
  2281. request, err := http.NewRequest("POST", url, reader)
  2282. if err != nil {
  2283. fmt.Println(err.Error())
  2284. return err.Error()
  2285. }
  2286. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2287. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2288. request.Header.Set("x-tif-signature", signature)
  2289. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2290. request.Header.Set("x-tif-nonce", nonce)
  2291. client := http.Client{}
  2292. resp, err := client.Do(request)
  2293. if err != nil {
  2294. fmt.Println(err.Error())
  2295. return err.Error()
  2296. }
  2297. respBytes, err := ioutil.ReadAll(resp.Body)
  2298. if err != nil {
  2299. fmt.Println(err.Error())
  2300. return err.Error()
  2301. }
  2302. str := string(respBytes)
  2303. fmt.Println(str)
  2304. return str
  2305. }
  2306. //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 {
  2307. // // 生成签名
  2308. // nonce := GetRandomString(32)
  2309. // timestamp := time.Now().Unix()
  2310. // signature := setSignature(timestamp, nonce, secret_key)
  2311. // tempTime := time.Unix(timestamp, 0)
  2312. // timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2313. //
  2314. // // 生成输入报文
  2315. // inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2316. // input := make(map[string]interface{})
  2317. // inputData := make(map[string]interface{})
  2318. // diseinfo := make([]map[string]interface{}, 0)
  2319. //
  2320. // inputMessage["infno"] = "2203" // 交易编码
  2321. // inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  2322. // inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  2323. // inputData["med_type"] = med_type // 医疗类别 16门诊特殊病
  2324. // inputData["begntime"] = timeFormatOne // 开始时间
  2325. // inputData["main_cond_dscr"] = "" // 主要病情描述
  2326. // inputData["dise_codg"] = sick_code // 病种编码
  2327. // inputData["dise_name"] = sick_name // 病种名称
  2328. // inputData["birctrl_type"] = "" // 计划生育手术类别
  2329. // inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
  2330. //
  2331. // diseinfo_sun := make(map[string]interface{})
  2332. // diseinfo_sun["diag_type"] = "1" // 诊断类别
  2333. // diseinfo_sun["diag_srt_no"] = "1" // 诊断排序号
  2334. // diseinfo_sun["diag_code"] = diag_code // 诊断代码
  2335. // diseinfo_sun["diag_name"] = diag // 诊断名称
  2336. // diseinfo_sun["diag_dept"] = department // 诊断科室
  2337. // diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
  2338. // diseinfo_sun["dise_dor_name"] = doctor // 诊断医生姓名
  2339. // diseinfo_sun["diag_time"] = timeFormatOne // 诊断时间
  2340. // diseinfo_sun["vali_flag"] = "1" // 有效标志
  2341. //
  2342. // diseinfo = append(diseinfo, diseinfo_sun)
  2343. // input["diseinfo"] = diseinfo
  2344. // input["mdtrtinfo"] = inputData
  2345. // inputMessage["input"] = input //交易输入
  2346. //
  2347. // bytesData, err := json.Marshal(inputMessage)
  2348. // fmt.Println(string(bytesData))
  2349. // if err != nil {
  2350. // fmt.Println(err.Error())
  2351. // return err.Error()
  2352. // }
  2353. // reader := bytes.NewReader(bytesData)
  2354. //
  2355. // url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2203"
  2356. //
  2357. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  2358. // request, err := http.NewRequest("POST", url, reader)
  2359. // if err != nil {
  2360. // fmt.Println(err.Error())
  2361. // return err.Error()
  2362. // }
  2363. //
  2364. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2365. // request.Header.Set("x-tif-paasid", "sg03_prd")
  2366. // request.Header.Set("x-tif-signature", signature)
  2367. // request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2368. // request.Header.Set("x-tif-nonce", nonce)
  2369. //
  2370. // client := http.Client{}
  2371. // resp, err := client.Do(request)
  2372. // if err != nil {
  2373. // fmt.Println(err.Error())
  2374. // return err.Error()
  2375. // }
  2376. // respBytes, err := ioutil.ReadAll(resp.Body)
  2377. // if err != nil {
  2378. // fmt.Println(err.Error())
  2379. // return err.Error()
  2380. // }
  2381. // str := string(respBytes)
  2382. // fmt.Println(str)
  2383. // return str
  2384. //}
  2385. func Gdyb5301(psnNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  2386. // 生成签名
  2387. nonce := GetRandomString(32)
  2388. timestamp := time.Now().Unix()
  2389. signature := setSignature(timestamp, nonce, secret_key)
  2390. //tempTime := time.Unix(timestamp, 0)
  2391. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2392. //timeFormatTwo := tempTime.Format("2006-01-02")
  2393. // 生成输入报文
  2394. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2395. input := make(map[string]interface{})
  2396. inputData := make(map[string]interface{})
  2397. inputMessage["infno"] = "5301" // 交易编码
  2398. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  2399. input["data"] = inputData
  2400. inputMessage["input"] = input //交易输入
  2401. bytesData, err := json.Marshal(inputMessage)
  2402. fmt.Println(string(bytesData))
  2403. if err != nil {
  2404. fmt.Println(err.Error())
  2405. return err.Error()
  2406. }
  2407. reader := bytes.NewReader(bytesData)
  2408. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  2409. gdyb_url := beego.AppConfig.String("gdyb_url")
  2410. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2411. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2412. url := gdyb_url + "5301"
  2413. request, err := http.NewRequest("POST", url, reader)
  2414. if err != nil {
  2415. fmt.Println(err.Error())
  2416. return err.Error()
  2417. }
  2418. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2419. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2420. request.Header.Set("x-tif-signature", signature)
  2421. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2422. request.Header.Set("x-tif-nonce", nonce)
  2423. client := http.Client{}
  2424. resp, err := client.Do(request)
  2425. if err != nil {
  2426. fmt.Println(err.Error())
  2427. return err.Error()
  2428. }
  2429. respBytes, err := ioutil.ReadAll(resp.Body)
  2430. if err != nil {
  2431. fmt.Println(err.Error())
  2432. return err.Error()
  2433. }
  2434. str := string(respBytes)
  2435. fmt.Println(str)
  2436. return str
  2437. }
  2438. func Gdyb5301Two(psnNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  2439. // 生成签名
  2440. nonce := GetRandomString(32)
  2441. timestamp := time.Now().Unix()
  2442. signature := setSignature(timestamp, nonce, secret_key)
  2443. //tempTime := time.Unix(timestamp, 0)
  2444. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2445. //timeFormatTwo := tempTime.Format("2006-01-02")
  2446. // 生成输入报文
  2447. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2448. input := make(map[string]interface{})
  2449. inputData := make(map[string]interface{})
  2450. inputMessage["infno"] = "5301" // 交易编码
  2451. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  2452. input["data"] = inputData
  2453. inputMessage["input"] = input //交易输入
  2454. bytesData, err := json.Marshal(inputMessage)
  2455. fmt.Println(string(bytesData))
  2456. if err != nil {
  2457. fmt.Println(err.Error())
  2458. return err.Error()
  2459. }
  2460. reader := bytes.NewReader(bytesData)
  2461. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  2462. gdyb_url := beego.AppConfig.String("gdyb_url")
  2463. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2464. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2465. url := gdyb_url
  2466. request, err := http.NewRequest("POST", url, reader)
  2467. if err != nil {
  2468. fmt.Println(err.Error())
  2469. return err.Error()
  2470. }
  2471. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2472. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2473. request.Header.Set("x-tif-signature", signature)
  2474. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2475. request.Header.Set("x-tif-nonce", nonce)
  2476. client := http.Client{}
  2477. resp, err := client.Do(request)
  2478. if err != nil {
  2479. fmt.Println(err.Error())
  2480. return err.Error()
  2481. }
  2482. respBytes, err := ioutil.ReadAll(resp.Body)
  2483. if err != nil {
  2484. fmt.Println(err.Error())
  2485. return err.Error()
  2486. }
  2487. str := string(respBytes)
  2488. fmt.Println(str)
  2489. return str
  2490. }
  2491. type CustomStruct struct {
  2492. FundPayType string
  2493. FundPayamt float64
  2494. }
  2495. type OpspdiseinfoStruct struct {
  2496. DiagName string
  2497. DiagCode string
  2498. OprnOprtName string
  2499. OprnOprtCode string
  2500. }
  2501. type DiaginfoStructTwo struct {
  2502. DiagType string
  2503. DiagCode string
  2504. DiagName string
  2505. MaindiagFlag string
  2506. }
  2507. type IteminfoStruct struct {
  2508. MedChrgitm string
  2509. Amt float64
  2510. ClaaSumfee float64
  2511. ClabAmt float64
  2512. FulamtOwnpayAmt float64
  2513. OthAmt float64
  2514. }
  2515. type Struct4101 struct {
  2516. PsnNo string
  2517. MdtrtId string
  2518. SetlId string
  2519. HiSetlLv string
  2520. PsnName string
  2521. Gend string
  2522. Brdy string
  2523. Ntly string
  2524. Naty string
  2525. PatnCertType string
  2526. Certno string
  2527. Prfs string
  2528. ConerName string
  2529. PatnRlts string
  2530. ConerAddr string
  2531. ConerTel string
  2532. HiType string
  2533. Insuplc string
  2534. AdmCaty string
  2535. DscgCaty string
  2536. MaindiagFlag string
  2537. BillCode string
  2538. BillNo string
  2539. BizSn string
  2540. SetlBegnDate string
  2541. SetlEndDate string
  2542. PsnSelfPay float64
  2543. PsnOwnPay float64
  2544. AcctPay float64
  2545. PsnCashpay float64
  2546. HiPaymtd string
  2547. Hsorg string
  2548. HsorgOpter string
  2549. MedinsFillDept string
  2550. MedinsFillPsn string
  2551. IptMedType string
  2552. Age int64
  2553. CustomStruct []CustomStruct
  2554. OpspdiseinfoStruct []OpspdiseinfoStruct
  2555. Diseinfo []DiaginfoStructTwo
  2556. IteminfoStruct []IteminfoStruct
  2557. AdmTime string
  2558. AdmEndTime string
  2559. HisNo string
  2560. DoctorName string
  2561. DoctorCode string
  2562. }
  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. str := strconv.FormatInt(timestamp, 10) + secret_key + nonce + strconv.FormatInt(timestamp, 10)
  3305. hash := sha256.New()
  3306. //输入数据
  3307. hash.Write([]byte(str))
  3308. //计算哈希值
  3309. bytes := hash.Sum(nil)
  3310. //将字符串编码为16进制格式,返回字符串
  3311. hashCode := hex.EncodeToString(bytes)
  3312. //返回哈希值
  3313. return hashCode
  3314. }
  3315. const charset = "abcdefghijklmnopqrstuvwxyz" +
  3316. "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
  3317. var seededRand *rand.Rand = rand.New(
  3318. rand.NewSource(time.Now().UnixNano()))
  3319. // 生成随机字符串
  3320. func GetRandomString(l int) string {
  3321. //str := "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
  3322. //bytes := []byte(str)
  3323. //result := []byte{}
  3324. //r := rand.New(rand.NewSource(time.Now().UnixNano()))
  3325. //for i := 0; i < l; i++ {
  3326. // result = append(result, bytes[r.Intn(len(bytes))])
  3327. //}
  3328. return String(32)
  3329. }
  3330. func StringWithCharset(length int, charset string) string {
  3331. b := make([]byte, length)
  3332. for i := range b {
  3333. b[i] = charset[seededRand.Intn(len(charset))]
  3334. }
  3335. return string(b)
  3336. }
  3337. func String(length int) string {
  3338. return StringWithCharset(length, charset)
  3339. }
  3340. // 生成基础报文
  3341. func SetInputMessage(nonce string, timestamp int64, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) map[string]interface{} {
  3342. // 生成签名
  3343. tempTime := time.Unix(timestamp, 0)
  3344. //timeFormat := tempTime.Format("20060102150405")
  3345. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  3346. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  3347. month := time.Unix(1557042972, 0).Format("1")
  3348. year := time.Now().Format("2006")
  3349. month = time.Now().Format("01")
  3350. day := time.Now().Format("02")
  3351. hour := time.Now().Format("15")
  3352. min := time.Now().Format("04")
  3353. sec := time.Now().Format("05")
  3354. msec := time.Now().Format("000")
  3355. // 生成输入报文
  3356. inputMessage := make(map[string]interface{})
  3357. inputMessage["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  3358. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  3359. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  3360. inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  3361. inputMessage["dev_no"] = "" // 设备编号
  3362. inputMessage["dev_safe_info"] = "" // 设备安全信息
  3363. inputMessage["cainfo"] = "" // 数字签名信息
  3364. inputMessage["signtype"] = "MOCK" // 签名类型
  3365. inputMessage["infver"] = "V1.0" // 接收方系统代码
  3366. inputMessage["opter_type"] = "1" // 经办人类别
  3367. inputMessage["opter"] = doctor // 经办人
  3368. inputMessage["opter_name"] = doctor // 经办人姓名
  3369. inputMessage["inf_time"] = timeFormatOne // 交易时间
  3370. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  3371. inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  3372. if mdtrtarea_admvs == "440100" {
  3373. inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号
  3374. } else {
  3375. inputMessage["sign_no"] = "" //交易签到流水号
  3376. }
  3377. return inputMessage
  3378. }
  3379. 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{} {
  3380. // 生成签名
  3381. tempTime := time.Unix(timestamp, 0)
  3382. //timeFormat := tempTime.Format("20060102150405")
  3383. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  3384. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  3385. // 生成输入报文
  3386. inputMessage := make(map[string]interface{})
  3387. inputMessage["msgid"] = msg_id // 发送方报文 ID
  3388. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  3389. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  3390. inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  3391. inputMessage["dev_no"] = "" // 设备编号
  3392. inputMessage["dev_safe_info"] = "" // 设备安全信息
  3393. inputMessage["cainfo"] = "" // 数字签名信息
  3394. inputMessage["signtype"] = "SM3" // 签名类型
  3395. inputMessage["infver"] = "V1.0" // 接收方系统代码
  3396. inputMessage["opter_type"] = "1" // 经办人类别
  3397. inputMessage["opter"] = doctor // 经办人
  3398. inputMessage["opter_name"] = doctor // 经办人姓名
  3399. inputMessage["inf_time"] = timeFormatOne // 交易时间
  3400. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  3401. inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  3402. if mdtrtarea_admvs == "440100" {
  3403. inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号
  3404. } else {
  3405. inputMessage["sign_no"] = "" //交易签到流水号
  3406. }
  3407. return inputMessage
  3408. }
  3409. 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{} {
  3410. // 生成签名
  3411. tempTime := time.Unix(timestamp, 0)
  3412. //timeFormat := tempTime.Format("20060102150405")
  3413. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  3414. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  3415. month := time.Unix(1557042972, 0).Format("1")
  3416. year := time.Now().Format("2006")
  3417. month = time.Now().Format("01")
  3418. day := time.Now().Format("02")
  3419. hour := time.Now().Format("15")
  3420. min := time.Now().Format("04")
  3421. sec := time.Now().Format("05")
  3422. msec := time.Now().Format("000")
  3423. // 生成输入报文
  3424. inputMessage := make(map[string]interface{})
  3425. inputMessage["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  3426. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  3427. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  3428. inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  3429. inputMessage["dev_no"] = "" // 设备编号
  3430. inputMessage["dev_safe_info"] = "" // 设备安全信息
  3431. inputMessage["cainfo"] = "" // 数字签名信息
  3432. inputMessage["signtype"] = "SM3" // 签名类型
  3433. inputMessage["infver"] = "V1.0" // 接收方系统代码
  3434. inputMessage["opter_type"] = "1" // 经办人类别
  3435. inputMessage["opter"] = doctor // 经办人
  3436. inputMessage["opter_name"] = doctor // 经办人姓名
  3437. inputMessage["inf_time"] = timeFormatOne // 交易时间
  3438. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  3439. inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  3440. if mdtrtarea_admvs == "440100" {
  3441. inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号
  3442. } else {
  3443. inputMessage["sign_no"] = sign_no //交易签到流水号
  3444. }
  3445. return inputMessage
  3446. }
  3447. func postFile(filename string, target_url string) (*http.Response, error) {
  3448. body_buf := bytes.NewBufferString("")
  3449. body_writer := multipart.NewWriter(body_buf)
  3450. // use the body_writer to write the Part headers to the buffer
  3451. _, err := body_writer.CreateFormFile("userfile", filename)
  3452. if err != nil {
  3453. fmt.Println("error writing to buffer")
  3454. return nil, err
  3455. }
  3456. // the file data will be the second part of the body
  3457. fh, err := os.Open(filename)
  3458. if err != nil {
  3459. fmt.Println("error opening file")
  3460. return nil, err
  3461. }
  3462. // need to know the boundary to properly close the part myself.
  3463. boundary := body_writer.Boundary()
  3464. //close_string := fmt.Sprintf("\r\n--%s--\r\n", boundary)
  3465. close_buf := bytes.NewBufferString(fmt.Sprintf("\r\n--%s--\r\n", boundary))
  3466. // use multi-reader to defer the reading of the file data until
  3467. // writing to the socket buffer.
  3468. request_reader := io.MultiReader(body_buf, fh, close_buf)
  3469. fi, err := fh.Stat()
  3470. if err != nil {
  3471. fmt.Printf("Error Stating file: %s", filename)
  3472. return nil, err
  3473. }
  3474. req, err := http.NewRequest("POST", target_url, request_reader)
  3475. if err != nil {
  3476. return nil, err
  3477. }
  3478. // Set headers for multipart, and Content Length
  3479. req.Header.Add("Content-Type", "multipart/form-data; boundary="+boundary)
  3480. req.ContentLength = fi.Size() + int64(body_buf.Len()) + int64(close_buf.Len())
  3481. return http.DefaultClient.Do(req)
  3482. }
  3483. //func Gdyb1201(psnNo string, org_name string, doctor string) string {
  3484. // // 生成签名
  3485. // nonce := GetRandomString(32)
  3486. // timestamp := time.Now().Unix()
  3487. // signature := setSignature(timestamp, nonce)
  3488. //
  3489. // // 生成输入报文
  3490. // inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, "")
  3491. // input := make(map[string]interface{})
  3492. // inputData := make(map[string]interface{})
  3493. // inputMessage["infno"] = "1201" // 交易编码
  3494. // inputData["fixmedins_type"] = psnNo // 人员编号 (来自1101接口返回)
  3495. // inputData["fixmedins_name"] = org_name // 人员编号 (来自1101接口返回)
  3496. // inputData["fixmedins_code"] = "" // 人员编号 (来自1101接口返回)
  3497. //
  3498. // input["medinsinfo"] = inputData
  3499. // inputMessage["input"] = input //交易输入
  3500. //
  3501. // bytesData, err := json.Marshal(inputMessage)
  3502. // fmt.Println(string(bytesData))
  3503. // if err != nil {
  3504. // fmt.Println(err.Error())
  3505. // return err.Error()
  3506. // }
  3507. // reader := bytes.NewReader(bytesData)
  3508. //
  3509. // url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1201"
  3510. // request, err := http.NewRequest("POST", url, reader)
  3511. // if err != nil {
  3512. // fmt.Println(err.Error())
  3513. // return err.Error()
  3514. // }
  3515. //
  3516. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3517. // request.Header.Set("x-tif-paasid", "test_hosp")
  3518. // request.Header.Set("x-tif-signature", signature)
  3519. // request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3520. // request.Header.Set("x-tif-nonce", nonce)
  3521. //
  3522. // client := http.Client{}
  3523. // resp, err := client.Do(request)
  3524. // if err != nil {
  3525. // fmt.Println(err.Error())
  3526. // return err.Error()
  3527. // }
  3528. // respBytes, err := ioutil.ReadAll(resp.Body)
  3529. // if err != nil {
  3530. // fmt.Println(err.Error())
  3531. // return err.Error()
  3532. // }
  3533. // str := string(respBytes)
  3534. // fmt.Println(str)
  3535. // return str
  3536. //}
  3537. func newfileUploadRequest(uri string, params map[string]string, paramName, path string) (*http.Request, error) {
  3538. file, err := os.Open(path)
  3539. if err != nil {
  3540. return nil, err
  3541. }
  3542. defer file.Close()
  3543. body := &bytes.Buffer{}
  3544. writer := multipart.NewWriter(body)
  3545. part, err := writer.CreateFormFile(paramName, filepath.Base(path))
  3546. if err != nil {
  3547. return nil, err
  3548. }
  3549. _, err = io.Copy(part, file)
  3550. for key, val := range params {
  3551. _ = writer.WriteField(key, val)
  3552. }
  3553. err = writer.Close()
  3554. if err != nil {
  3555. return nil, err
  3556. }
  3557. req, err := http.NewRequest("POST", uri, body)
  3558. req.Header.Set("Content-Type", writer.FormDataContentType())
  3559. return req, err
  3560. }
  3561. func CreateMedicalInsuranceCostCompareRecord(record *models.MedicalInsuranceCostCompare) error {
  3562. err := writeDb.Save(&record).Error
  3563. return err
  3564. }
  3565. //func Gdyb5203(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  3566. // // 生成签名
  3567. // nonce := GetRandomString(32)
  3568. // timestamp := time.Now().Unix()
  3569. // signature := setSignature(timestamp, nonce, secret_key)
  3570. //
  3571. // // 生成输入报文
  3572. // inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3573. // input := make(map[string]interface{})
  3574. // inputData := make(map[string]interface{})
  3575. // inputMessage["infno"] = "5203" // 交易编码
  3576. //
  3577. // inputData["fixmedins_type"] = "1"
  3578. // inputData["fixmedins_name"] = org_name
  3579. // inputData["fixmedins_code"] = fixmedins_code
  3580. // input["medinsinfo"] = inputData
  3581. // inputMessage["input"] = input //交易输入
  3582. //
  3583. // bytesData, err := json.Marshal(inputMessage)
  3584. // fmt.Println(string(bytesData))
  3585. // if err != nil {
  3586. // fmt.Println(err.Error())
  3587. // return err.Error()
  3588. // }
  3589. // reader := bytes.NewReader(bytesData)
  3590. // url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1201"
  3591. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1201"
  3592. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  3593. // request, err := http.NewRequest("POST", url, reader)
  3594. // if err != nil {
  3595. // fmt.Println(err.Error())
  3596. // return err.Error()
  3597. // }
  3598. //
  3599. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3600. // request.Header.Set("x-tif-paasid", "sg03_prd")
  3601. // request.Header.Set("x-tif-signature", signature)
  3602. // request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3603. // request.Header.Set("x-tif-nonce", nonce)
  3604. //
  3605. // client := http.Client{}
  3606. // resp, err := client.Do(request)
  3607. // if err != nil {
  3608. // fmt.Println(err.Error())
  3609. // return err.Error()
  3610. // }
  3611. // respBytes, err := ioutil.ReadAll(resp.Body)
  3612. // if err != nil {
  3613. // fmt.Println(err.Error())
  3614. // return err.Error()
  3615. // }
  3616. // fmt.Println(string(respBytes))
  3617. // str := string(respBytes)
  3618. // return str
  3619. //}
  3620. func CreatePsnRecord(record *models.GdybPsnRecord) {
  3621. writeDb.Save(&record)
  3622. return
  3623. }
  3624. func GetPsnRecordById(id int64) (record models.GdybPsnRecord, err error) {
  3625. err = readDb.Model(&models.GdybPsnRecord{}).Where("id = ?").First(&record).Error
  3626. return
  3627. }
  3628. func CreatePsnNCDSRecord(record *models.GdybPsnNcdsRecord) {
  3629. writeDb.Save(&record)
  3630. return
  3631. }
  3632. func GetPsnNCDSRecordById(id int64) (record models.GdybPsnNcdsRecord, err error) {
  3633. err = readDb.Model(&models.GdybPsnNcdsRecord{}).Where("id = ?", id).First(&record).Error
  3634. return
  3635. }
  3636. func GetPatientsByIds(ids []string, current_org_id int64) (patients []*models.Patients, err error) {
  3637. err = readDb.Model(&models.Patients{}).Where("id IN (?) AND user_org_id = ?", ids, current_org_id).Find(&patients).Error
  3638. return
  3639. }
  3640. 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 {
  3641. // 生成签名
  3642. nonce := GetRandomString(32)
  3643. timestamp := time.Now().Unix()
  3644. signature := setSignature(timestamp, nonce, secret_key)
  3645. // 生成输入报文
  3646. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3647. input := make(map[string]interface{})
  3648. inputData := make(map[string]interface{})
  3649. inputMessage["infno"] = "2601" // 交易编码
  3650. inputData["psn_no"] = psnNo
  3651. inputData["omsgid"] = omsgid
  3652. inputData["oinfno"] = oinfno
  3653. input["data"] = inputData
  3654. inputMessage["input"] = input //交易输入
  3655. bytesData, err := json.Marshal(inputMessage)
  3656. fmt.Println(string(bytesData))
  3657. if err != nil {
  3658. fmt.Println(err.Error())
  3659. return err.Error()
  3660. }
  3661. reader := bytes.NewReader(bytesData)
  3662. gdyb_url := beego.AppConfig.String("gdyb_url")
  3663. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3664. url := gdyb_url + "2601"
  3665. request, err := http.NewRequest("POST", url, reader)
  3666. if err != nil {
  3667. fmt.Println(err.Error())
  3668. return err.Error()
  3669. }
  3670. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3671. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3672. request.Header.Set("x-tif-signature", signature)
  3673. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3674. request.Header.Set("x-tif-nonce", nonce)
  3675. client := http.Client{}
  3676. resp, err := client.Do(request)
  3677. if err != nil {
  3678. fmt.Println(err.Error())
  3679. return err.Error()
  3680. }
  3681. respBytes, err := ioutil.ReadAll(resp.Body)
  3682. if err != nil {
  3683. fmt.Println(err.Error())
  3684. return err.Error()
  3685. }
  3686. str := string(respBytes)
  3687. fmt.Println(str)
  3688. return str
  3689. }
  3690. //人员信息版本3
  3691. 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 {
  3692. //生成签名
  3693. nonce := GetRandomString(32)
  3694. timestamp := time.Now().Unix()
  3695. signature := setSignature(timestamp, nonce, secret_key)
  3696. //生成输入报文
  3697. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3698. input := make(map[string]interface{})
  3699. inputData := make(map[string]interface{})
  3700. inputMessage["infno"] = "1101" // 交易编码
  3701. if certificates == 3 {
  3702. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  3703. inputData["certno"] = "01836483" // 证件号码
  3704. inputData["psn_cert_type"] = "01" // 人员证件类型
  3705. inputData["mdtrt_cert_no"] = "01836483" // 就诊凭证编号
  3706. } else {
  3707. if certificates == 1 {
  3708. if id_card_type == 1 {
  3709. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  3710. inputData["card_sn"] = card_sn // 卡识别码
  3711. inputData["certno"] = certNo // 证件号码
  3712. inputData["psn_cert_type"] = "01" // 人员证件类型
  3713. inputData["mdtrt_cert_no"] = cardNumber // 就诊凭证编号
  3714. } else {
  3715. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  3716. inputData["card_sn"] = "" // 卡识别码
  3717. inputData["certno"] = certNo // 证件号码
  3718. inputData["psn_cert_type"] = "01" // 人员证件类型
  3719. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  3720. }
  3721. } else if certificates == 6 {
  3722. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  3723. inputData["card_sn"] = "" // 卡识别码
  3724. inputData["certno"] = certNo // 证件号码
  3725. inputData["psn_cert_type"] = "17" // 人员证件类型
  3726. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  3727. }
  3728. }
  3729. inputData["begntime"] = "" // 开始时间
  3730. inputData["psn_name"] = name // 人员姓名
  3731. input["data"] = inputData
  3732. inputMessage["input"] = input //交易输入
  3733. bytesData, err := json.Marshal(inputMessage)
  3734. fmt.Println(string(bytesData))
  3735. if err != nil {
  3736. fmt.Println(err.Error())
  3737. return err.Error()
  3738. }
  3739. reader := bytes.NewReader(bytesData)
  3740. gdyb_url := beego.AppConfig.String("gdyb_url")
  3741. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3742. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  3743. //url := gdyb_url + "1101"
  3744. var url string
  3745. if fixmedins_code == "H15049901371" {
  3746. url = gdyb_url
  3747. } else {
  3748. url = gdyb_url + "1101"
  3749. }
  3750. fmt.Println(url)
  3751. fmt.Println(gdyb_paasid)
  3752. fmt.Println(secret_key)
  3753. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  3754. request, err := http.NewRequest("POST", url, reader)
  3755. if err != nil {
  3756. fmt.Println(err.Error())
  3757. return err.Error()
  3758. }
  3759. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3760. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3761. request.Header.Set("x-tif-signature", signature)
  3762. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3763. request.Header.Set("x-tif-nonce", nonce)
  3764. client := http.Client{}
  3765. resp, err := client.Do(request)
  3766. if err != nil {
  3767. fmt.Println(err.Error())
  3768. return err.Error()
  3769. }
  3770. respBytes, err := ioutil.ReadAll(resp.Body)
  3771. if err != nil {
  3772. fmt.Println(err.Error())
  3773. return err.Error()
  3774. }
  3775. fmt.Println(string(respBytes))
  3776. str := string(respBytes)
  3777. return str
  3778. }
  3779. 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 {
  3780. //生成签名
  3781. nonce := GetRandomString(32)
  3782. timestamp := time.Now().Unix()
  3783. signature := setSignature(timestamp, nonce, secret_key)
  3784. //生成输入报文
  3785. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3786. input := make(map[string]interface{})
  3787. inputData := make(map[string]interface{})
  3788. inputMessage["infno"] = "1101" // 交易编码
  3789. if certificates == 3 {
  3790. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  3791. inputData["certno"] = "01836483" // 证件号码
  3792. inputData["psn_cert_type"] = "01" // 人员证件类型
  3793. inputData["mdtrt_cert_no"] = "01836483" // 就诊凭证编号
  3794. } else {
  3795. if certificates == 1 {
  3796. if id_card_type == 1 {
  3797. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  3798. inputData["card_sn"] = "" // 卡识别码
  3799. inputData["certno"] = certNo // 证件号码
  3800. inputData["psn_cert_type"] = "01" // 人员证件类型
  3801. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  3802. } else {
  3803. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  3804. inputData["card_sn"] = "" // 卡识别码
  3805. inputData["certno"] = certNo // 证件号码
  3806. inputData["psn_cert_type"] = "" // 人员证件类型
  3807. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  3808. }
  3809. } else if certificates == 6 {
  3810. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  3811. inputData["card_sn"] = "" // 卡识别码
  3812. inputData["certno"] = certNo // 证件号码
  3813. inputData["psn_cert_type"] = "" // 人员证件类型
  3814. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  3815. }
  3816. }
  3817. inputData["begntime"] = "" // 开始时间
  3818. inputData["psn_name"] = "" // 人员姓名
  3819. input["data"] = inputData
  3820. inputMessage["input"] = input //交易输入
  3821. bytesData, err := json.Marshal(inputMessage)
  3822. fmt.Println(string(bytesData))
  3823. if err != nil {
  3824. fmt.Println(err.Error())
  3825. return err.Error()
  3826. }
  3827. reader := bytes.NewReader(bytesData)
  3828. gdyb_url := beego.AppConfig.String("gdyb_url")
  3829. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3830. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  3831. //url := gdyb_url + "1101"
  3832. var url string
  3833. if fixmedins_code == "H15049901371" {
  3834. url = gdyb_url
  3835. } else {
  3836. url = gdyb_url + "1101"
  3837. }
  3838. fmt.Println(url)
  3839. fmt.Println(gdyb_paasid)
  3840. fmt.Println(secret_key)
  3841. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  3842. request, err := http.NewRequest("POST", url, reader)
  3843. if err != nil {
  3844. fmt.Println(err.Error())
  3845. return err.Error()
  3846. }
  3847. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3848. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3849. request.Header.Set("x-tif-signature", signature)
  3850. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3851. request.Header.Set("x-tif-nonce", nonce)
  3852. client := http.Client{}
  3853. resp, err := client.Do(request)
  3854. if err != nil {
  3855. fmt.Println(err.Error())
  3856. return err.Error()
  3857. }
  3858. respBytes, err := ioutil.ReadAll(resp.Body)
  3859. if err != nil {
  3860. fmt.Println(err.Error())
  3861. return err.Error()
  3862. }
  3863. fmt.Println(string(respBytes))
  3864. str := string(respBytes)
  3865. return str
  3866. }
  3867. 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 {
  3868. //生成签名
  3869. nonce := GetRandomString(32)
  3870. timestamp := time.Now().Unix()
  3871. signature := setSignature(timestamp, nonce, secret_key)
  3872. //生成输入报文
  3873. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3874. input := make(map[string]interface{})
  3875. inputData := make(map[string]interface{})
  3876. inputMessage["infno"] = "1101" // 交易编码
  3877. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  3878. inputData["card_sn"] = card_sn // 卡识别码
  3879. inputData["certno"] = certNo // 证件号码
  3880. inputData["psn_cert_type"] = "01" // 人员证件类型
  3881. inputData["mdtrt_cert_no"] = cardNumber // 就诊凭证编号
  3882. inputData["begntime"] = "" // 开始时间
  3883. inputData["psn_name"] = name // 人员姓名
  3884. input["data"] = inputData
  3885. inputMessage["input"] = input //交易输入
  3886. bytesData, err := json.Marshal(inputMessage)
  3887. fmt.Println(string(bytesData))
  3888. if err != nil {
  3889. fmt.Println(err.Error())
  3890. return err.Error()
  3891. }
  3892. reader := bytes.NewReader(bytesData)
  3893. gdyb_url := beego.AppConfig.String("gdyb_url")
  3894. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3895. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  3896. //url := gdyb_url + "1101"
  3897. var url string
  3898. if fixmedins_code == "H15049901371" {
  3899. url = gdyb_url
  3900. } else {
  3901. url = gdyb_url + "1101"
  3902. }
  3903. fmt.Println(url)
  3904. fmt.Println(gdyb_paasid)
  3905. fmt.Println(secret_key)
  3906. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  3907. request, err := http.NewRequest("POST", url, reader)
  3908. if err != nil {
  3909. fmt.Println(err.Error())
  3910. return err.Error()
  3911. }
  3912. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3913. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3914. request.Header.Set("x-tif-signature", signature)
  3915. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3916. request.Header.Set("x-tif-nonce", nonce)
  3917. client := http.Client{}
  3918. resp, err := client.Do(request)
  3919. if err != nil {
  3920. fmt.Println(err.Error())
  3921. return err.Error()
  3922. }
  3923. respBytes, err := ioutil.ReadAll(resp.Body)
  3924. if err != nil {
  3925. fmt.Println(err.Error())
  3926. return err.Error()
  3927. }
  3928. fmt.Println(string(respBytes))
  3929. str := string(respBytes)
  3930. return str
  3931. }
  3932. 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) {
  3933. //生成签名
  3934. nonce := GetRandomString(32)
  3935. timestamp := time.Now().Unix()
  3936. signature := setSignature(timestamp, nonce, secret_key)
  3937. //生成输入报文
  3938. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3939. input := make(map[string]interface{})
  3940. inputData := make(map[string]interface{})
  3941. inputMessage["infno"] = "1101" // 交易编码
  3942. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  3943. inputData["card_sn"] = "" // 卡识别码
  3944. inputData["certno"] = idNo // 证件号码
  3945. inputData["psn_cert_type"] = "01" // 人员证件类型
  3946. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  3947. inputData["begntime"] = "" // 开始时间
  3948. inputData["psn_name"] = user_name // 人员姓名
  3949. input["data"] = inputData
  3950. inputMessage["input"] = input //交易输入
  3951. bytesData, err := json.Marshal(inputMessage)
  3952. fmt.Println(string(bytesData))
  3953. if err != nil {
  3954. fmt.Println(err.Error())
  3955. return err.Error(), ""
  3956. }
  3957. reader := bytes.NewReader(bytesData)
  3958. gdyb_url := beego.AppConfig.String("gdyb_url")
  3959. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3960. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  3961. //url := gdyb_url + "1101"
  3962. var url string
  3963. if fixmedins_code == "H15049901371" {
  3964. url = gdyb_url
  3965. } else {
  3966. url = gdyb_url + "1101"
  3967. }
  3968. fmt.Println(url)
  3969. fmt.Println(gdyb_paasid)
  3970. fmt.Println(secret_key)
  3971. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  3972. request, err := http.NewRequest("POST", url, reader)
  3973. if err != nil {
  3974. fmt.Println(err.Error())
  3975. return err.Error(), ""
  3976. }
  3977. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3978. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3979. request.Header.Set("x-tif-signature", signature)
  3980. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3981. request.Header.Set("x-tif-nonce", nonce)
  3982. client := http.Client{}
  3983. resp, err := client.Do(request)
  3984. if err != nil {
  3985. fmt.Println(err.Error())
  3986. return err.Error(), ""
  3987. }
  3988. respBytes, err := ioutil.ReadAll(resp.Body)
  3989. if err != nil {
  3990. fmt.Println(err.Error())
  3991. return err.Error(), ""
  3992. }
  3993. fmt.Println(string(respBytes))
  3994. str := string(respBytes)
  3995. return str, string(bytesData)
  3996. }
  3997. 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) {
  3998. //生成签名
  3999. nonce := GetRandomString(32)
  4000. timestamp := time.Now().Unix()
  4001. signature := setSignature(timestamp, nonce, secret_key)
  4002. //生成输入报文
  4003. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4004. input := make(map[string]interface{})
  4005. inputData := make(map[string]interface{})
  4006. inputMessage["infno"] = "1101" // 交易编码
  4007. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  4008. inputData["card_sn"] = "" // 卡识别码
  4009. inputData["certno"] = idNo // 证件号码
  4010. inputData["psn_cert_type"] = "01" // 人员证件类型
  4011. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  4012. inputData["begntime"] = "" // 开始时间
  4013. inputData["psn_name"] = user_name // 人员姓名
  4014. input["data"] = inputData
  4015. inputMessage["input"] = input //交易输入
  4016. bytesData, err := json.Marshal(inputMessage)
  4017. fmt.Println(string(bytesData))
  4018. if err != nil {
  4019. fmt.Println(err.Error())
  4020. return err.Error(), ""
  4021. }
  4022. reader := bytes.NewReader(bytesData)
  4023. gdyb_url := beego.AppConfig.String("gdyb_url")
  4024. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4025. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4026. //url := gdyb_url + "1101"
  4027. var url string
  4028. if fixmedins_code == "H15049901371" {
  4029. url = gdyb_url
  4030. } else {
  4031. url = gdyb_url + "1101"
  4032. }
  4033. fmt.Println(url)
  4034. fmt.Println(gdyb_paasid)
  4035. fmt.Println(secret_key)
  4036. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4037. request, err := http.NewRequest("POST", url, reader)
  4038. if err != nil {
  4039. fmt.Println(err.Error())
  4040. return err.Error(), ""
  4041. }
  4042. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4043. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4044. request.Header.Set("x-tif-signature", signature)
  4045. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4046. request.Header.Set("x-tif-nonce", nonce)
  4047. client := http.Client{}
  4048. resp, err := client.Do(request)
  4049. if err != nil {
  4050. fmt.Println(err.Error())
  4051. return err.Error(), ""
  4052. }
  4053. respBytes, err := ioutil.ReadAll(resp.Body)
  4054. if err != nil {
  4055. fmt.Println(err.Error())
  4056. return err.Error(), ""
  4057. }
  4058. fmt.Println(string(respBytes))
  4059. str := string(respBytes)
  4060. return str, string(bytesData)
  4061. }
  4062. func Gdyb6101(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) (string, string) {
  4063. //生成签名
  4064. nonce := GetRandomString(32)
  4065. timestamp := time.Now().Unix()
  4066. signature := setSignature(timestamp, nonce, secret_key)
  4067. //生成输入报文
  4068. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4069. input := make(map[string]interface{})
  4070. inputData := make(map[string]interface{})
  4071. inputMessage["infno"] = "6101" // 交易编码
  4072. inputData["orgId"] = fixmedins_code // 就诊凭证类型
  4073. inputData["businessType"] = "01101" // 卡识别码
  4074. inputData["businessInfo"] = "" // 证件号码
  4075. inputData["operateorId"] = "01" // 人员证件类型
  4076. inputData["operateornName"] = doctor // 就诊凭证编号
  4077. inputData["officeId"] = "01" // 开始时间
  4078. inputData["officeName"] = "血透" // 人员姓名
  4079. inputData["deviceType"] = "" // 人员姓名
  4080. input["InData"] = inputData
  4081. inputMessage["input"] = input //交易输入
  4082. bytesData, err := json.Marshal(inputMessage)
  4083. fmt.Println(string(bytesData))
  4084. if err != nil {
  4085. fmt.Println(err.Error())
  4086. return err.Error(), ""
  4087. }
  4088. reader := bytes.NewReader(bytesData)
  4089. gdyb_url := beego.AppConfig.String("gdyb_url")
  4090. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4091. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4092. //url := gdyb_url + "1101"
  4093. var url string
  4094. if fixmedins_code == "H15049901371" {
  4095. url = gdyb_url
  4096. } else {
  4097. url = gdyb_url + "1101"
  4098. }
  4099. fmt.Println(url)
  4100. fmt.Println(gdyb_paasid)
  4101. fmt.Println(secret_key)
  4102. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4103. request, err := http.NewRequest("POST", url, reader)
  4104. if err != nil {
  4105. fmt.Println(err.Error())
  4106. return err.Error(), ""
  4107. }
  4108. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4109. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4110. request.Header.Set("x-tif-signature", signature)
  4111. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4112. request.Header.Set("x-tif-nonce", nonce)
  4113. client := http.Client{}
  4114. resp, err := client.Do(request)
  4115. if err != nil {
  4116. fmt.Println(err.Error())
  4117. return err.Error(), ""
  4118. }
  4119. respBytes, err := ioutil.ReadAll(resp.Body)
  4120. if err != nil {
  4121. fmt.Println(err.Error())
  4122. return err.Error(), ""
  4123. }
  4124. fmt.Println(string(respBytes))
  4125. str := string(respBytes)
  4126. return str, string(bytesData)
  4127. }
  4128. //人员信息版本4
  4129. 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) {
  4130. //生成签名
  4131. nonce := GetRandomString(32)
  4132. timestamp := time.Now().Unix()
  4133. //signature := setSignature(timestamp, nonce, secret_key)
  4134. //生成输入报文
  4135. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4136. input := make(map[string]interface{})
  4137. inputData := make(map[string]interface{})
  4138. inputMessage["infno"] = "1101" // 交易编码
  4139. if certificates == 3 {
  4140. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  4141. inputData["certno"] = certNo // 证件号码
  4142. inputData["psn_cert_type"] = "99" // 人员证件类型
  4143. } else {
  4144. if id_card_type == 1 {
  4145. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  4146. inputData["card_sn"] = "" // 卡识别码
  4147. inputData["certno"] = "" // 证件号码
  4148. inputData["psn_cert_type"] = "" // 人员证件类型
  4149. } else {
  4150. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  4151. inputData["card_sn"] = "" // 卡识别码
  4152. inputData["certno"] = certNo // 证件号码
  4153. inputData["psn_cert_type"] = "1" // 人员证件类型
  4154. }
  4155. }
  4156. inputData["mdtrt_cert_no"] = "" // 就诊凭证编号
  4157. inputData["begntime"] = "" // 开始时间
  4158. inputData["psn_name"] = "" // 人员姓名
  4159. input["data"] = inputData
  4160. inputMessage["input"] = input //交易输入
  4161. bytesData, err := json.Marshal(inputMessage)
  4162. fmt.Println(string(bytesData))
  4163. if err != nil {
  4164. fmt.Println(err.Error())
  4165. return err.Error(), ""
  4166. }
  4167. var json2 string
  4168. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  4169. out, err := cmd.Output()
  4170. if err != nil {
  4171. fmt.Println("error:", err.Error())
  4172. }
  4173. fmt.Println(string(out))
  4174. return string(out), string(bytesData)
  4175. }
  4176. func StrPtr(s string) uintptr {
  4177. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  4178. }
  4179. 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 {
  4180. //生成签名
  4181. nonce := GetRandomString(32)
  4182. timestamp := time.Now().Unix()
  4183. signature := setSignature(timestamp, nonce, secret_key)
  4184. //生成输入报文
  4185. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4186. input := make(map[string]interface{})
  4187. inputData := make(map[string]interface{})
  4188. inputMessage["infno"] = "90991" // 交易编码
  4189. inputData["fixmedins_code"] = fixmedins_code // 就诊凭证编号
  4190. inputData["psn_no"] = psn_no // 开始时间
  4191. inputData["card_pwd"] = pwd // 人员姓名
  4192. inputData["sscno"] = card_number // 人员姓名
  4193. input["data"] = inputData
  4194. inputMessage["input"] = input //交易输入
  4195. bytesData, err := json.Marshal(inputMessage)
  4196. fmt.Println(string(bytesData))
  4197. if err != nil {
  4198. fmt.Println(err.Error())
  4199. return err.Error()
  4200. }
  4201. reader := bytes.NewReader(bytesData)
  4202. gdyb_url := beego.AppConfig.String("gdyb_url")
  4203. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4204. url := gdyb_url + "90991"
  4205. request, err := http.NewRequest("POST", url, reader)
  4206. if err != nil {
  4207. fmt.Println(err.Error())
  4208. return err.Error()
  4209. }
  4210. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4211. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4212. request.Header.Set("x-tif-signature", signature)
  4213. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4214. request.Header.Set("x-tif-nonce", nonce)
  4215. client := http.Client{}
  4216. resp, err := client.Do(request)
  4217. if err != nil {
  4218. fmt.Println(err.Error())
  4219. return err.Error()
  4220. }
  4221. respBytes, err := ioutil.ReadAll(resp.Body)
  4222. if err != nil {
  4223. fmt.Println(err.Error())
  4224. return err.Error()
  4225. }
  4226. fmt.Println(string(respBytes))
  4227. str := string(respBytes)
  4228. return str
  4229. }
  4230. func Gdyb90100(psn_no string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  4231. //生成签名
  4232. nonce := GetRandomString(32)
  4233. timestamp := time.Now().Unix()
  4234. signature := setSignature(timestamp, nonce, secret_key)
  4235. //生成输入报文
  4236. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4237. input := make(map[string]interface{})
  4238. inputData := make(map[string]interface{})
  4239. inputMessage["infno"] = "90100" // 交易编码
  4240. inputData["psn_no"] = psn_no // 开始时间
  4241. input["data"] = inputData
  4242. inputMessage["input"] = input //交易输入
  4243. bytesData, err := json.Marshal(inputMessage)
  4244. fmt.Println(string(bytesData))
  4245. if err != nil {
  4246. fmt.Println(err.Error())
  4247. return err.Error()
  4248. }
  4249. reader := bytes.NewReader(bytesData)
  4250. gdyb_url := beego.AppConfig.String("gdyb_url")
  4251. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4252. url := gdyb_url + "90100"
  4253. request, err := http.NewRequest("POST", url, reader)
  4254. if err != nil {
  4255. fmt.Println(err.Error())
  4256. return err.Error()
  4257. }
  4258. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4259. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4260. request.Header.Set("x-tif-signature", signature)
  4261. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4262. request.Header.Set("x-tif-nonce", nonce)
  4263. client := http.Client{}
  4264. resp, err := client.Do(request)
  4265. if err != nil {
  4266. fmt.Println(err.Error())
  4267. return err.Error()
  4268. }
  4269. respBytes, err := ioutil.ReadAll(resp.Body)
  4270. if err != nil {
  4271. fmt.Println(err.Error())
  4272. return err.Error()
  4273. }
  4274. fmt.Println(string(respBytes))
  4275. str := string(respBytes)
  4276. return str
  4277. }
  4278. 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) {
  4279. //生成签名
  4280. nonce := GetRandomString(32)
  4281. timestamp := time.Now().Unix()
  4282. signature := setSignature(timestamp, nonce, secret_key)
  4283. //生成输入报文
  4284. inputMessage := SetInputMessageTwo(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, sign)
  4285. input := make(map[string]interface{})
  4286. inputData := make(map[string]interface{})
  4287. inputMessage["infno"] = "3260" // 交易编码
  4288. inputData["sign"] = sign // 就诊凭证编号
  4289. inputData["trt_year"] = year // 就诊凭证编号
  4290. inputData["trt_month"] = month // 开始时间
  4291. inputData["startrow"] = count // 人员姓名
  4292. input["data"] = inputData
  4293. inputMessage["input"] = input //交易输入
  4294. var inputLog string
  4295. bytesData, err := json.Marshal(inputMessage)
  4296. inputLog = string(bytesData)
  4297. fmt.Println(string(bytesData))
  4298. if err != nil {
  4299. fmt.Println(err.Error())
  4300. return err.Error(), ""
  4301. }
  4302. reader := bytes.NewReader(bytesData)
  4303. gdyb_url := beego.AppConfig.String("gdyb_url")
  4304. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4305. var url string
  4306. if fixmedins_code == "H15049901371" {
  4307. url = gdyb_url
  4308. } else {
  4309. url = gdyb_url + "3260"
  4310. }
  4311. if insuplc_admdvs == "421300" {
  4312. var json2 string
  4313. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  4314. out, err := cmd.Output()
  4315. if err != nil {
  4316. fmt.Println("error:", err.Error())
  4317. }
  4318. fmt.Println(string(out))
  4319. return hex.EncodeToString(out), inputLog
  4320. } else {
  4321. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4322. request, err := http.NewRequest("POST", url, reader)
  4323. if err != nil {
  4324. fmt.Println(err.Error())
  4325. return err.Error(), ""
  4326. }
  4327. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4328. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4329. request.Header.Set("x-tif-signature", signature)
  4330. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4331. request.Header.Set("x-tif-nonce", nonce)
  4332. client := http.Client{}
  4333. resp, err := client.Do(request)
  4334. if err != nil {
  4335. fmt.Println(err.Error())
  4336. return err.Error(), ""
  4337. }
  4338. respBytes, err := ioutil.ReadAll(resp.Body)
  4339. if err != nil {
  4340. fmt.Println(err.Error())
  4341. return err.Error(), ""
  4342. }
  4343. fmt.Println(string(respBytes))
  4344. str := string(respBytes)
  4345. return str, inputLog
  4346. }
  4347. }
  4348. 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) {
  4349. //msg_month := time.Unix(1557042972, 0).Format("1")
  4350. //msg_year := time.Now().Format("2006")
  4351. //msg_month = time.Now().Format("01")
  4352. //day := time.Now().Format("02")
  4353. //
  4354. //hour := time.Now().Format("15")
  4355. //min := time.Now().Format("04")
  4356. //sec := time.Now().Format("05")
  4357. //
  4358. //msec := time.Now().Format("000")
  4359. //msg_id := fixmedins_code + msg_year + msg_month + day + hour + min + sec + msec + "0"
  4360. //生成输入报文
  4361. var curpage int
  4362. var pagesize int = 10
  4363. var start int = 1
  4364. var stop int
  4365. //pagecount := 10
  4366. pagecount := int(math.Ceil(float64(len(result3260.Output.Data)) / float64(pagesize)))
  4367. for curpage = 1; curpage <= pagecount; curpage++ {
  4368. //生成签名
  4369. nonce := GetRandomString(32)
  4370. timestamp := time.Now().Unix()
  4371. signature := setSignature(timestamp, nonce, secret_key)
  4372. inputMessage := SetInputMessageTwo(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, sign_no)
  4373. input := make(map[string]interface{})
  4374. inputData := make(map[string]interface{})
  4375. inputMessage["infno"] = "3261" // 交易编码
  4376. inputData["trt_year"] = year // 就诊凭证编号
  4377. inputData["trt_month"] = month // 开始时间
  4378. feedetail := make([]map[string]interface{}, 0)
  4379. if curpage == 1 {
  4380. start = 1
  4381. } else {
  4382. start = (curpage-1)*pagesize + 1
  4383. }
  4384. stop = curpage * pagesize
  4385. if stop > len(result3260.Output.Data) {
  4386. stop = len(result3260.Output.Data)
  4387. }
  4388. for _, item := range result3260.Output.Data[start-1 : stop] {
  4389. if item.MdtrtId != "out20230406681871" && item.MdtrtId != "out20230406681868" && item.MdtrtId != "out20230418732788" {
  4390. feedetailInfo := make(map[string]interface{})
  4391. feedetailInfo["certno"] = item.Certno
  4392. feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  4393. feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  4394. feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  4395. feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  4396. feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  4397. feedetailInfo["cnfm_flag"] = "1" // 处方号
  4398. feedetail = append(feedetail, feedetailInfo)
  4399. }
  4400. }
  4401. for _, item := range result3260.Output.Data[start-1 : stop] {
  4402. if item.MdtrtId == "out20230406681871" {
  4403. feedetailInfo := make(map[string]interface{})
  4404. feedetailInfo["certno"] = item.Certno
  4405. feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  4406. feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  4407. feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  4408. feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  4409. feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  4410. feedetailInfo["cnfm_flag"] = "0" // 处方号
  4411. feedetail = append(feedetail, feedetailInfo)
  4412. }
  4413. }
  4414. for _, item := range result3260.Output.Data[start-1 : stop] {
  4415. if item.MdtrtId == "out20230406681868" {
  4416. feedetailInfo := make(map[string]interface{})
  4417. feedetailInfo["certno"] = item.Certno
  4418. feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  4419. feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  4420. feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  4421. feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  4422. feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  4423. feedetailInfo["cnfm_flag"] = "0" // 处方号
  4424. feedetail = append(feedetail, feedetailInfo)
  4425. }
  4426. }
  4427. for _, item := range result3260.Output.Data[start-1 : stop] {
  4428. if item.MdtrtId == "out20230418732788" {
  4429. feedetailInfo := make(map[string]interface{})
  4430. feedetailInfo["certno"] = item.Certno
  4431. feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  4432. feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  4433. feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  4434. feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  4435. feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  4436. feedetailInfo["cnfm_flag"] = "0" // 处方号
  4437. feedetail = append(feedetail, feedetailInfo)
  4438. }
  4439. }
  4440. inputData["totalrow"] = 314 // 人员姓名
  4441. input["data"] = inputData
  4442. input["detail"] = feedetail
  4443. inputMessage["input"] = input //交易输入
  4444. //var inputLog string
  4445. bytesData, err := json.Marshal(inputMessage)
  4446. //inputLog = string(bytesData)
  4447. fmt.Println(string(bytesData))
  4448. if err != nil {
  4449. fmt.Println(err.Error())
  4450. return
  4451. }
  4452. reader := bytes.NewReader(bytesData)
  4453. gdyb_url := beego.AppConfig.String("gdyb_url")
  4454. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4455. var url string
  4456. if fixmedins_code == "H15049901371" {
  4457. url = gdyb_url
  4458. } else {
  4459. url = gdyb_url + "3261"
  4460. }
  4461. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4462. request, err := http.NewRequest("POST", url, reader)
  4463. if err != nil {
  4464. fmt.Println(err.Error())
  4465. return
  4466. }
  4467. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4468. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4469. request.Header.Set("x-tif-signature", signature)
  4470. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4471. request.Header.Set("x-tif-nonce", nonce)
  4472. client := http.Client{}
  4473. resp, err := client.Do(request)
  4474. if err != nil {
  4475. fmt.Println(err.Error())
  4476. return
  4477. }
  4478. respBytes, err := ioutil.ReadAll(resp.Body)
  4479. if err != nil {
  4480. fmt.Println(err.Error())
  4481. return
  4482. }
  4483. fmt.Println(string(respBytes))
  4484. str := string(respBytes)
  4485. fmt.Println(str)
  4486. //return str, inputLog, msg_id
  4487. }
  4488. return
  4489. }
  4490. 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) {
  4491. //生成签名
  4492. nonce := GetRandomString(32)
  4493. timestamp := time.Now().Unix()
  4494. signature := setSignature(timestamp, nonce, secret_key)
  4495. //生成输入报文
  4496. inputMessage := SetInputMessageTwo(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, sign_no)
  4497. input := make(map[string]interface{})
  4498. inputData := make(map[string]interface{})
  4499. inputMessage["infno"] = "3262" // 交易编码
  4500. inputData["trt_year"] = year // 就诊凭证编号
  4501. inputData["trt_month"] = "05" // 开始时间
  4502. inputData["otransid"] = "0" // 开始时间
  4503. input["data"] = inputData
  4504. inputMessage["input"] = input //交易输入
  4505. var inputLog string
  4506. bytesData, err := json.Marshal(inputMessage)
  4507. inputLog = string(bytesData)
  4508. fmt.Println(string(bytesData))
  4509. if err != nil {
  4510. fmt.Println(err.Error())
  4511. return err.Error(), ""
  4512. }
  4513. reader := bytes.NewReader(bytesData)
  4514. gdyb_url := beego.AppConfig.String("gdyb_url")
  4515. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4516. var url string
  4517. if fixmedins_code == "H15049901371" {
  4518. url = gdyb_url
  4519. } else {
  4520. url = gdyb_url + "3262"
  4521. }
  4522. if insuplc_admdvs == "421300" {
  4523. var json2 string
  4524. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  4525. out, err := cmd.Output()
  4526. if err != nil {
  4527. fmt.Println("error:", err.Error())
  4528. }
  4529. fmt.Println(string(out))
  4530. return hex.EncodeToString(out), inputLog
  4531. } else {
  4532. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4533. request, err := http.NewRequest("POST", url, reader)
  4534. if err != nil {
  4535. fmt.Println(err.Error())
  4536. return err.Error(), ""
  4537. }
  4538. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4539. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4540. request.Header.Set("x-tif-signature", signature)
  4541. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4542. request.Header.Set("x-tif-nonce", nonce)
  4543. client := http.Client{}
  4544. resp, err := client.Do(request)
  4545. if err != nil {
  4546. fmt.Println(err.Error())
  4547. return err.Error(), ""
  4548. }
  4549. respBytes, err := ioutil.ReadAll(resp.Body)
  4550. if err != nil {
  4551. fmt.Println(err.Error())
  4552. return err.Error(), ""
  4553. }
  4554. fmt.Println(string(respBytes))
  4555. str := string(respBytes)
  4556. return str, inputLog
  4557. }
  4558. }
  4559. 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) {
  4560. //生成签名
  4561. nonce := GetRandomString(32)
  4562. timestamp := time.Now().Unix()
  4563. signature := setSignature(timestamp, nonce, "d6Ad0P1B3z6Dsdst0gYAFPlz8YlIvFDx")
  4564. //生成输入报文
  4565. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4566. input := make(map[string]interface{})
  4567. inputData := make(map[string]interface{})
  4568. inputMessage["infno"] = "9001" // 交易编码
  4569. inputData["opter_no"] = admin_user_id // 就诊凭证编号
  4570. inputData["mac"] = "11-11-11-11-11" // 开始时间
  4571. inputData["ip"] = "11.11.11.11"
  4572. inputData["userid"] = "H44010400081"
  4573. month := time.Unix(1557042972, 0).Format("1")
  4574. year := time.Now().Format("2006")
  4575. month = time.Now().Format("01")
  4576. day := time.Now().Format("02")
  4577. hour := time.Now().Format("15")
  4578. min := time.Now().Format("04")
  4579. sec := time.Now().Format("05")
  4580. custom_time := year + month + day + hour + min + sec
  4581. inputData["currenttime"] = custom_time
  4582. var psd string
  4583. psd = custom_time + "Gzyb$867"
  4584. h := md5.New()
  4585. h.Write([]byte(psd))
  4586. inputData["password"] = strings.ToUpper(hex.EncodeToString(h.Sum(nil)))
  4587. input["data"] = inputData
  4588. inputMessage["input"] = input //交易输入
  4589. var inputLog string
  4590. bytesData, err := json.Marshal(inputMessage)
  4591. inputLog = string(bytesData)
  4592. fmt.Println(string(bytesData))
  4593. if err != nil {
  4594. fmt.Println(err.Error())
  4595. return err.Error(), ""
  4596. }
  4597. reader := bytes.NewReader(bytesData)
  4598. gdyb_url := beego.AppConfig.String("gdyb_url")
  4599. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4600. var url string
  4601. if fixmedins_code == "H15049901371" {
  4602. url = gdyb_url
  4603. } else {
  4604. url = gdyb_url + "9001"
  4605. }
  4606. if insuplc_admdvs == "421300" {
  4607. var json2 string
  4608. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  4609. out, err := cmd.Output()
  4610. if err != nil {
  4611. fmt.Println("error:", err.Error())
  4612. }
  4613. fmt.Println(string(out))
  4614. return hex.EncodeToString(out), inputLog
  4615. } else {
  4616. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4617. request, err := http.NewRequest("POST", url, reader)
  4618. if err != nil {
  4619. fmt.Println(err.Error())
  4620. return err.Error(), ""
  4621. }
  4622. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4623. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4624. request.Header.Set("x-tif-signature", signature)
  4625. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4626. request.Header.Set("x-tif-nonce", nonce)
  4627. fmt.Println(string(bytesData))
  4628. fmt.Println(gdyb_url)
  4629. fmt.Println(gdyb_paasid)
  4630. fmt.Println(request.Header)
  4631. client := http.Client{}
  4632. resp, err := client.Do(request)
  4633. if err != nil {
  4634. fmt.Println(err.Error())
  4635. return err.Error(), ""
  4636. }
  4637. respBytes, err := ioutil.ReadAll(resp.Body)
  4638. if err != nil {
  4639. fmt.Println(err.Error())
  4640. return err.Error(), ""
  4641. }
  4642. fmt.Println(string(respBytes))
  4643. str := string(respBytes)
  4644. return str, inputLog
  4645. }
  4646. }
  4647. 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) {
  4648. //生成签名
  4649. nonce := GetRandomString(32)
  4650. timestamp := time.Now().Unix()
  4651. signature := setSignature(timestamp, nonce, secret_key)
  4652. //生成输入报文
  4653. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4654. input := make(map[string]interface{})
  4655. inputData := make(map[string]interface{})
  4656. inputMessage["infno"] = "9001" // 交易编码
  4657. inputData["opter_no"] = admin_user_id // 就诊凭证编号
  4658. inputData["mac"] = GetMac() // 开始时间
  4659. inputData["ip"] = GetLocalIp()
  4660. input["signIn"] = inputData
  4661. inputMessage["input"] = input //交易输入
  4662. var inputLog string
  4663. bytesData, err := json.Marshal(inputMessage)
  4664. inputLog = string(bytesData)
  4665. fmt.Println(string(bytesData))
  4666. if err != nil {
  4667. fmt.Println(err.Error())
  4668. return err.Error(), ""
  4669. }
  4670. reader := bytes.NewReader(bytesData)
  4671. gdyb_url := beego.AppConfig.String("gdyb_url")
  4672. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4673. var url string
  4674. if fixmedins_code == "H15049901371" {
  4675. url = gdyb_url
  4676. } else {
  4677. url = gdyb_url + "9001"
  4678. }
  4679. if insuplc_admdvs == "421300" {
  4680. var json2 string
  4681. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  4682. out, err := cmd.Output()
  4683. if err != nil {
  4684. fmt.Println("error:", err.Error())
  4685. }
  4686. fmt.Println(string(out))
  4687. return hex.EncodeToString(out), inputLog
  4688. } else {
  4689. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4690. request, err := http.NewRequest("POST", url, reader)
  4691. if err != nil {
  4692. fmt.Println(err.Error())
  4693. return err.Error(), ""
  4694. }
  4695. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4696. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4697. request.Header.Set("x-tif-signature", signature)
  4698. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4699. request.Header.Set("x-tif-nonce", nonce)
  4700. fmt.Println(string(bytesData))
  4701. fmt.Println(gdyb_url)
  4702. fmt.Println(gdyb_paasid)
  4703. fmt.Println(request.Header)
  4704. client := http.Client{}
  4705. resp, err := client.Do(request)
  4706. if err != nil {
  4707. fmt.Println(err.Error())
  4708. return err.Error(), ""
  4709. }
  4710. respBytes, err := ioutil.ReadAll(resp.Body)
  4711. if err != nil {
  4712. fmt.Println(err.Error())
  4713. return err.Error(), ""
  4714. }
  4715. fmt.Println(string(respBytes))
  4716. str := string(respBytes)
  4717. return str, inputLog
  4718. }
  4719. }
  4720. //获取本机ip
  4721. func GetLocalIp() string {
  4722. addrs, err := net.InterfaceAddrs()
  4723. if err != nil {
  4724. fmt.Println("get local ip failed")
  4725. }
  4726. for _, address := range addrs {
  4727. if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
  4728. if ipnet.IP.To4() != nil {
  4729. return ipnet.IP.String()
  4730. }
  4731. }
  4732. }
  4733. return ""
  4734. }
  4735. //获取本机Mac
  4736. func GetMac() string {
  4737. interfaces, err := net.Interfaces()
  4738. if err != nil {
  4739. fmt.Println("Get loacl Mac failed")
  4740. }
  4741. for _, inter := range interfaces {
  4742. mac := inter.HardwareAddr
  4743. fmt.Println("+======" + mac.String())
  4744. if mac.String() != "" {
  4745. return mac.String()
  4746. }
  4747. }
  4748. return ""
  4749. }
  4750. // 人员基本信息
  4751. 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) {
  4752. //生成签名
  4753. fmt.Println("DDDDD")
  4754. nonce := GetRandomString(32)
  4755. timestamp := time.Now().Unix()
  4756. signature := setSignature(timestamp, nonce, secret_key)
  4757. //生成输入报文
  4758. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4759. input := make(map[string]interface{})
  4760. inputData := make(map[string]interface{})
  4761. inputMessage["infno"] = "1101" // 交易编码
  4762. if certificates == "3" {
  4763. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  4764. inputData["certno"] = certNo // 证件号码
  4765. inputData["psn_cert_type"] = "99" // 人员证件类型
  4766. } else {
  4767. if certificates == "1" {
  4768. if id_card_type == 1 {
  4769. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  4770. inputData["card_sn"] = "" // 卡识别码
  4771. inputData["certno"] = certNo // 证件号码
  4772. inputData["psn_cert_type"] = "01" // 人员证件类型
  4773. } else if id_card_type == 4 {
  4774. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  4775. inputData["certno"] = certNo // 证件号码
  4776. inputData["psn_cert_type"] = "01" // 人员证件类型
  4777. } else {
  4778. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  4779. inputData["card_sn"] = "" // 卡识别码
  4780. inputData["certno"] = certNo // 证件号码
  4781. inputData["psn_cert_type"] = "01" // 人员证件类型
  4782. }
  4783. } else if certificates == "6" {
  4784. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  4785. inputData["card_sn"] = "" // 卡识别码
  4786. inputData["certno"] = certNo // 证件号码
  4787. inputData["psn_cert_type"] = "17" // 人员证件类型
  4788. }
  4789. }
  4790. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  4791. inputData["begntime"] = "" // 开始时间
  4792. inputData["psn_name"] = "" // 人员姓名
  4793. input["data"] = inputData
  4794. inputMessage["input"] = input //交易输入
  4795. var inputLog string
  4796. bytesData, err := json.Marshal(inputMessage)
  4797. inputLog = string(bytesData)
  4798. fmt.Println(string(bytesData))
  4799. if err != nil {
  4800. fmt.Println(err.Error())
  4801. return err.Error(), ""
  4802. }
  4803. reader := bytes.NewReader(bytesData)
  4804. gdyb_url := beego.AppConfig.String("gdyb_url")
  4805. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4806. //DllDef := syscall.MustLoadDLL("yh_hb_sctrl.dll")
  4807. //Iinit := DllDef.MustFindProc("yh_hb_call")
  4808. //var str3 string
  4809. //ret, _, _ := Iinit.Call(StrPtr("1101"), StrPtr(string(bytesData)), StrPtr(str3))
  4810. //fmt.Println(ret)
  4811. //fmt.Println(str3)
  4812. //
  4813. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4814. var url string
  4815. if fixmedins_code == "H15049901371" {
  4816. url = gdyb_url
  4817. } else {
  4818. url = gdyb_url + "1101"
  4819. }
  4820. if insuplc_admdvs == "421300" {
  4821. var json2 string
  4822. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  4823. out, err := cmd.Output()
  4824. if err != nil {
  4825. fmt.Println("error:", err.Error())
  4826. }
  4827. fmt.Println(string(out))
  4828. return hex.EncodeToString(out), inputLog
  4829. } else {
  4830. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4831. request, err := http.NewRequest("POST", url, reader)
  4832. if err != nil {
  4833. fmt.Println(err.Error())
  4834. return err.Error(), ""
  4835. }
  4836. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4837. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4838. request.Header.Set("x-tif-signature", signature)
  4839. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4840. request.Header.Set("x-tif-nonce", nonce)
  4841. client := http.Client{}
  4842. resp, err := client.Do(request)
  4843. if err != nil {
  4844. fmt.Println(err.Error())
  4845. return err.Error(), ""
  4846. }
  4847. respBytes, err := ioutil.ReadAll(resp.Body)
  4848. if err != nil {
  4849. fmt.Println(err.Error())
  4850. return err.Error(), ""
  4851. }
  4852. fmt.Println(string(respBytes))
  4853. str := string(respBytes)
  4854. return str, inputLog
  4855. }
  4856. }
  4857. //func SetInputMessageFour(nonce string, timestamp int64, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) map[string]interface{} {
  4858. // // 生成签名
  4859. // //tempTime := time.Unix(timestamp, 0)
  4860. // //timeFormat := tempTime.Format("20060102150405")
  4861. // //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  4862. // //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  4863. //
  4864. // msec := time.Now().Format("000")
  4865. // fmt.Println(utils.GetNetTime())
  4866. // // 生成输入报文
  4867. // inputMessage := make(map[string]interface{})
  4868. // inputMessage["msgid"] = fixmedins_code + utils.GetNetTime() + msec + "0" // 发送方报文 ID
  4869. // inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  4870. // inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  4871. // inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  4872. // inputMessage["dev_no"] = "" // 设备编号
  4873. // inputMessage["dev_safe_info"] = "" // 设备安全信息
  4874. // inputMessage["cainfo"] = "" // 数字签名信息
  4875. // inputMessage["signtype"] = "SM3" // 签名类型
  4876. // inputMessage["infver"] = "V1.0" // 接收方系统代码
  4877. // inputMessage["opter_type"] = "1" // 经办人类别
  4878. // inputMessage["opter"] = doctor // 经办人
  4879. // inputMessage["opter_name"] = doctor // 经办人姓名
  4880. // inputMessage["inf_time"] = utils.GetNetTime() // 交易时间
  4881. // inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  4882. // inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  4883. // inputMessage["sign_no"] = "" //交易签到流水号
  4884. // return inputMessage
  4885. //}
  4886. func Gdyb5302(psnNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  4887. // 生成签名
  4888. nonce := GetRandomString(32)
  4889. timestamp := time.Now().Unix()
  4890. signature := setSignature(timestamp, nonce, secret_key)
  4891. // 生成输入报文
  4892. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4893. input := make(map[string]interface{})
  4894. inputData := make(map[string]interface{})
  4895. inputMessage["infno"] = "5302" // 交易编码
  4896. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  4897. inputData["biz_appy_type"] = "03" // 人员编号 (来自1101接口返回)
  4898. input["data"] = inputData
  4899. inputMessage["input"] = input //交易输入
  4900. bytesData, err := json.Marshal(inputMessage)
  4901. fmt.Println(string(bytesData))
  4902. if err != nil {
  4903. fmt.Println(err.Error())
  4904. return err.Error()
  4905. }
  4906. reader := bytes.NewReader(bytesData)
  4907. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  4908. gdyb_url := beego.AppConfig.String("gdyb_url")
  4909. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4910. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4911. url := gdyb_url + "5302"
  4912. request, err := http.NewRequest("POST", url, reader)
  4913. if err != nil {
  4914. fmt.Println(err.Error())
  4915. return err.Error()
  4916. }
  4917. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4918. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4919. request.Header.Set("x-tif-signature", signature)
  4920. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4921. request.Header.Set("x-tif-nonce", nonce)
  4922. client := http.Client{}
  4923. resp, err := client.Do(request)
  4924. if err != nil {
  4925. fmt.Println(err.Error())
  4926. return err.Error()
  4927. }
  4928. respBytes, err := ioutil.ReadAll(resp.Body)
  4929. if err != nil {
  4930. fmt.Println(err.Error())
  4931. return err.Error()
  4932. }
  4933. str := string(respBytes)
  4934. fmt.Println(str)
  4935. return str
  4936. }
  4937. func CreateSignIn(record *models.HisSignIn) (err error) {
  4938. err = writeDb.Save(&record).Error
  4939. return
  4940. }
  4941. func GetSignInInfo(code string) string {
  4942. var sign models.HisSignIn
  4943. err = readDb.Model(&models.HisSignIn{}).Where("fixmedins_code = ? AND status = 1", code).Last(&sign).Error
  4944. return sign.SignNo
  4945. }
  4946. func Gdyb3501(struct3501 models.Struct3501, secret_key string) string {
  4947. // 生成签名
  4948. nonce := GetRandomString(32)
  4949. timestamp := time.Now().Unix()
  4950. signature := setSignature(timestamp, nonce, secret_key)
  4951. // 生成输入报文
  4952. inputMessage := SetGdInputMessage(timestamp, struct3501.OrgName, struct3501.Opter, struct3501.FixmedinsHilistId, struct3501.InsuplcAdmdvs, struct3501.MdtrtareaAdmvs, struct3501.Cainfo)
  4953. input := make(map[string]interface{})
  4954. inputData := make(map[string]interface{})
  4955. inputMessage["infno"] = "3501" // 交易编码
  4956. inputData["med_list_codg"] = struct3501.MedListCodg // 定点医药机构目录编号
  4957. inputData["fixmedins_hilist_id"] = struct3501.FixmedinsHilistId // 定点医药机构目录编号
  4958. inputData["fixmedins_hilist_name"] = struct3501.OrgName // 定点医药机构目录名称
  4959. inputData["rx_flag"] = struct3501.RxFlag //
  4960. inputData["invdate"] = struct3501.Invdate // 人员编号 (来自1101接口返回)
  4961. inputData["inv_cnt"] = struct3501.InvCnt // 人员编号 (来自1101接口返回)
  4962. inputData["manu_lotnum"] = struct3501.ManuLotnum // 人员编号 (来自1101接口返回)
  4963. inputData["fixmedins_bchno"] = struct3501.FixmedinsBchno // 人员编号 (来自1101接口返回)
  4964. inputData["manu_date"] = struct3501.ManuDate // 人员编号 (来自1101接口返回)
  4965. inputData["expy_end"] = struct3501.ExpyEnd // 人员编号 (来自1101接口返回)
  4966. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  4967. input["invinfo"] = inputData
  4968. inputMessage["input"] = input //交易输入
  4969. bytesData, err := json.Marshal(inputMessage)
  4970. fmt.Println(string(bytesData))
  4971. if err != nil {
  4972. fmt.Println(err.Error())
  4973. return err.Error()
  4974. }
  4975. reader := bytes.NewReader(bytesData)
  4976. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  4977. gdyb_url := beego.AppConfig.String("gdyb_url")
  4978. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4979. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4980. url := gdyb_url + "3501"
  4981. request, err := http.NewRequest("POST", url, reader)
  4982. if err != nil {
  4983. fmt.Println(err.Error())
  4984. return err.Error()
  4985. }
  4986. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4987. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4988. request.Header.Set("x-tif-signature", signature)
  4989. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4990. request.Header.Set("x-tif-nonce", nonce)
  4991. client := http.Client{}
  4992. resp, err := client.Do(request)
  4993. if err != nil {
  4994. fmt.Println(err.Error())
  4995. return err.Error()
  4996. }
  4997. respBytes, err := ioutil.ReadAll(resp.Body)
  4998. if err != nil {
  4999. fmt.Println(err.Error())
  5000. return err.Error()
  5001. }
  5002. str := string(respBytes)
  5003. fmt.Println(str)
  5004. return str
  5005. }
  5006. func Gdyb3502(struct3502 models.Struct3502, secret_key string) string {
  5007. // 生成签名
  5008. nonce := GetRandomString(32)
  5009. timestamp := time.Now().Unix()
  5010. signature := setSignature(timestamp, nonce, secret_key)
  5011. // 生成输入报文
  5012. inputMessage := SetGdInputMessage(timestamp, struct3502.OrgName, struct3502.Opter, struct3502.FixmedinsCode, struct3502.InsuplcAdmdvs, struct3502.MdtrtareaAdmvs, struct3502.Cainfo)
  5013. input := make(map[string]interface{})
  5014. inputData := make(map[string]interface{})
  5015. inputMessage["infno"] = "3502" // 交易编码
  5016. inputData["med_list_codg"] = struct3502.MedListCodg // 定点医药机构目录编号
  5017. inputData["inv_chg_type"] = struct3502.InvChgType // 定点医药机构目录编号
  5018. inputData["fixmedins_hilist_id"] = struct3502.FixmedinsCode // 定点医药机构目录编号
  5019. inputData["fixmedins_hilist_name"] = struct3502.OrgName // 定点医药机构目录名称
  5020. inputData["fixmedins_bchno"] = struct3502.FixmedinsBchno // 人员编号 (来自1101接口返回)
  5021. inputData["pric"] = struct3502.Pric // 人员编号 (来自1101接口返回)
  5022. inputData["cnt"] = struct3502.Cnt // 人员编号 (来自1101接口返回)
  5023. inputData["rx_flag"] = struct3502.RxFlag //
  5024. inputData["inv_chg_time"] = struct3502.InvChgTime // 人员编号 (来自1101接口返回)
  5025. inputData["inv_chg_opter_name"] = "" // 人员编号 (来自1101接口返回)
  5026. inputData["memo"] = struct3502.Memo // 人员编号 (来自1101接口返回)
  5027. inputData["trdn_flag"] = "" // 人员编号 (来自1101接口返回)
  5028. input["invinfo"] = inputData
  5029. inputMessage["input"] = input //交易输入
  5030. bytesData, err := json.Marshal(inputMessage)
  5031. fmt.Println(string(bytesData))
  5032. if err != nil {
  5033. fmt.Println(err.Error())
  5034. return err.Error()
  5035. }
  5036. reader := bytes.NewReader(bytesData)
  5037. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  5038. gdyb_url := beego.AppConfig.String("gdyb_url")
  5039. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5040. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  5041. url := gdyb_url + "3502"
  5042. request, err := http.NewRequest("POST", url, reader)
  5043. if err != nil {
  5044. fmt.Println(err.Error())
  5045. return err.Error()
  5046. }
  5047. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5048. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5049. request.Header.Set("x-tif-signature", signature)
  5050. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5051. request.Header.Set("x-tif-nonce", nonce)
  5052. client := http.Client{}
  5053. resp, err := client.Do(request)
  5054. if err != nil {
  5055. fmt.Println(err.Error())
  5056. return err.Error()
  5057. }
  5058. respBytes, err := ioutil.ReadAll(resp.Body)
  5059. if err != nil {
  5060. fmt.Println(err.Error())
  5061. return err.Error()
  5062. }
  5063. str := string(respBytes)
  5064. fmt.Println(str)
  5065. return str
  5066. }
  5067. func Gdyb3503(struct3503 models.Struct3503, secret_key string) string {
  5068. // 生成签名
  5069. nonce := GetRandomString(32)
  5070. timestamp := time.Now().Unix()
  5071. signature := setSignature(timestamp, nonce, secret_key)
  5072. // 生成输入报文
  5073. inputMessage := SetGdInputMessage(timestamp, struct3503.OrgName, struct3503.Opter, struct3503.FixmedinsHilistId, struct3503.InsuplcAdmdvs, struct3503.MdtrtareaAdmvs, struct3503.Cainfo)
  5074. input := make(map[string]interface{})
  5075. inputMessage["infno"] = "3503"
  5076. item := struct3503
  5077. feedetailInfo := make(map[string]interface{})
  5078. feedetailInfo["med_list_codg"] = item.MedListCodg
  5079. feedetailInfo["fixmedins_hilist_id"] = item.FixmedinsHilistId
  5080. feedetailInfo["fixmedins_hilist_name"] = item.FixmedinsHilistName
  5081. feedetailInfo["dynt_no"] = ""
  5082. feedetailInfo["fixmedins_bchno"] = item.FixmedinsBchno // 人员编号 (来自1101接口返回)
  5083. feedetailInfo["spler_name"] = item.SplerName // 人员编号 (来自1101接口返回)
  5084. feedetailInfo["spler_pmtno"] = "" // 人员编号 (来自1101接口返回)
  5085. feedetailInfo["manu_lotnum"] = item.ManuLotnum // 人员编号 (来自1101接口返回)
  5086. feedetailInfo["prodentp_name"] = item.ProdentpName // 人员编号 (来自1101接口返回)
  5087. feedetailInfo["aprvno"] = item.Aprvno // 人员编号 (来自1101接口返回)
  5088. feedetailInfo["manu_date"] = item.ManuDate // 人员编号 (来自1101接口返回)
  5089. feedetailInfo["expy_end"] = item.ExpyEnd // 人员编号 (来自1101接口返回)
  5090. feedetailInfo["finl_trns_pric"] = item.FinlTrnsPric // 人员编号 (来自1101接口返回)
  5091. feedetailInfo["purc_retn_cnt"] = item.PurcRetnCnt // 人员编号 (来自1101接口返回)
  5092. feedetailInfo["purc_invo_codg"] = item.PurcInvoCodg // 人员编号 (来自1101接口返回)
  5093. feedetailInfo["purc_invo_no"] = item.PurcInvoNo // 人员编号 (来自1101接口返回)
  5094. feedetailInfo["rx_flag"] = item.RxFlag // 人员编号 (来自1101接口返回)
  5095. feedetailInfo["purc_retn_stoin_time"] = item.PurcRetnStoinTime // 人员编号 (来自1101接口返回)
  5096. feedetailInfo["purc_retn_opter_name"] = item.PurcRetnOpterName // 人员编号 (来自1101接口返回)
  5097. feedetailInfo["prod_geay_flag"] = "" // 人员编号 (来自1101接口返回)
  5098. feedetailInfo["memo"] = "" // 人员编号 (来自1101接口返回)
  5099. input["purcinfo"] = feedetailInfo
  5100. inputMessage["input"] = input //交易输入
  5101. bytesData, err := json.Marshal(inputMessage)
  5102. fmt.Println(string(bytesData))
  5103. if err != nil {
  5104. fmt.Println(err.Error())
  5105. return err.Error()
  5106. }
  5107. reader := bytes.NewReader(bytesData)
  5108. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  5109. gdyb_url := beego.AppConfig.String("gdyb_url")
  5110. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5111. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  5112. url := gdyb_url + "3503"
  5113. request, err := http.NewRequest("POST", url, reader)
  5114. if err != nil {
  5115. fmt.Println(err.Error())
  5116. return err.Error()
  5117. }
  5118. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5119. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5120. request.Header.Set("x-tif-signature", signature)
  5121. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5122. request.Header.Set("x-tif-nonce", nonce)
  5123. client := http.Client{}
  5124. resp, err := client.Do(request)
  5125. if err != nil {
  5126. fmt.Println(err.Error())
  5127. return err.Error()
  5128. }
  5129. respBytes, err := ioutil.ReadAll(resp.Body)
  5130. if err != nil {
  5131. fmt.Println(err.Error())
  5132. return err.Error()
  5133. }
  5134. str := string(respBytes)
  5135. fmt.Println(str)
  5136. return str
  5137. }
  5138. func Gdyb3504(struct3504 models.Struct3504, secret_key string) string {
  5139. // 生成签名
  5140. nonce := GetRandomString(32)
  5141. timestamp := time.Now().Unix()
  5142. signature := setSignature(timestamp, nonce, secret_key)
  5143. // 生成输入报文
  5144. inputMessage := SetGdInputMessage(timestamp, struct3504.OrgName, struct3504.Opter, struct3504.FixmedinsCode, struct3504.InsuplcAdmdvs, struct3504.MdtrtareaAdmvs, struct3504.Cainfo)
  5145. input := make(map[string]interface{})
  5146. inputData := make(map[string]interface{})
  5147. inputMessage["infno"] = "3504" // 交易编码
  5148. inputData["med_list_codg"] = struct3504.MedListCodg // 定点医药机构目录编号
  5149. inputData["fixmedins_hilist_id"] = struct3504.FixmedinsHilistId // 定点医药机构目录编号
  5150. inputData["fixmedins_hilist_name"] = struct3504.FixmedinsHilistName // 定点医药机构目录名称
  5151. inputData["fixmedins_bchno"] = struct3504.FixmedinsBchno // 人员编号 (来自1101接口返回)
  5152. inputData["spler_name"] = struct3504.SplerName // 人员编号 (来自1101接口返回)
  5153. inputData["spler_pmtno"] = "" // 人员编号 (来自1101接口返回)
  5154. inputData["manu_date"] = struct3504.ManuDate // 人员编号 (来自1101接口返回)
  5155. inputData["expy_end"] = struct3504.ExpyEnd // 人员编号 (来自1101接口返回)
  5156. inputData["finl_trns_pric"] = struct3504.FinlTrnsPric // 人员编号 (来自1101接口返回)
  5157. inputData["purc_retn_cnt"] = struct3504.PurcRetnCnt // 人员编号 (来自1101接口返回)
  5158. inputData["purc_invo_codg"] = struct3504.PurcInvoCodg // 人员编号 (来自1101接口返回)
  5159. inputData["purc_invo_no"] = struct3504.PurcInvoNo // 人员编号 (来自1101接口返回)
  5160. inputData["rx_flag"] = struct3504.RxFlag
  5161. inputData["purc_retn_stoin_time"] = struct3504.PurcRetnStoin
  5162. inputData["purc_retn_opter_name"] = struct3504.PurcRetnStoin
  5163. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  5164. inputData["medins_prod_purc_no"] = "" // 人员编号 (来自1101接口返回)
  5165. input["purcinfo"] = inputData
  5166. inputMessage["input"] = input //交易输入
  5167. bytesData, err := json.Marshal(inputMessage)
  5168. fmt.Println(string(bytesData))
  5169. if err != nil {
  5170. fmt.Println(err.Error())
  5171. return err.Error()
  5172. }
  5173. reader := bytes.NewReader(bytesData)
  5174. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  5175. gdyb_url := beego.AppConfig.String("gdyb_url")
  5176. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5177. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  5178. url := gdyb_url + "3504"
  5179. request, err := http.NewRequest("POST", url, reader)
  5180. if err != nil {
  5181. fmt.Println(err.Error())
  5182. return err.Error()
  5183. }
  5184. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5185. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5186. request.Header.Set("x-tif-signature", signature)
  5187. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5188. request.Header.Set("x-tif-nonce", nonce)
  5189. client := http.Client{}
  5190. resp, err := client.Do(request)
  5191. if err != nil {
  5192. fmt.Println(err.Error())
  5193. return err.Error()
  5194. }
  5195. respBytes, err := ioutil.ReadAll(resp.Body)
  5196. if err != nil {
  5197. fmt.Println(err.Error())
  5198. return err.Error()
  5199. }
  5200. str := string(respBytes)
  5201. fmt.Println(str)
  5202. return str
  5203. }
  5204. func Gdyb3505(struct3505 models.Struct3505, secret_key string) string {
  5205. // 生成签名
  5206. nonce := GetRandomString(32)
  5207. timestamp := time.Now().Unix()
  5208. signature := setSignature(timestamp, nonce, secret_key)
  5209. // 生成输入报文
  5210. inputMessage := SetGdInputMessage(timestamp, struct3505.OrgName, struct3505.Opter, struct3505.FixmedinsHilistId, struct3505.InsuplcAdmdvs, struct3505.MdtrtareaAdmvs, struct3505.Cainfo)
  5211. input := make(map[string]interface{})
  5212. inputData := make(map[string]interface{})
  5213. inputMessage["infno"] = "3505" // 交易编码
  5214. inputData["med_list_codg"] = struct3505.MedListCodg // 定点医药机构目录编号
  5215. inputData["fixmedins_hilist_id"] = struct3505.FixmedinsHilistId // 定点医药机构目录编号
  5216. inputData["fixmedins_hilist_name"] = struct3505.OrgName // 定点医药机构目录名称
  5217. inputData["fixmedins_bchno"] = struct3505.FixmedinsBchno // 人员编号 (来自1101接口返回)
  5218. inputData["prsc_dr_cert_type"] = struct3505.PrscDrCertType // 人员编号 (来自1101接口返回)
  5219. inputData["prsc_dr_certno"] = struct3505.PrscDrCertno // 人员编号 (来自1101接口返回)
  5220. inputData["prsc_dr_name"] = struct3505.PrscDrName // 人员编号 (来自1101接口返回)
  5221. inputData["phar_cert_type"] = struct3505.PharCertType // 人员编号 (来自1101接口返回)
  5222. inputData["phar_certno"] = struct3505.PharCertno // 人员编号 (来自1101接口返回)
  5223. inputData["phar_name"] = struct3505.PharName // 人员编号 (来自1101接口返回)
  5224. inputData["phar_prac_cert_no"] = struct3505.PharPracCertNo // 人员编号 (来自1101接口返回)
  5225. inputData["hi_feesetl_type"] = struct3505.HiFeesetlType // 人员编号 (来自1101接口返回)
  5226. inputData["setl_id"] = struct3505.SetlId // 人员编号 (来自1101接口返回)
  5227. inputData["mdtrt_sn"] = struct3505.MdtrtSn // 人员编号 (来自1101接口返回)
  5228. inputData["psn_no"] = struct3505.PsnNo // 人员编号 (来自1101接口返回)
  5229. inputData["psn_cert_type"] = struct3505.PsnCertType // 人员编号 (来自1101接口返回)
  5230. inputData["certno"] = struct3505.CertNo // 人员编号 (来自1101接口返回)
  5231. inputData["psn_name"] = struct3505.PsnName // 人员编号 (来自1101接口返回)
  5232. inputData["manu_lotnum"] = struct3505.ManuLotnum // 人员编号 (来自1101接口返回)
  5233. inputData["manu_date"] = struct3505.ManuDate // 人员编号 (来自1101接口返回)
  5234. inputData["expy_end"] = struct3505.ExpyEnd // 人员编号 (来自1101接口返回)
  5235. inputData["rx_flag"] = struct3505.RxFlag // 人员编号 (来自1101接口返回)
  5236. inputData["trdn_flag"] = struct3505.TrdnFlag // 人员编号 (来自1101接口返回)
  5237. inputData["finl_trns_pric"] = struct3505.FinlTrnsPric // 人员编号 (来自1101接口返回)
  5238. inputData["rxno"] = struct3505.Rxno // 人员编号 (来自1101接口返回)
  5239. inputData["rx_circ_flag"] = struct3505.RxCircFlag // 人员编号 (来自1101接口返回)
  5240. inputData["rtal_docno"] = struct3505.RtalDocno // 人员编号 (来自1101接口返回)
  5241. inputData["stoout_no"] = struct3505.StooutNo // 人员编号 (来自1101接口返回)
  5242. inputData["bchno"] = struct3505.Bchno // 人员编号 (来自1101接口返回)
  5243. inputData["drug_trac_codg"] = struct3505.DrugTracCodg // 人员编号 (来自1101接口返回)
  5244. inputData["drug_prod_barc"] = struct3505.DrugProdBarc // 人员编号 (来自1101接口返回)
  5245. inputData["shelf_posi"] = struct3505.ShelfPosi // 人员编号 (来自1101接口返回)
  5246. inputData["sel_retn_cnt"] = struct3505.SelRetnCnt // 人员编号 (来自1101接口返回)
  5247. inputData["sel_retn_time"] = struct3505.SelRetnTime // 人员编号 (来自1101接口返回)
  5248. inputData["sel_retn_opter_name"] = struct3505.SelRetnOpterName // 人员编号 (来自1101接口返回)
  5249. inputData["memo"] = struct3505.Memo // 人员编号 (来自1101接口返回)
  5250. input["selinfo"] = inputData
  5251. inputMessage["input"] = input //交易输入
  5252. bytesData, err := json.Marshal(inputMessage)
  5253. fmt.Println(string(bytesData))
  5254. if err != nil {
  5255. fmt.Println(err.Error())
  5256. return err.Error()
  5257. }
  5258. reader := bytes.NewReader(bytesData)
  5259. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  5260. gdyb_url := beego.AppConfig.String("gdyb_url")
  5261. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5262. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  5263. url := gdyb_url + "3505"
  5264. request, err := http.NewRequest("POST", url, reader)
  5265. if err != nil {
  5266. fmt.Println(err.Error())
  5267. return err.Error()
  5268. }
  5269. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5270. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5271. request.Header.Set("x-tif-signature", signature)
  5272. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5273. request.Header.Set("x-tif-nonce", nonce)
  5274. client := http.Client{}
  5275. resp, err := client.Do(request)
  5276. if err != nil {
  5277. fmt.Println(err.Error())
  5278. return err.Error()
  5279. }
  5280. respBytes, err := ioutil.ReadAll(resp.Body)
  5281. if err != nil {
  5282. fmt.Println(err.Error())
  5283. return err.Error()
  5284. }
  5285. str := string(respBytes)
  5286. fmt.Println(str)
  5287. return str
  5288. }
  5289. func Gdyb3506(struct3506 models.Struct3506, secret_key string) string {
  5290. // 生成签名
  5291. nonce := GetRandomString(32)
  5292. timestamp := time.Now().Unix()
  5293. signature := setSignature(timestamp, nonce, secret_key)
  5294. // 生成输入报文
  5295. inputMessage := SetGdInputMessage(timestamp, struct3506.OrgName, struct3506.Opter, struct3506.FixmedinsCode, struct3506.InsuplcAdmdvs, struct3506.MdtrtareaAdmvs, struct3506.Cainfo)
  5296. input := make(map[string]interface{})
  5297. inputData := make(map[string]interface{})
  5298. inputMessage["infno"] = "3506" // 交易编码
  5299. inputData["med_list_codg"] = struct3506.MedListCodg // 定点医药机构目录编号
  5300. inputData["fixmedins_hilist_id"] = struct3506.FixmedinsHilistId // 定点医药机构目录编号
  5301. inputData["fixmedins_hilist_name"] = struct3506.OrgName // 定点医药机构目录名称
  5302. inputData["fixmedins_bchno"] = struct3506.FixmedinsBchno // 人员编号 (来自1101接口返回)
  5303. inputData["setl_id"] = struct3506.SetlId // 人员编号 (来自1101接口返回)
  5304. inputData["psn_no"] = struct3506.PsnNo // 人员编号 (来自1101接口返回)
  5305. inputData["psn_cert_type"] = struct3506.PsnCertType // 人员编号 (来自1101接口返回)
  5306. inputData["certno"] = struct3506.Certno // 人员编号 (来自1101接口返回)
  5307. inputData["psn_name"] = struct3506.PsnName // 人员编号 (来自1101接口返回)
  5308. inputData["manu_lotnum"] = struct3506.ManuLotnum // 人员编号 (来自1101接口返回)
  5309. inputData["manu_date"] = struct3506.ManuDate // 人员编号 (来自1101接口返回)
  5310. inputData["expy_end"] = struct3506.ExpyEnd // 人员编号 (来自1101接口返回)
  5311. inputData["rx_flag"] = struct3506.RxFlag // 人员编号 (来自1101接口返回)
  5312. inputData["trdn_flag"] = struct3506.TrdnFlag // 人员编号 (来自1101接口返回)
  5313. inputData["finl_trns_pric"] = struct3506.FinlTrnsPric // 人员编号 (来自1101接口返回)
  5314. inputData["sel_retn_cnt"] = struct3506.SelRetnCnt // 人员编号 (来自1101接口返回)
  5315. inputData["sel_retn_time"] = struct3506.SelRetnTime // 人员编号 (来自1101接口返回)
  5316. inputData["sel_retn_opter_name"] = struct3506.SelRetnOpterName // 人员编号 (来自1101接口返回)
  5317. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  5318. inputData["medins_prod_sel_no"] = "" // 人员编号 (来自1101接口返回)
  5319. input["selinfo"] = inputData
  5320. inputMessage["input"] = input //交易输入
  5321. bytesData, err := json.Marshal(inputMessage)
  5322. fmt.Println(string(bytesData))
  5323. if err != nil {
  5324. fmt.Println(err.Error())
  5325. return err.Error()
  5326. }
  5327. reader := bytes.NewReader(bytesData)
  5328. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  5329. gdyb_url := beego.AppConfig.String("gdyb_url")
  5330. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5331. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  5332. url := gdyb_url + "3506"
  5333. request, err := http.NewRequest("POST", url, reader)
  5334. if err != nil {
  5335. fmt.Println(err.Error())
  5336. return err.Error()
  5337. }
  5338. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5339. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5340. request.Header.Set("x-tif-signature", signature)
  5341. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5342. request.Header.Set("x-tif-nonce", nonce)
  5343. client := http.Client{}
  5344. resp, err := client.Do(request)
  5345. if err != nil {
  5346. fmt.Println(err.Error())
  5347. return err.Error()
  5348. }
  5349. respBytes, err := ioutil.ReadAll(resp.Body)
  5350. if err != nil {
  5351. fmt.Println(err.Error())
  5352. return err.Error()
  5353. }
  5354. str := string(respBytes)
  5355. fmt.Println(str)
  5356. return str
  5357. }
  5358. func Gdyb3507(struct3507 models.Struct3507, secret_key string) string {
  5359. // 生成签名
  5360. nonce := GetRandomString(32)
  5361. timestamp := time.Now().Unix()
  5362. signature := setSignature(timestamp, nonce, secret_key)
  5363. // 生成输入报文
  5364. inputMessage := SetGdInputMessage(timestamp, struct3507.OrgName, struct3507.Opter, struct3507.FixmedinsCode, struct3507.InsuplcAdmdvs, struct3507.MdtrtareaAdmvs, struct3507.Cainfo)
  5365. input := make(map[string]interface{})
  5366. inputData := make(map[string]interface{})
  5367. inputMessage["infno"] = "3507" // 交易编码
  5368. inputData["fixmedins_bchno"] = struct3507.FixmedinsCode // 人员编号 (来自1101接口返回)
  5369. inputData["inv_data_type"] = struct3507.InvDataType // 人员编号 (来自1101接口返回)
  5370. input["data"] = inputData
  5371. inputMessage["input"] = input //交易输入
  5372. bytesData, err := json.Marshal(inputMessage)
  5373. fmt.Println(string(bytesData))
  5374. if err != nil {
  5375. fmt.Println(err.Error())
  5376. return err.Error()
  5377. }
  5378. reader := bytes.NewReader(bytesData)
  5379. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  5380. gdyb_url := beego.AppConfig.String("gdyb_url")
  5381. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5382. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  5383. url := gdyb_url + "3507"
  5384. request, err := http.NewRequest("POST", url, reader)
  5385. if err != nil {
  5386. fmt.Println(err.Error())
  5387. return err.Error()
  5388. }
  5389. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5390. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5391. request.Header.Set("x-tif-signature", signature)
  5392. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5393. request.Header.Set("x-tif-nonce", nonce)
  5394. client := http.Client{}
  5395. resp, err := client.Do(request)
  5396. if err != nil {
  5397. fmt.Println(err.Error())
  5398. return err.Error()
  5399. }
  5400. respBytes, err := ioutil.ReadAll(resp.Body)
  5401. if err != nil {
  5402. fmt.Println(err.Error())
  5403. return err.Error()
  5404. }
  5405. str := string(respBytes)
  5406. fmt.Println(str)
  5407. return str
  5408. }
  5409. // 生成基础报文
  5410. func SetGdInputMessage(timestamp int64, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, cainfo string) map[string]interface{} {
  5411. // 生成签名
  5412. tempTime := time.Unix(timestamp, 0)
  5413. //timeFormat := tempTime.Format("20060102150405")
  5414. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  5415. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  5416. month := time.Unix(1557042972, 0).Format("1")
  5417. year := time.Now().Format("2006")
  5418. month = time.Now().Format("01")
  5419. day := time.Now().Format("02")
  5420. hour := time.Now().Format("15")
  5421. min := time.Now().Format("04")
  5422. sec := time.Now().Format("05")
  5423. msec := time.Now().Format("000")
  5424. // 生成输入报文
  5425. inputMessage := make(map[string]interface{})
  5426. inputMessage["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  5427. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  5428. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  5429. inputMessage["recer_sys_code"] = "MBS_LOCAL" // 接收方系统代码
  5430. inputMessage["dev_no"] = "1" // 设备编号
  5431. inputMessage["dev_safe_info"] = "1" // 设备安全信息
  5432. inputMessage["cainfo"] = cainfo // 数字签名信息
  5433. inputMessage["signtype"] = "SM3" // 签名类型
  5434. inputMessage["infver"] = "1.0.0" // 接收方系统代码
  5435. inputMessage["opter_type"] = "1" // 经办人类别
  5436. inputMessage["opter"] = doctor // 经办人
  5437. inputMessage["opter_name"] = doctor // 经办人姓名
  5438. inputMessage["inf_time"] = timeFormatOne // 交易时间
  5439. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  5440. inputMessage["fixmedins_name"] = org_name
  5441. inputMessage["fixmedins_soft_fcty"] = "深圳市领透科技有限公司" //定点医药机构名称
  5442. //定点医药机构名称
  5443. inputMessage["sign_no"] = "" //交易签到流水号
  5444. return inputMessage
  5445. }