gdyb_service.go 375KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535
  1. package service
  2. import (
  3. "bytes"
  4. //"crypto/md5"
  5. "crypto/sha256"
  6. "encoding/hex"
  7. "encoding/json"
  8. "fmt"
  9. "gdyb/models"
  10. "strings"
  11. //"gdyb/utils"
  12. "github.com/astaxie/beego"
  13. "github.com/axgle/mahonia"
  14. "io"
  15. "io/ioutil"
  16. "math/rand"
  17. "mime/multipart"
  18. "net"
  19. "net/http"
  20. "os"
  21. "os/exec"
  22. "path/filepath"
  23. "strconv"
  24. "syscall"
  25. "time"
  26. "unsafe"
  27. )
  28. const (
  29. SceretKey = "RhaDw4H0RUbWYyTxmRKM1eSeN0qyGLds" // secretKey 私钥
  30. )
  31. // 机构信息
  32. func Gdyb1201(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, card_sn string) string {
  33. // 生成签名
  34. nonce := GetRandomString(32)
  35. timestamp := time.Now().Unix()
  36. signature := setSignature(timestamp, nonce, secret_key)
  37. // 生成输入报文
  38. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  39. input := make(map[string]interface{})
  40. inputData := make(map[string]interface{})
  41. inputMessage["infno"] = "1201" // 交易编码
  42. inputData["fixmedins_type"] = "1"
  43. inputData["fixmedins_name"] = org_name
  44. inputData["fixmedins_code"] = fixmedins_code
  45. input["medinsinfo"] = inputData
  46. inputMessage["input"] = input //交易输入
  47. bytesData, err := json.Marshal(inputMessage)
  48. fmt.Println(string(bytesData))
  49. if err != nil {
  50. fmt.Println(err.Error())
  51. return err.Error()
  52. }
  53. reader := bytes.NewReader(bytesData)
  54. gdyb_url := beego.AppConfig.String("gdyb_url")
  55. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  56. url := gdyb_url + "1201"
  57. request, err := http.NewRequest("POST", url, reader)
  58. if err != nil {
  59. fmt.Println(err.Error())
  60. return err.Error()
  61. }
  62. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  63. request.Header.Set("x-tif-paasid", gdyb_paasid)
  64. request.Header.Set("x-tif-signature", signature)
  65. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  66. request.Header.Set("x-tif-nonce", nonce)
  67. client := http.Client{}
  68. resp, err := client.Do(request)
  69. if err != nil {
  70. fmt.Println(err.Error())
  71. return err.Error()
  72. }
  73. respBytes, err := ioutil.ReadAll(resp.Body)
  74. if err != nil {
  75. fmt.Println(err.Error())
  76. return err.Error()
  77. }
  78. fmt.Println(string(respBytes))
  79. str2 := string(respBytes)
  80. return str2
  81. }
  82. // 人员基本信息
  83. func Gdyb1101(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, card_sn string, certificates string, psn_name string) (string, string) {
  84. //生成签名
  85. nonce := GetRandomString(32)
  86. timestamp := time.Now().Unix()
  87. signature := setSignature(timestamp, nonce, secret_key)
  88. //生成输入报文
  89. inputMessage := SetInputMessagenosign(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  90. input := make(map[string]interface{})
  91. inputData := make(map[string]interface{})
  92. inputMessage["infno"] = "1101" // 交易编码
  93. if certificates == "3" {
  94. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  95. inputData["certno"] = certNo // 证件号码
  96. inputData["psn_cert_type"] = "06" // 人员证件类型
  97. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  98. } else {
  99. if id_card_type == 1 {
  100. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  101. inputData["card_sn"] = card_sn // 卡识别码
  102. inputData["certno"] = certNo // 证件号码
  103. inputData["psn_cert_type"] = "" // 人员证件类型
  104. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  105. } else {
  106. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  107. inputData["card_sn"] = "" // 卡识别码
  108. inputData["certno"] = certNo // 证件号码
  109. inputData["psn_cert_type"] = "" // 人员证件类型
  110. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  111. }
  112. }
  113. inputData["begntime"] = "" // 开始时间
  114. inputData["psn_name"] = "" // 人员姓名
  115. input["data"] = inputData
  116. inputMessage["input"] = input //交易输入
  117. var inputLog string
  118. bytesData, err := json.Marshal(inputMessage)
  119. inputLog = string(bytesData)
  120. fmt.Println(string(bytesData))
  121. if err != nil {
  122. fmt.Println(err.Error())
  123. return err.Error(), ""
  124. }
  125. reader := bytes.NewReader(bytesData)
  126. gdyb_url := beego.AppConfig.String("gdyb_url")
  127. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  128. var url string
  129. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  130. url = gdyb_url
  131. } else {
  132. url = gdyb_url + "1101"
  133. }
  134. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  135. request, err := http.NewRequest("POST", url, reader)
  136. if err != nil {
  137. fmt.Println(err.Error())
  138. return err.Error(), ""
  139. }
  140. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  141. request.Header.Set("x-tif-paasid", gdyb_paasid)
  142. request.Header.Set("x-tif-signature", signature)
  143. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  144. request.Header.Set("x-tif-nonce", nonce)
  145. client := http.Client{}
  146. resp, err := client.Do(request)
  147. if err != nil {
  148. fmt.Println(err.Error())
  149. return err.Error(), ""
  150. }
  151. respBytes, err := ioutil.ReadAll(resp.Body)
  152. if err != nil {
  153. fmt.Println(err.Error())
  154. return err.Error(), ""
  155. }
  156. fmt.Println(string(respBytes))
  157. str := string(respBytes)
  158. return str, inputLog
  159. }
  160. func Gdyb1101A(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, name string) string {
  161. //生成签名
  162. nonce := GetRandomString(32)
  163. timestamp := time.Now().Unix()
  164. signature := setSignature(timestamp, nonce, secret_key)
  165. //生成输入报文
  166. inputMessage := SetInputMessagenosign(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  167. input := make(map[string]interface{})
  168. inputData := make(map[string]interface{})
  169. inputMessage["infno"] = "1101" // 交易编码
  170. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  171. inputData["card_sn"] = "" // 卡识别码
  172. inputData["certno"] = certNo // 证件号码
  173. inputData["psn_cert_type"] = "01" // 人员证件类型
  174. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  175. inputData["begntime"] = "" // 开始时间
  176. inputData["psn_name"] = name // 人员姓名
  177. input["data"] = inputData
  178. inputMessage["input"] = input //交易输入
  179. bytesData, err := json.Marshal(inputMessage)
  180. fmt.Println(string(bytesData))
  181. if err != nil {
  182. fmt.Println(err.Error())
  183. return err.Error()
  184. }
  185. reader := bytes.NewReader(bytesData)
  186. gdyb_url := beego.AppConfig.String("gdyb_url")
  187. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  188. var url string
  189. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  190. url = gdyb_url
  191. } else {
  192. url = gdyb_url + "1101"
  193. }
  194. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  195. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  196. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  197. if insuplc_admdvs == "421300" {
  198. var json2 string
  199. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101A", string(bytesData), json2)
  200. out, err := cmd.Output()
  201. if err != nil {
  202. fmt.Println("error:", err.Error())
  203. }
  204. fmt.Println(string(out))
  205. return hex.EncodeToString(out)
  206. } else {
  207. request, err := http.NewRequest("POST", url, reader)
  208. if err != nil {
  209. fmt.Println(err.Error())
  210. return err.Error()
  211. }
  212. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  213. request.Header.Set("x-tif-paasid", gdyb_paasid)
  214. request.Header.Set("x-tif-signature", signature)
  215. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  216. request.Header.Set("x-tif-nonce", nonce)
  217. client := http.Client{}
  218. resp, err := client.Do(request)
  219. if err != nil {
  220. fmt.Println(err.Error())
  221. return err.Error()
  222. }
  223. respBytes, err := ioutil.ReadAll(resp.Body)
  224. if err != nil {
  225. fmt.Println(err.Error())
  226. return err.Error()
  227. }
  228. fmt.Println(string(respBytes))
  229. str := string(respBytes)
  230. return str
  231. }
  232. }
  233. // 门诊挂号
  234. func Gdyb2201(psnNo string, insutype string, certNo string, org_name string, opera string, ipt_otp_no string, dept string, fixmedins_code string, dept_code string, doctor_id string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, doctor_name string) (string, string) {
  235. fmt.Println(opera)
  236. // 生成签名
  237. nonce := GetRandomString(32)
  238. timestamp := time.Now().Unix()
  239. signature := setSignature(timestamp, nonce, secret_key)
  240. tempTime := time.Unix(timestamp, 0)
  241. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  242. // 生成输入报文
  243. inputMessage := SetInputMessagenosign(nonce, timestamp, org_name, opera, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  244. input := make(map[string]interface{})
  245. inputData := make(map[string]interface{})
  246. inputMessage["infno"] = "2201" // 交易编码
  247. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  248. inputData["insutype"] = insutype // 险种类型(来自1101接口返回)
  249. inputData["begntime"] = timeFormatOne // 开始时间
  250. if id_card_type == 1 {
  251. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  252. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  253. } else {
  254. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  255. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  256. }
  257. inputData["ipt_otp_no"] = ipt_otp_no // 住院/门诊号
  258. inputData["atddr_no"] = doctor_id // 医师编码
  259. inputData["dr_name"] = doctor_name // 医师姓名
  260. inputData["dept_code"] = dept_code // 科室编码
  261. inputData["dept_name"] = dept // 科室名称
  262. inputData["caty"] = "A03.06" // 科别
  263. input["data"] = inputData
  264. inputMessage["input"] = input //交易输入
  265. var requestLog string
  266. bytesData, err := json.Marshal(inputMessage)
  267. requestLog = string(bytesData)
  268. fmt.Println(string(bytesData))
  269. if err != nil {
  270. fmt.Println(err.Error())
  271. return err.Error(), ""
  272. }
  273. reader := bytes.NewReader(bytesData)
  274. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2201"
  275. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2201"
  276. gdyb_url := beego.AppConfig.String("gdyb_url")
  277. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  278. var url string
  279. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  280. url = gdyb_url
  281. } else {
  282. url = gdyb_url + "2201"
  283. }
  284. if insuplc_admdvs == "421300" {
  285. var json2 string
  286. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2201", string(bytesData), json2)
  287. out, err := cmd.Output()
  288. if err != nil {
  289. fmt.Println("error:", err.Error())
  290. }
  291. fmt.Println(string(out))
  292. return hex.EncodeToString(out), requestLog
  293. } else {
  294. request, err := http.NewRequest("POST", url, reader)
  295. if err != nil {
  296. fmt.Println(err.Error())
  297. return err.Error(), ""
  298. }
  299. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  300. request.Header.Set("x-tif-paasid", gdyb_paasid)
  301. request.Header.Set("x-tif-signature", signature)
  302. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  303. request.Header.Set("x-tif-nonce", nonce)
  304. client := http.Client{}
  305. resp, err := client.Do(request)
  306. if err != nil {
  307. fmt.Println(err.Error())
  308. return err.Error(), ""
  309. }
  310. respBytes, err := ioutil.ReadAll(resp.Body)
  311. if err != nil {
  312. fmt.Println(err.Error())
  313. return err.Error(), ""
  314. }
  315. str := string(respBytes)
  316. fmt.Println(str)
  317. return str, requestLog
  318. }
  319. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2201"
  320. }
  321. func Gdyb2201A(psnNo string, insutype string, certNo string, org_name string, opera string, ipt_otp_no string, dept string, fixmedins_code string, dept_code string, doctor_id string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, doctor_name string, record_time string, token string, admin_user_id int64) (string, string) {
  322. fmt.Println(opera)
  323. // 生成签名
  324. nonce := GetRandomString(32)
  325. timestamp := time.Now().Unix()
  326. signature := setSignature(timestamp, nonce, secret_key)
  327. //tempTime := time.Unix(timestamp, 0)
  328. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  329. inputMessage := make(map[string]interface{})
  330. //tempTime := time.Unix(timestamp, 0)
  331. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  332. // 生成输入报文
  333. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  334. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, opera)
  335. } else {
  336. inputMessage = SetInputMessage(nonce, timestamp, org_name, opera, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  337. }
  338. // 生成输入报文
  339. //inputMessage := SetInputMessagenosign(nonce, timestamp, org_name, opera, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  340. input := make(map[string]interface{})
  341. inputData := make(map[string]interface{})
  342. inputMessage["infno"] = "2201" // 交易编码
  343. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  344. inputData["insutype"] = insutype // 险种类型(来自1101接口返回)
  345. inputData["begntime"] = record_time // 开始时间
  346. if id_card_type == 1 {
  347. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  348. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  349. } else if id_card_type == 4 {
  350. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  351. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  352. } else {
  353. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  354. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  355. }
  356. inputData["ipt_otp_no"] = ipt_otp_no // 住院/门诊号
  357. inputData["atddr_no"] = doctor_id // 医师编码
  358. inputData["dr_name"] = doctor_name // 医师姓名
  359. inputData["dept_code"] = dept_code // 科室编码
  360. inputData["dept_name"] = dept // 科室名称
  361. inputData["caty"] = "A03.06" // 科别
  362. input["data"] = inputData
  363. inputMessage["input"] = input //交易输入
  364. var requestLog string
  365. bytesData, err := json.Marshal(inputMessage)
  366. requestLog = string(bytesData)
  367. fmt.Println(string(bytesData))
  368. if err != nil {
  369. fmt.Println(err.Error())
  370. return err.Error(), ""
  371. }
  372. reader := bytes.NewReader(bytesData)
  373. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2201"
  374. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2201"
  375. gdyb_url := beego.AppConfig.String("gdyb_url")
  376. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  377. var url string
  378. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  379. url = gdyb_url
  380. } else {
  381. url = gdyb_url + "2201"
  382. }
  383. if insuplc_admdvs == "421300" {
  384. var json2 string
  385. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2201", string(bytesData), json2)
  386. out, err := cmd.Output()
  387. if err != nil {
  388. fmt.Println("error:", err.Error())
  389. }
  390. fmt.Println(string(out))
  391. return hex.EncodeToString(out), requestLog
  392. } else {
  393. fmt.Println(url)
  394. fmt.Println(gdyb_paasid)
  395. fmt.Println(secret_key)
  396. request, err := http.NewRequest("POST", url, reader)
  397. if err != nil {
  398. fmt.Println(err.Error())
  399. return err.Error(), ""
  400. }
  401. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  402. request.Header.Set("x-tif-paasid", gdyb_paasid)
  403. request.Header.Set("x-tif-signature", signature)
  404. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  405. request.Header.Set("x-tif-nonce", nonce)
  406. client := http.Client{}
  407. resp, err := client.Do(request)
  408. if err != nil {
  409. fmt.Println(err.Error())
  410. return err.Error(), ""
  411. }
  412. respBytes, err := ioutil.ReadAll(resp.Body)
  413. if err != nil {
  414. fmt.Println(err.Error())
  415. return err.Error(), ""
  416. }
  417. str := string(respBytes)
  418. fmt.Println(str)
  419. return str, requestLog
  420. }
  421. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2201"
  422. }
  423. // 门诊挂号撤销
  424. func Gdyb2202(psnNo string, mdtrtId string, ipt_otp_no string, org_name string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, fixmedins_code string, admin_user_id int64) (string, string) {
  425. // 生成签名
  426. nonce := GetRandomString(32)
  427. timestamp := time.Now().Unix()
  428. signature := setSignature(timestamp, nonce, secret_key)
  429. // 生成输入报文
  430. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  431. inputMessage := make(map[string]interface{})
  432. //tempTime := time.Unix(timestamp, 0)
  433. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  434. // 生成输入报文
  435. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  436. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  437. } else {
  438. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  439. }
  440. input := make(map[string]interface{})
  441. inputData := make(map[string]interface{})
  442. inputMessage["infno"] = "2202" // 交易编码
  443. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  444. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  445. inputData["ipt_otp_no"] = ipt_otp_no // 住院/门诊号
  446. input["data"] = inputData
  447. inputMessage["input"] = input //交易输入
  448. var requestLog string
  449. bytesData, err := json.Marshal(inputMessage)
  450. fmt.Println(string(bytesData))
  451. requestLog = string(bytesData)
  452. if err != nil {
  453. fmt.Println(err.Error())
  454. return err.Error(), ""
  455. }
  456. reader := bytes.NewReader(bytesData)
  457. gdyb_url := beego.AppConfig.String("gdyb_url")
  458. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  459. var url string
  460. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  461. url = gdyb_url
  462. } else {
  463. url = gdyb_url + "2202"
  464. }
  465. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2202"
  466. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2202"
  467. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2202"
  468. if insuplc_admdvs == "421300" {
  469. var json2 string
  470. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2202", string(bytesData), json2)
  471. out, err := cmd.Output()
  472. if err != nil {
  473. fmt.Println("error:", err.Error())
  474. }
  475. fmt.Println(string(out))
  476. return hex.EncodeToString(out), requestLog
  477. } else {
  478. request, err := http.NewRequest("POST", url, reader)
  479. if err != nil {
  480. fmt.Println(err.Error())
  481. return err.Error(), ""
  482. }
  483. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  484. request.Header.Set("x-tif-paasid", gdyb_paasid)
  485. request.Header.Set("x-tif-signature", signature)
  486. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  487. request.Header.Set("x-tif-nonce", nonce)
  488. client := http.Client{}
  489. resp, err := client.Do(request)
  490. if err != nil {
  491. fmt.Println(err.Error())
  492. return err.Error(), ""
  493. }
  494. respBytes, err := ioutil.ReadAll(resp.Body)
  495. if err != nil {
  496. fmt.Println(err.Error())
  497. return err.Error(), ""
  498. }
  499. str := string(respBytes)
  500. fmt.Println(str)
  501. return str, requestLog
  502. }
  503. }
  504. // 门诊就诊信息上传
  505. func Gdyb2203(psnNo string, mdtrtId string, doctor string, department string, org_name string, med_type string, doctor_id string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, sick_code string, sick_name string, dept string, config []*models.HisXtDiagnoseConfig, begin_time string, doctor_name string, op_id int64, op_name string) (string, string) {
  506. // 生成签名
  507. nonce := GetRandomString(32)
  508. timestamp := time.Now().Unix()
  509. signature := setSignature(timestamp, nonce, secret_key)
  510. inputMessage := make(map[string]interface{})
  511. //tempTime := time.Unix(timestamp, 0)
  512. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  513. // 生成输入报文
  514. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  515. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, op_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, op_name)
  516. } else {
  517. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  518. }
  519. //inputMessage := SetInputMessage1111(nonce, timestamp, org_name, op_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs,op_name)
  520. input := make(map[string]interface{})
  521. inputData := make(map[string]interface{})
  522. diseinfo := make([]map[string]interface{}, 0)
  523. if med_type == "1111" || med_type == "1112" {
  524. med_type = "11"
  525. }
  526. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  527. inputMessage["infno"] = "2203" // 交易编码
  528. } else {
  529. inputMessage["infno"] = "2203" // 交易编码
  530. }
  531. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  532. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  533. inputData["med_type"] = med_type // 医疗类别 16门诊特殊病
  534. inputData["begntime"] = begin_time // 开始时间
  535. //inputData["begntime"] = // 开始时间
  536. inputData["main_cond_dscr"] = "" // 主要病情描述
  537. inputData["dise_codg"] = sick_code // 病种编码
  538. inputData["dise_name"] = sick_name // 病种名称
  539. if med_type == "12" {
  540. inputData["dise_codg"] = "" // 病种编码
  541. inputData["dise_name"] = "" // 病种名称
  542. }
  543. inputData["birctrl_type"] = "" // 计划生育手术类别
  544. inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
  545. for index, item := range config {
  546. diseinfo_sun := make(map[string]interface{})
  547. diseinfo_sun["diag_type"] = "1" // 诊断类别
  548. diseinfo_sun["diag_srt_no"] = index + 1 // 诊断排序号
  549. diseinfo_sun["diag_code"] = item.CountryCode // 诊断代码
  550. diseinfo_sun["diag_name"] = item.ClassName // 诊断名称
  551. diseinfo_sun["diag_dept"] = department // 诊断科室
  552. diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
  553. diseinfo_sun["dise_dor_name"] = doctor_name // 诊断医生姓名
  554. diseinfo_sun["diag_time"] = begin_time // 诊断时间
  555. diseinfo_sun["vali_flag"] = "1" // 有效标志
  556. diseinfo = append(diseinfo, diseinfo_sun)
  557. }
  558. input["diseinfo"] = diseinfo
  559. input["mdtrtinfo"] = inputData
  560. inputMessage["input"] = input //交易输入
  561. var requestLog string
  562. bytesData, err := json.Marshal(inputMessage)
  563. fmt.Println(string(bytesData))
  564. requestLog = string(bytesData)
  565. if err != nil {
  566. fmt.Println(err.Error())
  567. return err.Error(), ""
  568. }
  569. reader := bytes.NewReader(bytesData)
  570. gdyb_url := beego.AppConfig.String("gdyb_url")
  571. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  572. var url string
  573. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  574. url = gdyb_url
  575. } else {
  576. url = gdyb_url + "2203"
  577. }
  578. if insuplc_admdvs == "421300" {
  579. var json2 string
  580. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2203", string(bytesData), json2)
  581. out, err := cmd.Output()
  582. if err != nil {
  583. fmt.Println("error:", err.Error())
  584. }
  585. fmt.Println(string(out))
  586. return hex.EncodeToString(out), requestLog
  587. } else {
  588. request, err := http.NewRequest("POST", url, reader)
  589. if err != nil {
  590. fmt.Println(err.Error())
  591. return err.Error(), ""
  592. }
  593. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  594. request.Header.Set("x-tif-paasid", gdyb_paasid)
  595. request.Header.Set("x-tif-signature", signature)
  596. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  597. request.Header.Set("x-tif-nonce", nonce)
  598. client := http.Client{}
  599. resp, err := client.Do(request)
  600. if err != nil {
  601. fmt.Println(err.Error())
  602. return err.Error(), ""
  603. }
  604. respBytes, err := ioutil.ReadAll(resp.Body)
  605. if err != nil {
  606. fmt.Println(err.Error())
  607. return err.Error(), ""
  608. }
  609. str := string(respBytes)
  610. fmt.Println(str)
  611. return str, requestLog
  612. }
  613. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2203"
  614. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  615. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  616. }
  617. func Gdyb2203c(psnNo string, mdtrtId string, doctor string, department string, org_name string, med_type string, doctor_id string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, sick_code string, sick_name string, dept string, config []*models.HisXtDiagnoseConfig, begin_time string, doctor_name string) (string, string) {
  618. // 生成签名
  619. nonce := GetRandomString(32)
  620. timestamp := time.Now().Unix()
  621. signature := setSignature(timestamp, nonce, secret_key)
  622. //tempTime := time.Unix(timestamp, 0)
  623. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  624. // 生成输入报文
  625. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  626. input := make(map[string]interface{})
  627. inputData := make(map[string]interface{})
  628. diseinfo := make([]map[string]interface{}, 0)
  629. if med_type == "1111" || med_type == "1112" {
  630. med_type = "11"
  631. }
  632. inputMessage["infno"] = "2203" // 交易编码
  633. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  634. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  635. inputData["med_type"] = med_type // 医疗类别 16门诊特殊病
  636. inputData["begntime"] = begin_time // 开始时间
  637. //inputData["begntime"] = // 开始时间
  638. inputData["main_cond_dscr"] = "" // 主要病情描述
  639. inputData["dise_codg"] = sick_code // 病种编码
  640. inputData["dise_name"] = sick_name // 病种名称
  641. if med_type == "12" {
  642. inputData["dise_codg"] = "" // 病种编码
  643. inputData["dise_name"] = "" // 病种名称
  644. }
  645. inputData["birctrl_type"] = "" // 计划生育手术类别
  646. inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
  647. for index, item := range config {
  648. diseinfo_sun := make(map[string]interface{})
  649. diseinfo_sun["diag_type"] = "1" // 诊断类别
  650. diseinfo_sun["diag_srt_no"] = index // 诊断排序号
  651. diseinfo_sun["diag_code"] = item.CountryCode // 诊断代码
  652. diseinfo_sun["diag_name"] = item.ClassName // 诊断名称
  653. diseinfo_sun["diag_dept"] = department // 诊断科室
  654. diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
  655. diseinfo_sun["dise_dor_name"] = doctor_name // 诊断医生姓名
  656. diseinfo_sun["diag_time"] = begin_time // 诊断时间
  657. diseinfo_sun["vali_flag"] = "1" // 有效标志
  658. diseinfo = append(diseinfo, diseinfo_sun)
  659. }
  660. input["diseinfo"] = diseinfo
  661. input["mdtrtinfo"] = inputData
  662. inputMessage["input"] = input //交易输入
  663. var requestLog string
  664. bytesData, err := json.Marshal(inputMessage)
  665. fmt.Println(string(bytesData))
  666. requestLog = string(bytesData)
  667. if err != nil {
  668. fmt.Println(err.Error())
  669. return err.Error(), ""
  670. }
  671. reader := bytes.NewReader(bytesData)
  672. gdyb_url := beego.AppConfig.String("gdyb_url")
  673. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  674. var url string
  675. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  676. url = gdyb_url
  677. } else {
  678. url = gdyb_url + "2203"
  679. }
  680. if insuplc_admdvs == "421300" {
  681. var json2 string
  682. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2203", string(bytesData), json2)
  683. out, err := cmd.Output()
  684. if err != nil {
  685. fmt.Println("error:", err.Error())
  686. }
  687. fmt.Println(string(out))
  688. return hex.EncodeToString(out), requestLog
  689. } else {
  690. request, err := http.NewRequest("POST", url, reader)
  691. if err != nil {
  692. fmt.Println(err.Error())
  693. return err.Error(), ""
  694. }
  695. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  696. request.Header.Set("x-tif-paasid", gdyb_paasid)
  697. request.Header.Set("x-tif-signature", signature)
  698. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  699. request.Header.Set("x-tif-nonce", nonce)
  700. client := http.Client{}
  701. resp, err := client.Do(request)
  702. if err != nil {
  703. fmt.Println(err.Error())
  704. return err.Error(), ""
  705. }
  706. respBytes, err := ioutil.ReadAll(resp.Body)
  707. if err != nil {
  708. fmt.Println(err.Error())
  709. return err.Error(), ""
  710. }
  711. str := string(respBytes)
  712. fmt.Println(str)
  713. return str, requestLog
  714. }
  715. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2203"
  716. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  717. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  718. }
  719. // 门诊就诊信息上传
  720. 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) {
  721. // 生成签名
  722. nonce := GetRandomString(32)
  723. timestamp := time.Now().Unix()
  724. signature := setSignature(timestamp, nonce, secret_key)
  725. tempTime := time.Unix(timestamp, 0)
  726. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  727. // 生成输入报文
  728. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  729. input := make(map[string]interface{})
  730. inputData := make(map[string]interface{})
  731. diseinfo := make([]map[string]interface{}, 0)
  732. if med_type == "1111" || med_type == "1112" {
  733. med_type = "11"
  734. }
  735. inputMessage["infno"] = "2203A" // 交易编码
  736. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  737. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  738. inputData["med_type"] = med_type // 医疗类别 16门诊特殊病
  739. inputData["begntime"] = begin_time // 开始时间
  740. inputData["main_cond_dscr"] = "" // 主要病情描述
  741. inputData["dise_codg"] = sick_code // 病种编码
  742. inputData["dise_name"] = sick_name // 病种名称
  743. inputData["birctrl_type"] = "" // 计划生育手术类别
  744. inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
  745. inputData["matn_type"] = "" // 生育类别
  746. inputData["geso_val"] = "" // 孕周数
  747. for index, item := range config {
  748. diseinfo_sun := make(map[string]interface{})
  749. diseinfo_sun["diag_type"] = "1" // 诊断类别
  750. diseinfo_sun["diag_srt_no"] = index // 诊断排序号
  751. diseinfo_sun["diag_code"] = item.CountryCode // 诊断代码
  752. diseinfo_sun["diag_name"] = item.ClassName // 诊断名称
  753. diseinfo_sun["diag_dept"] = department // 诊断科室
  754. diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
  755. diseinfo_sun["dise_dor_name"] = doctor // 诊断医生姓名
  756. diseinfo_sun["diag_time"] = timeFormatOne // 诊断时间
  757. diseinfo_sun["vali_flag"] = "1" // 有效标志
  758. diseinfo = append(diseinfo, diseinfo_sun)
  759. }
  760. input["diseinfo"] = diseinfo
  761. input["mdtrtinfo"] = inputData
  762. inputMessage["input"] = input //交易输入
  763. var requestLog string
  764. bytesData, err := json.Marshal(inputMessage)
  765. fmt.Println(string(bytesData))
  766. requestLog = string(bytesData)
  767. if err != nil {
  768. fmt.Println(err.Error())
  769. return err.Error(), ""
  770. }
  771. reader := bytes.NewReader(bytesData)
  772. gdyb_url := beego.AppConfig.String("gdyb_url")
  773. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  774. var url string
  775. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  776. url = gdyb_url
  777. } else {
  778. url = gdyb_url + "2203"
  779. }
  780. if insuplc_admdvs == "421300" {
  781. var json2 string
  782. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2203A", string(bytesData), json2)
  783. out, err := cmd.Output()
  784. if err != nil {
  785. fmt.Println("error:", err.Error())
  786. }
  787. fmt.Println(string(out))
  788. return hex.EncodeToString(out), requestLog
  789. } else {
  790. request, err := http.NewRequest("POST", url, reader)
  791. if err != nil {
  792. fmt.Println(err.Error())
  793. return err.Error(), ""
  794. }
  795. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  796. request.Header.Set("x-tif-paasid", gdyb_paasid)
  797. request.Header.Set("x-tif-signature", signature)
  798. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  799. request.Header.Set("x-tif-nonce", nonce)
  800. client := http.Client{}
  801. resp, err := client.Do(request)
  802. if err != nil {
  803. fmt.Println(err.Error())
  804. return err.Error(), ""
  805. }
  806. respBytes, err := ioutil.ReadAll(resp.Body)
  807. if err != nil {
  808. fmt.Println(err.Error())
  809. return err.Error(), ""
  810. }
  811. str := string(respBytes)
  812. fmt.Println(str)
  813. return str, requestLog
  814. }
  815. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2203A"
  816. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  817. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  818. }
  819. func Gdyb2203d(psnNo string, mdtrtId string, doctor string, department string, org_name string, med_type string, doctor_id string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, sick_code string, sick_name string, dept string, config []*models.HisXtDiagnoseConfig, begin_time string) (string, string) {
  820. // 生成签名
  821. nonce := GetRandomString(32)
  822. timestamp := time.Now().Unix()
  823. signature := setSignature(timestamp, nonce, secret_key)
  824. tempTime := time.Unix(timestamp, 0)
  825. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  826. // 生成输入报文
  827. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  828. input := make(map[string]interface{})
  829. inputData := make(map[string]interface{})
  830. diseinfo := make([]map[string]interface{}, 0)
  831. inputMessage["infno"] = "2203" // 交易编码
  832. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  833. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  834. inputData["med_type"] = "14" // 医疗类别 16门诊特殊病
  835. inputData["begntime"] = begin_time // 开始时间
  836. inputData["main_cond_dscr"] = "" // 主要病情描述
  837. inputData["dise_codg"] = sick_code // 病种编码
  838. inputData["dise_name"] = sick_name // 病种名称
  839. inputData["birctrl_type"] = "" // 计划生育手术类别
  840. inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
  841. inputData["matn_type"] = "" // 生育类别
  842. inputData["geso_val"] = "" // 孕周数
  843. for index, item := range config {
  844. diseinfo_sun := make(map[string]interface{})
  845. diseinfo_sun["diag_type"] = "1" // 诊断类别
  846. diseinfo_sun["diag_srt_no"] = index // 诊断排序号
  847. diseinfo_sun["diag_code"] = item.CountryCode // 诊断代码
  848. diseinfo_sun["diag_name"] = item.ClassName // 诊断名称
  849. diseinfo_sun["diag_dept"] = department // 诊断科室
  850. diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
  851. diseinfo_sun["dise_dor_name"] = doctor // 诊断医生姓名
  852. diseinfo_sun["diag_time"] = timeFormatOne // 诊断时间
  853. diseinfo_sun["vali_flag"] = "1" // 有效标志
  854. diseinfo = append(diseinfo, diseinfo_sun)
  855. }
  856. input["diseinfo"] = diseinfo
  857. input["mdtrtinfo"] = inputData
  858. inputMessage["input"] = input //交易输入
  859. var requestLog string
  860. bytesData, err := json.Marshal(inputMessage)
  861. fmt.Println(string(bytesData))
  862. requestLog = string(bytesData)
  863. if err != nil {
  864. fmt.Println(err.Error())
  865. return err.Error(), ""
  866. }
  867. reader := bytes.NewReader(bytesData)
  868. gdyb_url := beego.AppConfig.String("gdyb_url")
  869. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  870. var url string
  871. url = gdyb_url + "2203"
  872. if insuplc_admdvs == "421300" {
  873. var json2 string
  874. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2203A", string(bytesData), json2)
  875. out, err := cmd.Output()
  876. if err != nil {
  877. fmt.Println("error:", err.Error())
  878. }
  879. fmt.Println(string(out))
  880. return hex.EncodeToString(out), requestLog
  881. } else {
  882. request, err := http.NewRequest("POST", url, reader)
  883. if err != nil {
  884. fmt.Println(err.Error())
  885. return err.Error(), ""
  886. }
  887. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  888. request.Header.Set("x-tif-paasid", gdyb_paasid)
  889. request.Header.Set("x-tif-signature", signature)
  890. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  891. request.Header.Set("x-tif-nonce", nonce)
  892. client := http.Client{}
  893. resp, err := client.Do(request)
  894. if err != nil {
  895. fmt.Println(err.Error())
  896. return err.Error(), ""
  897. }
  898. respBytes, err := ioutil.ReadAll(resp.Body)
  899. if err != nil {
  900. fmt.Println(err.Error())
  901. return err.Error(), ""
  902. }
  903. str := string(respBytes)
  904. fmt.Println(str)
  905. return str, requestLog
  906. }
  907. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2203A"
  908. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  909. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  910. }
  911. type Custom struct {
  912. DetItemFeeSumamt string
  913. Cut string
  914. FeedetlSn string
  915. Price string
  916. MedListCodg string
  917. LmtUsedFlag int64
  918. HospApprFlag int64
  919. DoctorNumber string
  920. DoctorName string
  921. ProvinceDrugMedListCodg string
  922. ProvinceGoodMedListCodg string
  923. IsUser int64
  924. FeeOcurTime string
  925. Unit string
  926. }
  927. type RequestResult struct {
  928. Output Output `json:"output" form:"output"`
  929. Infcode int64 `gorm:"column:infcode" json:"infcode" form:"infcode"`
  930. WarnMsg string `gorm:"column:warn_msg" json:"warn_msg" form:"warn_msg"`
  931. Cainfo string `gorm:"column:cainfo" json:"cainfo" form:"cainfo"`
  932. ErrMsg string `gorm:"column:err_msg" json:"err_msg" form:"err_msg"`
  933. RespondTime string `gorm:"column:respond_time" json:"respond_time" form:"respond_time"`
  934. InfRefmsgid string `gorm:"column:inf_refmsgid" json:"inf_refmsgid" form:"inf_refmsgid"`
  935. }
  936. type Output struct {
  937. Result Result `json:"result" form:"result"`
  938. }
  939. type Result struct {
  940. BasMednFlag string `json:"bas_medn_flag" form:"bas_medn_flag"`
  941. MedChrgitmType string `json:"med_chrgitm_type" form:"med_chrgitm_type"`
  942. DetItemFeeSumamt int64 `json:"det_item_fee_sumamt" form:"det_item_fee_sumamt"`
  943. HiNegoDrugFlag string `json:"hi_nego_drug_flag" form:"hi_nego_drug_flag"`
  944. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
  945. FeedtlSn int64 `json:"feedtl_sn" form:"feedtl_sn"`
  946. UploadDate int64 `json:"upload_date" form:"upload_date"`
  947. AdviceId int64 `json:"advice_id" form:"advice_id"`
  948. Cnt int64 `json:"cnt" form:"cnt"`
  949. Pric float64 `json:"pric" form:"pric"`
  950. PatientId int64 `json:"patient_id" form:"patient_id"`
  951. PricUplmtAmt float64 `json:"pric_uplmt_amt" form:"pric_uplmt_amt"`
  952. SelfpayProp float64 `json:"selfpay_prop" form:"selfpay_prop"`
  953. OverlmtAmt float64 `json:"overlmt_amt" form:"overlmt_amt"`
  954. PreselfpayAmt float64 `json:"preselfpay_amt" form:"preselfpay_amt"`
  955. Status int64 `json:"status" form:"status"`
  956. Memo string `json:"memo" form:"memo"`
  957. FeedetlSn string `json:"feedetl_sn" form:"feedetl_sn"`
  958. Mtime int64 `json:"mtime" form:"mtime"`
  959. InscpScpAmt float64 `json:"inscp_scp_amt" form:"inscp_scp_amt"`
  960. DrtReimFlag string `json:"drt_reim_flag" form:"drt_reim_flag"`
  961. Ctime int64 `json:"ctime" form:"ctime"`
  962. ListSpItemFlag string `json:"list_sp_item_flag" form:"list_sp_item_flag"`
  963. ChldMedcFlag string `json:"chld_medc_flag" form:"chld_medc_flag"`
  964. LmtUsedFlag string `json:"lmt_used_flag" form:"lmt_used_flag"`
  965. ChrgitmLv string `json:"chrgitm_lv" form:"chrgitm_lv"`
  966. UserOrgId int64 `json:"user_org_id" form:"user_org_id"`
  967. HisPatientId int64 `json:"his_patient_id" form:"his_patient_id"`
  968. OrderId int64 `json:"order_id" form:"order_id"`
  969. }
  970. // 门诊费用明细信息上传
  971. func Gdyb2204(psnNo string, mdtrtId string, hisPrescription []*models.HisPrescription, chrg_bchno string, org_name string, doctor string, dept string, fixmedins_code string, dept_code string, doctor_id string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, balance_accounts_type string, new_doctor_id int64, diag_code string, admin_user_id int64) (string, string) {
  972. // 生成签名
  973. nonce := GetRandomString(32)
  974. timestamp := time.Now().Unix()
  975. signature := setSignature(timestamp, nonce, secret_key)
  976. //tempTime := time.Unix(timestamp, 0)
  977. //timeFormat := tempTime.Format("20060102150405")
  978. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  979. //chrgBchno := rand.Intn(100000) + 10000
  980. var customs []*Custom
  981. inputMessage := make(map[string]interface{})
  982. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  983. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  984. } else {
  985. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  986. }
  987. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  988. for _, item := range hisPrescription {
  989. role, _ := GetAdminUserInfoByID(item.UserOrgId, new_doctor_id)
  990. tm := time.Unix(item.PreTime, 0)
  991. if item.Type == 1 { //药品
  992. for _, subItem := range item.HisDoctorAdviceInfo {
  993. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 && subItem.BaseDrugLib.IsUser != 1 {
  994. //var randNum int
  995. //randNum = rand.Intn(10000) + 1000
  996. role, _ := GetAdminUserInfoByID(item.UserOrgId, new_doctor_id)
  997. cus := &Custom{
  998. DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  999. Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  1000. FeedetlSn: subItem.FeedetlSn,
  1001. Price: fmt.Sprintf("%.2f", subItem.Price),
  1002. MedListCodg: subItem.BaseDrugLib.MedicalInsuranceNumber,
  1003. HospApprFlag: subItem.HospApprFlag,
  1004. DoctorNumber: role.DoctorNumber,
  1005. DoctorName: role.UserName,
  1006. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  1007. }
  1008. customs = append(customs, cus)
  1009. }
  1010. }
  1011. }
  1012. if item.Type == 2 { //项目
  1013. for _, subItem := range item.HisPrescriptionProject {
  1014. //var randNum int
  1015. //randNum = rand.Intn(10000) + 1000
  1016. if subItem.Type == 2 {
  1017. if len(subItem.HisProject.MedicalCode) > 0 {
  1018. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1019. cus := &Custom{
  1020. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  1021. Cut: fmt.Sprintf("%.4f", cnt),
  1022. FeedetlSn: subItem.FeedetlSn,
  1023. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  1024. MedListCodg: subItem.HisProject.MedicalCode,
  1025. DoctorNumber: role.DoctorNumber,
  1026. DoctorName: role.UserName,
  1027. HospApprFlag: -1,
  1028. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  1029. }
  1030. customs = append(customs, cus)
  1031. }
  1032. } else if subItem.Type == 3 {
  1033. if len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  1034. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1035. cus := &Custom{
  1036. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  1037. Cut: fmt.Sprintf("%.4f", cnt),
  1038. FeedetlSn: subItem.FeedetlSn,
  1039. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  1040. MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
  1041. HospApprFlag: -1,
  1042. DoctorNumber: role.DoctorNumber,
  1043. DoctorName: role.UserName,
  1044. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  1045. }
  1046. customs = append(customs, cus)
  1047. }
  1048. }
  1049. }
  1050. }
  1051. for _, subItem := range item.HisAdditionalCharge {
  1052. if len(subItem.XtHisAddtionConfig.Code) > 0 {
  1053. cus := &Custom{
  1054. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*float64(subItem.Count)),
  1055. Cut: fmt.Sprintf("%.4f", float64(subItem.Count)),
  1056. FeedetlSn: subItem.FeedetlSn,
  1057. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  1058. MedListCodg: subItem.XtHisAddtionConfig.Code,
  1059. HospApprFlag: -1,
  1060. DoctorNumber: role.DoctorNumber,
  1061. DoctorName: role.UserName,
  1062. }
  1063. customs = append(customs, cus)
  1064. }
  1065. }
  1066. }
  1067. // 生成输入报文
  1068. input := make(map[string]interface{})
  1069. feedetail := make([]map[string]interface{}, 0)
  1070. inputMessage["infno"] = "2204" // 交易编码
  1071. //chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  1072. for _, item := range customs {
  1073. feedetailInfo := make(map[string]interface{})
  1074. feedetailInfo["feedetl_sn"] = item.FeedetlSn
  1075. feedetailInfo["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1076. feedetailInfo["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1077. feedetailInfo["chrg_bchno"] = chrg_bchno // 收费批次号
  1078. feedetailInfo["dise_codg"] = diag_code // 病种编码
  1079. feedetailInfo["rxno"] = "" // 处方号
  1080. feedetailInfo["rx_circ_flag"] = "0" // 外购处方标志
  1081. feedetailInfo["fee_ocur_time"] = item.FeeOcurTime // 费用发生时间
  1082. feedetailInfo["med_list_codg"] = item.MedListCodg // 医疗目录编码
  1083. feedetailInfo["medins_list_codg"] = item.MedListCodg // 医药机构目录编码
  1084. feedetailInfo["det_item_fee_sumamt"] = item.DetItemFeeSumamt // 明细项目费用总额
  1085. feedetailInfo["cnt"] = item.Cut // 数量
  1086. feedetailInfo["pric"] = item.Price // 单价
  1087. feedetailInfo["sin_dos_dscr"] = "1" // 单次剂量描述
  1088. feedetailInfo["used_frqu_dscr"] = "" // 使用频次描述
  1089. feedetailInfo["prd_days"] = "0" // 周期天数
  1090. feedetailInfo["medc_way_dscr"] = "" // 用药途径描述
  1091. feedetailInfo["bilg_dept_codg"] = dept_code // 开单科室编码
  1092. feedetailInfo["bilg_dept_name"] = dept // 开单科室名称
  1093. feedetailInfo["bilg_dr_codg"] = item.DoctorNumber // 开单医生编码
  1094. feedetailInfo["bilg_dr_name"] = item.DoctorName // 开单医师姓名
  1095. feedetailInfo["acord_dept_codg"] = "" // 受单科室编码
  1096. feedetailInfo["acord_dept_name"] = "" // 受单科室名称
  1097. feedetailInfo["orders_dr_code"] = item.DoctorNumber // 受单医生编码
  1098. feedetailInfo["orders_dr_name"] = item.DoctorName // 受单医生姓名
  1099. if balance_accounts_type == "8" {
  1100. feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
  1101. } else {
  1102. if item.HospApprFlag != -1 {
  1103. if item.HospApprFlag == 1 {
  1104. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  1105. } else if item.HospApprFlag == 2 {
  1106. feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
  1107. } else if item.HospApprFlag == 3 {
  1108. feedetailInfo["hosp_appr_flag"] = "0" // 医院审批标志
  1109. } else {
  1110. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  1111. }
  1112. } else {
  1113. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  1114. }
  1115. }
  1116. //feedetailInfo["tcmdrug_used_way"] = "" // 中药使用方式
  1117. feedetailInfo["etip_flag"] = "0" // 外检标志
  1118. feedetailInfo["etip_hosp_code"] = "" // 外检医院编码
  1119. feedetailInfo["dscg_tkdrug_flag"] = "" // 出院带药标志
  1120. feedetailInfo["matn_fee_flag"] = "" // 生育费用标志
  1121. feedetail = append(feedetail, feedetailInfo)
  1122. }
  1123. input["feedetail"] = feedetail
  1124. inputMessage["input"] = input //交易输入
  1125. var requestLog string
  1126. bytesData, err := json.Marshal(inputMessage)
  1127. fmt.Println("----------")
  1128. fmt.Println(string(bytesData))
  1129. fmt.Println("----------")
  1130. requestLog = string(bytesData)
  1131. if err != nil {
  1132. fmt.Println(err.Error())
  1133. return "", ""
  1134. }
  1135. reader := bytes.NewReader(bytesData)
  1136. gdyb_url := beego.AppConfig.String("gdyb_url")
  1137. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1138. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1139. var url string
  1140. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  1141. url = gdyb_url
  1142. } else {
  1143. url = gdyb_url + "2204"
  1144. }
  1145. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2204"
  1146. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2204"
  1147. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2204"
  1148. if insuplc_admdvs == "421300" {
  1149. var json2 string
  1150. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2204", string(bytesData), json2)
  1151. out, err := cmd.Output()
  1152. if err != nil {
  1153. fmt.Println("error:", err.Error())
  1154. }
  1155. fmt.Println(string(out))
  1156. return hex.EncodeToString(out), requestLog
  1157. } else {
  1158. request, err := http.NewRequest("POST", url, reader)
  1159. if err != nil {
  1160. fmt.Println(err.Error())
  1161. return "", ""
  1162. }
  1163. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1164. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1165. request.Header.Set("x-tif-signature", signature)
  1166. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1167. request.Header.Set("x-tif-nonce", nonce)
  1168. client := http.Client{}
  1169. resp, err := client.Do(request)
  1170. if err != nil {
  1171. fmt.Println(err.Error())
  1172. return "", ""
  1173. }
  1174. respBytes, err := ioutil.ReadAll(resp.Body)
  1175. if err != nil {
  1176. fmt.Println(err.Error())
  1177. return "", ""
  1178. }
  1179. return string(respBytes), requestLog
  1180. }
  1181. //var result RequestResult
  1182. //json.Unmarshal(respBytes, &result)
  1183. //return &result
  1184. }
  1185. func Gdyb2204For441799(psnNo string, mdtrtId string, hisPrescription []*models.HisPrescription, chrg_bchno string, org_name string, doctor string, dept string, fixmedins_code string, dept_code string, new_doctor_name string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, balance_accounts_type string, new_doctor_id string, diag_code string) (string, string) {
  1186. // 生成签名
  1187. nonce := GetRandomString(32)
  1188. timestamp := time.Now().Unix()
  1189. signature := setSignature(timestamp, nonce, secret_key)
  1190. //tempTime := time.Unix(timestamp, 0)
  1191. //timeFormat := tempTime.Format("20060102150405")
  1192. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  1193. //chrgBchno := rand.Intn(100000) + 10000
  1194. var customs []*Custom
  1195. for _, item := range hisPrescription {
  1196. tm := time.Unix(item.PreTime, 0)
  1197. if item.Type == 1 { //药品
  1198. for _, subItem := range item.HisDoctorAdviceInfo {
  1199. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 && subItem.BaseDrugLib.IsUser != 1 {
  1200. //var randNum int
  1201. //randNum = rand.Intn(10000) + 1000
  1202. cus := &Custom{
  1203. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber),
  1204. Cut: fmt.Sprintf("%.4f", subItem.PrescribingNumber),
  1205. FeedetlSn: subItem.FeedetlSn,
  1206. Price: fmt.Sprintf("%.4f", subItem.Price),
  1207. MedListCodg: subItem.BaseDrugLib.MedicalInsuranceNumber,
  1208. HospApprFlag: subItem.HospApprFlag,
  1209. DoctorNumber: new_doctor_id,
  1210. DoctorName: new_doctor_name,
  1211. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  1212. }
  1213. customs = append(customs, cus)
  1214. }
  1215. }
  1216. }
  1217. if item.Type == 2 { //项目
  1218. for _, subItem := range item.HisPrescriptionProject {
  1219. //var randNum int
  1220. //randNum = rand.Intn(10000) + 1000
  1221. if subItem.Type == 2 {
  1222. if len(subItem.HisProject.MedicalCode) > 0 {
  1223. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1224. cus := &Custom{
  1225. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  1226. Cut: fmt.Sprintf("%.4f", cnt),
  1227. FeedetlSn: subItem.FeedetlSn,
  1228. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  1229. MedListCodg: subItem.HisProject.MedicalCode,
  1230. DoctorNumber: new_doctor_id,
  1231. DoctorName: new_doctor_name,
  1232. HospApprFlag: -1,
  1233. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  1234. }
  1235. customs = append(customs, cus)
  1236. }
  1237. } else if subItem.Type == 3 {
  1238. if len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  1239. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1240. cus := &Custom{
  1241. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  1242. Cut: fmt.Sprintf("%.4f", cnt),
  1243. FeedetlSn: subItem.FeedetlSn,
  1244. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  1245. MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
  1246. HospApprFlag: -1,
  1247. DoctorNumber: new_doctor_id,
  1248. DoctorName: new_doctor_name,
  1249. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  1250. }
  1251. customs = append(customs, cus)
  1252. }
  1253. }
  1254. }
  1255. }
  1256. for _, subItem := range item.HisAdditionalCharge {
  1257. if len(subItem.XtHisAddtionConfig.Code) > 0 {
  1258. cus := &Custom{
  1259. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*float64(subItem.Count)),
  1260. Cut: fmt.Sprintf("%.4f", float64(subItem.Count)),
  1261. FeedetlSn: subItem.FeedetlSn,
  1262. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  1263. MedListCodg: subItem.XtHisAddtionConfig.Code,
  1264. HospApprFlag: -1,
  1265. DoctorNumber: new_doctor_id,
  1266. DoctorName: new_doctor_name,
  1267. }
  1268. customs = append(customs, cus)
  1269. }
  1270. }
  1271. }
  1272. // 生成输入报文
  1273. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1274. input := make(map[string]interface{})
  1275. feedetail := make([]map[string]interface{}, 0)
  1276. inputMessage["infno"] = "2204" // 交易编码
  1277. //chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  1278. for _, item := range customs {
  1279. feedetailInfo := make(map[string]interface{})
  1280. feedetailInfo["feedetl_sn"] = item.FeedetlSn
  1281. feedetailInfo["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1282. feedetailInfo["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1283. feedetailInfo["chrg_bchno"] = chrg_bchno // 收费批次号
  1284. feedetailInfo["dise_codg"] = diag_code // 病种编码
  1285. feedetailInfo["rxno"] = "" // 处方号
  1286. feedetailInfo["rx_circ_flag"] = "0" // 外购处方标志
  1287. feedetailInfo["fee_ocur_time"] = item.FeeOcurTime // 费用发生时间
  1288. feedetailInfo["med_list_codg"] = item.MedListCodg // 医疗目录编码
  1289. feedetailInfo["medins_list_codg"] = fixmedins_code // 医药机构目录编码
  1290. feedetailInfo["det_item_fee_sumamt"] = item.DetItemFeeSumamt // 明细项目费用总额
  1291. feedetailInfo["cnt"] = item.Cut // 数量
  1292. feedetailInfo["pric"] = item.Price // 单价
  1293. feedetailInfo["sin_dos_dscr"] = "" // 单次剂量描述
  1294. feedetailInfo["used_frqu_dscr"] = "" // 使用频次描述
  1295. feedetailInfo["prd_days"] = "0" // 周期天数
  1296. feedetailInfo["medc_way_dscr"] = "" // 用药途径描述
  1297. feedetailInfo["bilg_dept_codg"] = dept_code // 开单科室编码
  1298. feedetailInfo["bilg_dept_name"] = dept // 开单科室名称
  1299. feedetailInfo["bilg_dr_codg"] = item.DoctorNumber // 开单医生编码
  1300. feedetailInfo["bilg_dr_name"] = item.DoctorName // 开单医师姓名
  1301. feedetailInfo["acord_dept_codg"] = "" // 受单科室编码
  1302. feedetailInfo["acord_dept_name"] = "" // 受单科室名称
  1303. feedetailInfo["orders_dr_code"] = item.DoctorNumber // 受单医生编码
  1304. feedetailInfo["orders_dr_name"] = item.DoctorName // 受单医生姓名
  1305. if balance_accounts_type == "8" {
  1306. feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
  1307. } else {
  1308. if item.HospApprFlag != -1 {
  1309. if item.HospApprFlag == 1 {
  1310. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  1311. } else if item.HospApprFlag == 2 {
  1312. feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
  1313. } else if item.HospApprFlag == 3 {
  1314. feedetailInfo["hosp_appr_flag"] = "0" // 医院审批标志
  1315. } else {
  1316. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  1317. }
  1318. } else {
  1319. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  1320. }
  1321. }
  1322. //feedetailInfo["tcmdrug_used_way"] = "" // 中药使用方式
  1323. feedetailInfo["etip_flag"] = "" // 外检标志
  1324. feedetailInfo["etip_hosp_code"] = "" // 外检医院编码
  1325. feedetailInfo["dscg_tkdrug_flag"] = "" // 出院带药标志
  1326. feedetailInfo["matn_fee_flag"] = "" // 生育费用标志
  1327. feedetail = append(feedetail, feedetailInfo)
  1328. }
  1329. input["feedetail"] = feedetail
  1330. inputMessage["input"] = input //交易输入
  1331. var requestLog string
  1332. bytesData, err := json.Marshal(inputMessage)
  1333. fmt.Println("----------")
  1334. fmt.Println(string(bytesData))
  1335. fmt.Println("----------")
  1336. requestLog = string(bytesData)
  1337. if err != nil {
  1338. fmt.Println(err.Error())
  1339. return "", ""
  1340. }
  1341. reader := bytes.NewReader(bytesData)
  1342. gdyb_url := beego.AppConfig.String("gdyb_url")
  1343. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1344. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1345. var url string
  1346. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  1347. url = gdyb_url
  1348. } else {
  1349. url = gdyb_url + "2204"
  1350. }
  1351. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2204"
  1352. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2204"
  1353. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2204"
  1354. if insuplc_admdvs == "421300" {
  1355. var json2 string
  1356. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2204", string(bytesData), json2)
  1357. out, err := cmd.Output()
  1358. if err != nil {
  1359. fmt.Println("error:", err.Error())
  1360. }
  1361. fmt.Println(string(out))
  1362. return hex.EncodeToString(out), requestLog
  1363. } else {
  1364. request, err := http.NewRequest("POST", url, reader)
  1365. if err != nil {
  1366. fmt.Println(err.Error())
  1367. return "", ""
  1368. }
  1369. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1370. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1371. request.Header.Set("x-tif-signature", signature)
  1372. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1373. request.Header.Set("x-tif-nonce", nonce)
  1374. client := http.Client{}
  1375. resp, err := client.Do(request)
  1376. if err != nil {
  1377. fmt.Println(err.Error())
  1378. return "", ""
  1379. }
  1380. respBytes, err := ioutil.ReadAll(resp.Body)
  1381. if err != nil {
  1382. fmt.Println(err.Error())
  1383. return "", ""
  1384. }
  1385. return string(respBytes), requestLog
  1386. }
  1387. //var result RequestResult
  1388. //json.Unmarshal(respBytes, &result)
  1389. //return &result
  1390. }
  1391. // 门诊费用明细信息撤销
  1392. func Gdyb2205(psnNo string, mdtrtId string, chrgBchno string, org_name string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, fixmedins_code string, admin_user_id int64) (string, string) {
  1393. // 生成签名
  1394. nonce := GetRandomString(32)
  1395. timestamp := time.Now().Unix()
  1396. signature := setSignature(timestamp, nonce, secret_key)
  1397. inputMessage := make(map[string]interface{})
  1398. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  1399. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  1400. } else {
  1401. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1402. }
  1403. // 生成输入报文
  1404. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1405. input := make(map[string]interface{})
  1406. inputData := make(map[string]interface{})
  1407. inputMessage["infno"] = "2205" // 交易编码
  1408. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1409. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  1410. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1411. input["data"] = inputData
  1412. inputMessage["input"] = input //交易输入
  1413. bytesData, err := json.Marshal(inputMessage)
  1414. fmt.Println(string(bytesData))
  1415. var requestLog string
  1416. requestLog = string(bytesData)
  1417. if err != nil {
  1418. fmt.Println(err.Error())
  1419. return err.Error(), ""
  1420. }
  1421. reader := bytes.NewReader(bytesData)
  1422. gdyb_url := beego.AppConfig.String("gdyb_url")
  1423. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1424. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1425. //url := gdyb_url + "2205"
  1426. var url string
  1427. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  1428. url = gdyb_url
  1429. } else {
  1430. url = gdyb_url + "2205"
  1431. }
  1432. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2205"
  1433. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2205"
  1434. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2205"
  1435. if insuplc_admdvs == "421300" {
  1436. var json2 string
  1437. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2205", string(bytesData), json2)
  1438. out, err := cmd.Output()
  1439. if err != nil {
  1440. fmt.Println("error:", err.Error())
  1441. }
  1442. fmt.Println(string(out))
  1443. return hex.EncodeToString(out), requestLog
  1444. } else {
  1445. request, err := http.NewRequest("POST", url, reader)
  1446. fmt.Println(err)
  1447. fmt.Println(request)
  1448. if err != nil {
  1449. fmt.Println(err.Error())
  1450. return err.Error(), ""
  1451. }
  1452. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1453. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1454. request.Header.Set("x-tif-signature", signature)
  1455. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1456. request.Header.Set("x-tif-nonce", nonce)
  1457. client := http.Client{}
  1458. resp, err := client.Do(request)
  1459. if err != nil {
  1460. fmt.Println(err.Error())
  1461. return err.Error(), ""
  1462. }
  1463. respBytes, err := ioutil.ReadAll(resp.Body)
  1464. if err != nil {
  1465. fmt.Println(err.Error())
  1466. return err.Error(), ""
  1467. }
  1468. str := string(respBytes)
  1469. fmt.Println(str)
  1470. return str, requestLog
  1471. }
  1472. }
  1473. // 门诊预结算
  1474. //
  1475. // func Gdyb2206(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string, total string, org_name string, doctor string, secret_key string) string {
  1476. func Gdyb2206(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string, total string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, med_type string, id_card_type int64, fulamt_ownpay_amt float64, overlmt_selfpay float64, preselfpay_amt float64, inscp_scp_amt float64, certificates int64, admin_user_id int64) (string, string) {
  1477. // 生成签名
  1478. nonce := GetRandomString(32)
  1479. timestamp := time.Now().Unix()
  1480. signature := setSignature(timestamp, nonce, secret_key)
  1481. inputMessage := make(map[string]interface{})
  1482. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  1483. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  1484. } else {
  1485. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1486. }
  1487. // 生成输入报文
  1488. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1489. input := make(map[string]interface{})
  1490. inputData := make(map[string]interface{})
  1491. inputMessage["infno"] = "2206" // 交易编码
  1492. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1493. if certificates == 3 {
  1494. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  1495. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1496. } else {
  1497. if id_card_type == 1 {
  1498. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  1499. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1500. } else if id_card_type == 4 {
  1501. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  1502. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1503. } else {
  1504. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  1505. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1506. }
  1507. }
  1508. if insuplc_admdvs == "421300" {
  1509. if med_type == "11" || med_type == "1112" || med_type == "1111" {
  1510. inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
  1511. } else if med_type == "14" {
  1512. inputData["med_type"] = "140110" // 医疗类别 11 普通门诊 12 门诊挂号
  1513. }
  1514. } else {
  1515. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  1516. }
  1517. inputData["medfee_sumamt"] = total // 医疗费总额
  1518. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  1519. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1520. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  1521. inputData["acct_used_flag"] = "0" // 个人账户使用标志 0否 1是
  1522. inputData["insutype"] = insutype // 险种类型
  1523. inputData["invono"] = "" // 发票号
  1524. input["data"] = inputData
  1525. inputMessage["input"] = input //交易输入
  1526. var requestLog string
  1527. bytesData, err := json.Marshal(inputMessage)
  1528. requestLog = string(bytesData)
  1529. fmt.Println(string(bytesData))
  1530. if err != nil {
  1531. fmt.Println(err.Error())
  1532. return err.Error(), ""
  1533. }
  1534. reader := bytes.NewReader(bytesData)
  1535. gdyb_url := beego.AppConfig.String("gdyb_url")
  1536. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1537. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1538. //url := gdyb_url + "2206"
  1539. var url string
  1540. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  1541. url = gdyb_url
  1542. } else {
  1543. url = gdyb_url + "2206"
  1544. }
  1545. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2206"
  1546. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2206"
  1547. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2206"
  1548. if insuplc_admdvs == "421300" {
  1549. var json2 string
  1550. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2206", string(bytesData), json2)
  1551. out, err := cmd.Output()
  1552. if err != nil {
  1553. fmt.Println("error:", err.Error())
  1554. }
  1555. fmt.Println(string(out))
  1556. return hex.EncodeToString(out), requestLog
  1557. } else {
  1558. request, err := http.NewRequest("POST", url, reader)
  1559. if err != nil {
  1560. fmt.Println(err.Error())
  1561. return err.Error(), ""
  1562. }
  1563. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1564. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1565. request.Header.Set("x-tif-signature", signature)
  1566. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1567. request.Header.Set("x-tif-nonce", nonce)
  1568. client := http.Client{}
  1569. resp, err := client.Do(request)
  1570. if err != nil {
  1571. fmt.Println(err.Error())
  1572. return err.Error(), ""
  1573. }
  1574. respBytes, err := ioutil.ReadAll(resp.Body)
  1575. if err != nil {
  1576. fmt.Println(err.Error())
  1577. return err.Error(), ""
  1578. }
  1579. str := string(respBytes)
  1580. fmt.Println(str)
  1581. return str, requestLog
  1582. }
  1583. }
  1584. // 门诊结算
  1585. func Gdyb2207(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string, total string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, med_type string, id_card_type int64, fulamt_ownpay_amt float64, overlmt_selfpay float64, preselfpay_amt float64, inscp_scp_amt float64, certificates int64, acct_used_flag string, token string, admin_user_id int64) (string, string) {
  1586. // 生成签名
  1587. nonce := GetRandomString(32)
  1588. timestamp := time.Now().Unix()
  1589. signature := setSignature(timestamp, nonce, secret_key)
  1590. // 生成输入报文
  1591. inputMessage := make(map[string]interface{})
  1592. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  1593. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  1594. } else {
  1595. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1596. }
  1597. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1598. input := make(map[string]interface{})
  1599. inputData := make(map[string]interface{})
  1600. inputMessage["infno"] = "2207" // 交易编码
  1601. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1602. if certificates == 3 {
  1603. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  1604. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1605. } else {
  1606. if id_card_type == 1 {
  1607. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  1608. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1609. } else if id_card_type == 4 {
  1610. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  1611. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  1612. } else {
  1613. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  1614. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1615. }
  1616. }
  1617. if med_type == "1111" || med_type == "1112" {
  1618. med_type = "11"
  1619. }
  1620. if insuplc_admdvs == "421300" {
  1621. if med_type == "11" {
  1622. inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
  1623. } else if med_type == "14" {
  1624. inputData["med_type"] = "140101" // 医疗类别 11 普通门诊 12 门诊挂号
  1625. }
  1626. } else {
  1627. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  1628. }
  1629. inputData["medfee_sumamt"] = total // 医疗费总额
  1630. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  1631. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1632. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  1633. inputData["acct_used_flag"] = acct_used_flag // 个人账户使用标志 0否 1是
  1634. inputData["insutype"] = insutype // 险种类型
  1635. inputData["invono"] = "" // 发票号
  1636. inputData["fulamt_ownpay_amt"] = fulamt_ownpay_amt //
  1637. inputData["overlmt_selfpay"] = overlmt_selfpay //
  1638. inputData["preselfpay_amt"] = preselfpay_amt //
  1639. inputData["inscp_scp_amt"] = inscp_scp_amt //
  1640. input["data"] = inputData
  1641. inputMessage["input"] = input //交易输入
  1642. bytesData, err := json.Marshal(inputMessage)
  1643. fmt.Println(string(bytesData))
  1644. if err != nil {
  1645. fmt.Println(err.Error())
  1646. return err.Error(), ""
  1647. }
  1648. reader := bytes.NewReader(bytesData)
  1649. gdyb_url := beego.AppConfig.String("gdyb_url")
  1650. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1651. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1652. //url := gdyb_url + "2207"
  1653. var url string
  1654. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  1655. url = gdyb_url
  1656. } else {
  1657. url = gdyb_url + "2207"
  1658. }
  1659. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2207"
  1660. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  1661. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  1662. if insuplc_admdvs == "421300" {
  1663. var json2 string
  1664. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2207", string(bytesData), json2)
  1665. out, err := cmd.Output()
  1666. if err != nil {
  1667. fmt.Println("error:", err.Error())
  1668. }
  1669. mjson, _ := json.Marshal(inputMessage)
  1670. str2 := string(mjson)
  1671. fmt.Println(string(out))
  1672. return hex.EncodeToString(out), str2
  1673. } else {
  1674. request, err := http.NewRequest("POST", url, reader)
  1675. if err != nil {
  1676. fmt.Println(err.Error())
  1677. return err.Error(), ""
  1678. }
  1679. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1680. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1681. request.Header.Set("x-tif-signature", signature)
  1682. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1683. request.Header.Set("x-tif-nonce", nonce)
  1684. client := http.Client{}
  1685. resp, err := client.Do(request)
  1686. if err != nil {
  1687. fmt.Println(err.Error())
  1688. return err.Error(), ""
  1689. }
  1690. respBytes, err := ioutil.ReadAll(resp.Body)
  1691. if err != nil {
  1692. fmt.Println(err.Error())
  1693. return err.Error(), ""
  1694. }
  1695. str := string(respBytes)
  1696. fmt.Println(str)
  1697. mjson, _ := json.Marshal(inputMessage)
  1698. str2 := string(mjson)
  1699. return str, str2
  1700. }
  1701. }
  1702. 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) {
  1703. // 生成签名
  1704. nonce := GetRandomString(32)
  1705. timestamp := time.Now().Unix()
  1706. signature := setSignature(timestamp, nonce, secret_key)
  1707. // 生成输入报文
  1708. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1709. input := make(map[string]interface{})
  1710. inputData := make(map[string]interface{})
  1711. inputMessage["infno"] = "2207A" // 交易编码
  1712. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1713. if certificates == 3 {
  1714. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  1715. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1716. } else {
  1717. if id_card_type == 1 {
  1718. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  1719. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1720. } else {
  1721. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  1722. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1723. }
  1724. }
  1725. if med_type == "1111" || med_type == "1112" {
  1726. med_type = "11"
  1727. }
  1728. if insuplc_admdvs == "421300" {
  1729. if med_type == "11" {
  1730. inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
  1731. } else if med_type == "14" {
  1732. inputData["med_type"] = "140101" // 医疗类别 11 普通门诊 12 门诊挂号
  1733. }
  1734. } else {
  1735. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  1736. }
  1737. inputData["medfee_sumamt"] = total // 医疗费总额
  1738. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  1739. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1740. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  1741. inputData["acct_used_flag"] = acct_used_flag // 个人账户使用标志 0否 1是
  1742. inputData["insutype"] = insutype // 险种类型
  1743. inputData["invono"] = "" // 发票号
  1744. inputData["fulamt_ownpay_amt"] = fulamt_ownpay_amt //
  1745. inputData["overlmt_selfpay"] = overlmt_selfpay //
  1746. inputData["preselfpay_amt"] = preselfpay_amt //
  1747. inputData["inscp_scp_amt"] = inscp_scp_amt //
  1748. input["data"] = inputData
  1749. inputMessage["input"] = input //交易输入
  1750. bytesData, err := json.Marshal(inputMessage)
  1751. fmt.Println(string(bytesData))
  1752. if err != nil {
  1753. fmt.Println(err.Error())
  1754. return err.Error(), ""
  1755. }
  1756. reader := bytes.NewReader(bytesData)
  1757. gdyb_url := beego.AppConfig.String("gdyb_url")
  1758. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1759. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1760. //url := gdyb_url + "2207"
  1761. var url string
  1762. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  1763. url = gdyb_url
  1764. } else {
  1765. url = gdyb_url + "2207"
  1766. }
  1767. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2207"
  1768. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  1769. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  1770. if insuplc_admdvs == "421300" {
  1771. var json2 string
  1772. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2207", string(bytesData), json2)
  1773. out, err := cmd.Output()
  1774. if err != nil {
  1775. fmt.Println("error:", err.Error())
  1776. }
  1777. mjson, _ := json.Marshal(inputMessage)
  1778. str2 := string(mjson)
  1779. fmt.Println(string(out))
  1780. return hex.EncodeToString(out), str2
  1781. } else {
  1782. request, err := http.NewRequest("POST", url, reader)
  1783. if err != nil {
  1784. fmt.Println(err.Error())
  1785. return err.Error(), ""
  1786. }
  1787. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1788. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1789. request.Header.Set("x-tif-signature", signature)
  1790. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1791. request.Header.Set("x-tif-nonce", nonce)
  1792. client := http.Client{}
  1793. resp, err := client.Do(request)
  1794. if err != nil {
  1795. fmt.Println(err.Error())
  1796. return err.Error(), ""
  1797. }
  1798. respBytes, err := ioutil.ReadAll(resp.Body)
  1799. if err != nil {
  1800. fmt.Println(err.Error())
  1801. return err.Error(), ""
  1802. }
  1803. str := string(respBytes)
  1804. fmt.Println(str)
  1805. mjson, _ := json.Marshal(inputMessage)
  1806. str2 := string(mjson)
  1807. return str, str2
  1808. }
  1809. }
  1810. // 门诊结算撤销
  1811. func Gdyb2208(psnNo string, mdtrtId string, setlId string, org_name string, doctor string, secret_key string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, admin_user_id int64) (string, string) {
  1812. // 生成签名
  1813. nonce := GetRandomString(32)
  1814. timestamp := time.Now().Unix()
  1815. signature := setSignature(timestamp, nonce, secret_key)
  1816. inputMessage := make(map[string]interface{})
  1817. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  1818. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  1819. } else {
  1820. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1821. }
  1822. // 生成输入报文
  1823. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1824. input := make(map[string]interface{})
  1825. inputData := make(map[string]interface{})
  1826. inputMessage["infno"] = "2208" // 交易编码
  1827. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1828. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1829. inputData["setl_id"] = setlId // 结算 ID
  1830. input["data"] = inputData
  1831. inputMessage["input"] = input //交易输入
  1832. bytesData, err := json.Marshal(inputMessage)
  1833. fmt.Println(string(bytesData))
  1834. if err != nil {
  1835. fmt.Println(err.Error())
  1836. return err.Error(), ""
  1837. }
  1838. reader := bytes.NewReader(bytesData)
  1839. gdyb_url := beego.AppConfig.String("gdyb_url")
  1840. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1841. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1842. //url := gdyb_url + "2208"
  1843. var url string
  1844. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  1845. url = gdyb_url
  1846. } else {
  1847. url = gdyb_url + "2208"
  1848. }
  1849. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2208"
  1850. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2208"
  1851. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2208"
  1852. if insuplc_admdvs == "421300" {
  1853. var json2 string
  1854. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2208", string(bytesData), json2)
  1855. out, err := cmd.Output()
  1856. if err != nil {
  1857. fmt.Println("error:", err.Error())
  1858. }
  1859. mjson, _ := json.Marshal(inputMessage)
  1860. str2 := string(mjson)
  1861. fmt.Println(string(out))
  1862. return hex.EncodeToString(out), str2
  1863. } else {
  1864. request, err := http.NewRequest("POST", url, reader)
  1865. if err != nil {
  1866. fmt.Println(err.Error())
  1867. return err.Error(), ""
  1868. }
  1869. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1870. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1871. request.Header.Set("x-tif-signature", signature)
  1872. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1873. request.Header.Set("x-tif-nonce", nonce)
  1874. client := http.Client{}
  1875. resp, err := client.Do(request)
  1876. if err != nil {
  1877. fmt.Println(err.Error())
  1878. return err.Error(), ""
  1879. }
  1880. respBytes, err := ioutil.ReadAll(resp.Body)
  1881. if err != nil {
  1882. fmt.Println(err.Error())
  1883. return err.Error(), ""
  1884. }
  1885. str := string(respBytes)
  1886. fmt.Println(str)
  1887. mjson, _ := json.Marshal(inputMessage)
  1888. str2 := string(mjson)
  1889. return str, str2
  1890. }
  1891. }
  1892. // 确认订单
  1893. func Gdyb6201(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, order models.HisOrder) string {
  1894. // 生成签名
  1895. nonce := GetRandomString(32)
  1896. timestamp := time.Now().Unix()
  1897. signature := setSignature(timestamp, nonce, secret_key)
  1898. // 生成输入报文
  1899. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1900. input := make(map[string]interface{})
  1901. inputData := make(map[string]interface{})
  1902. inputMessage["infno"] = "6201" // 交易编码
  1903. inputData["mdtrt_id"] = order.MdtrtId
  1904. inputData["chrg_bchno"] = order.Number
  1905. inputData["psn_no"] = order.PsnNo
  1906. inputData["psn_name"] = order.PsnName
  1907. inputData["psn_cert_type"] = order.PsnCertType
  1908. inputData["certno"] = order.Certno
  1909. inputData["insutype"] = order.Insutype
  1910. inputData["med_type"] = order.MedType
  1911. inputData["medfee_sumamt"] = order.MedfeeSumamt
  1912. inputData["fulamt_ownpay_amt"] = order.FulamtOwnpayAmt
  1913. inputData["overlmt_selfpay"] = order.OverlmtSelfPay
  1914. inputData["preselfpay_amt"] = order.PreselfpayAmt
  1915. inputData["inscp_scp_amt"] = order.InscpScpAmt
  1916. inputData["act_pay_dedc"] = order.ActPayDedc
  1917. inputData["hifp_pay"] = order.HifpPay
  1918. inputData["pool_prop_selfpay"] = order.PoolPropSelfpay
  1919. inputData["cvlserv_pay"] = order.CvlservPay
  1920. inputData["hifes_pay"] = order.HifesPay
  1921. inputData["hifmi_pay"] = order.HifmiPay
  1922. inputData["hifob_pay"] = order.HifobPay
  1923. inputData["maf_pay"] = order.MafPay
  1924. inputData["oth_pay"] = order.OthPay
  1925. inputData["fund_pay_sumamt"] = order.FundPaySumamt
  1926. inputData["psn_part_amt"] = order.PsnPartAmt
  1927. inputData["acct_pay"] = order.AcctPay
  1928. inputData["psn_cash_pay"] = order.PsnCashPay
  1929. inputData["hosp_part_amt"] = order.HospPartAmt
  1930. inputData["acct_mulaid_pay"] = order.AcctMulaidPay
  1931. input["data"] = inputData
  1932. inputMessage["input"] = input //交易输入
  1933. bytesData, err := json.Marshal(inputMessage)
  1934. fmt.Println(string(bytesData))
  1935. if err != nil {
  1936. fmt.Println(err.Error())
  1937. return err.Error()
  1938. }
  1939. reader := bytes.NewReader(bytesData)
  1940. gdyb_url := beego.AppConfig.String("gdyb_url")
  1941. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1942. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1943. url := gdyb_url + "6201"
  1944. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/6201"
  1945. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/6201"
  1946. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  1947. request, err := http.NewRequest("POST", url, reader)
  1948. if err != nil {
  1949. fmt.Println(err.Error())
  1950. return err.Error()
  1951. }
  1952. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1953. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1954. request.Header.Set("x-tif-signature", signature)
  1955. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1956. request.Header.Set("x-tif-nonce", nonce)
  1957. client := http.Client{}
  1958. resp, err := client.Do(request)
  1959. if err != nil {
  1960. fmt.Println(err.Error())
  1961. return err.Error()
  1962. }
  1963. respBytes, err := ioutil.ReadAll(resp.Body)
  1964. if err != nil {
  1965. fmt.Println(err.Error())
  1966. return err.Error()
  1967. }
  1968. str := string(respBytes)
  1969. fmt.Println(str)
  1970. return str
  1971. }
  1972. // 医药机构费用结算对总账 func Gdyb3201( org_name string, doctor string, secret_key string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) string {
  1973. func Gdyb3201(baseParams models.BaseParams, businessParams models.BusinessParams, admin_user_id int64) string {
  1974. fmt.Println("11222333-----")
  1975. fmt.Println(baseParams)
  1976. fmt.Println(businessParams)
  1977. // 生成签名
  1978. nonce := GetRandomString(32)
  1979. timestamp := time.Now().Unix()
  1980. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1981. inputMessage := make(map[string]interface{})
  1982. if baseParams.MdtrtareaAdmvs == "450721" || baseParams.MdtrtareaAdmvs == "450127" {
  1983. inputMessage = SetInputMessage1111(nonce, timestamp, baseParams.OrgName, admin_user_id, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.Doctor)
  1984. } else {
  1985. inputMessage = SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1986. //inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1987. }
  1988. // 生成输入报文
  1989. input := make(map[string]interface{})
  1990. inputData := make(map[string]interface{})
  1991. inputMessage["infno"] = "3201" // 交易编码
  1992. inputData["insutype"] = businessParams.Insutype // 险种
  1993. if baseParams.MdtrtareaAdmvs == "450721" {
  1994. if businessParams.Insutype == "390" {
  1995. inputData["clr_type"] = "99971" // 就诊 ID(来自2201接口返回)
  1996. } else {
  1997. inputData["clr_type"] = "99970" // 就诊 ID(来自2201接口返回)
  1998. }
  1999. } else {
  2000. inputData["clr_type"] = businessParams.ClrType // 就诊 ID(来自2201接口返回)
  2001. }
  2002. inputData["setl_optins"] = businessParams.SetlOptins // 结算经办机构
  2003. inputData["stmt_begndate"] = businessParams.StmtBegndate // 对帐开始时间
  2004. inputData["stmt_enddate"] = businessParams.StmtEnddate //对帐结束时间
  2005. inputData["medfee_sumamt"] = businessParams.MedfeeSumamt //医疗费总额
  2006. inputData["fund_pay_sumamt"] = businessParams.FundPaySumamt //基金支付总额
  2007. inputData["acct_pay"] = businessParams.AcctPay //个人账户支付金额
  2008. inputData["fixmedins_setl_cnt"] = businessParams.FixmedinsSetlCnt //定点医药机构结算笔数
  2009. inputData["refd_setl_flag"] = 0 // 就诊 ID(来自2201接口返回)
  2010. input["data"] = inputData
  2011. inputMessage["input"] = input //交易输入
  2012. bytesData, err := json.Marshal(inputMessage)
  2013. fmt.Println(string(bytesData))
  2014. if err != nil {
  2015. fmt.Println(err.Error())
  2016. return err.Error()
  2017. }
  2018. reader := bytes.NewReader(bytesData)
  2019. gdyb_url := beego.AppConfig.String("gdyb_url")
  2020. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2021. var url string
  2022. if baseParams.MdtrtareaAdmvs == "150499" || baseParams.MdtrtareaAdmvs == "450721" {
  2023. url = gdyb_url
  2024. } else {
  2025. url = gdyb_url + "3201"
  2026. }
  2027. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2028. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3201"
  2029. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3201"
  2030. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3201"
  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. type Params struct {
  2057. FileName string `json:"file_name"` //产品ID
  2058. In []byte `json:"in"` //
  2059. FixmedinsCode string `json:"fixmedins_code"` //调用环境生产为1 沙盒2
  2060. }
  2061. // 文件上传
  2062. func Gdyb9101(baseParams models.BaseParams, file_name string, file_byte []byte) string {
  2063. // 生成签名
  2064. nonce := GetRandomString(32)
  2065. timestamp := time.Now().Unix()
  2066. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  2067. //buf := new(bytes.Buffer)
  2068. //buf.ReadFrom(strings.NewReader(string(file_byte)))
  2069. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  2070. input := make(map[string]interface{})
  2071. inputData := make(map[string]interface{})
  2072. inputMessage["infno"] = "9101" // 交易编码
  2073. inputData["file_name"] = file_name //文件名
  2074. inputData["in"] = file_byte //文件数据
  2075. inputData["fixmedins_code"] = baseParams.FixmedinsCode //编码
  2076. input["fsUploadIn"] = inputData
  2077. inputMessage["input"] = input //交易输入
  2078. bytesData, err := json.Marshal(inputMessage)
  2079. fmt.Println(string(bytesData))
  2080. if err != nil {
  2081. fmt.Println(err.Error())
  2082. return err.Error()
  2083. }
  2084. reader := bytes.NewReader(bytesData)
  2085. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/9101"
  2086. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9101"
  2087. gdyb_url := beego.AppConfig.String("gdyb_url")
  2088. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2089. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2090. url := gdyb_url + "9101"
  2091. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9101"
  2092. request, err := http.NewRequest("POST", url, reader)
  2093. if err != nil {
  2094. fmt.Println(err.Error())
  2095. return err.Error()
  2096. }
  2097. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2098. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2099. request.Header.Set("x-tif-signature", signature)
  2100. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2101. request.Header.Set("x-tif-nonce", nonce)
  2102. client := http.Client{}
  2103. resp, err := client.Do(request)
  2104. if err != nil {
  2105. fmt.Println(err.Error())
  2106. return err.Error()
  2107. }
  2108. respBytes, err := ioutil.ReadAll(resp.Body)
  2109. if err != nil {
  2110. fmt.Println(err.Error())
  2111. return err.Error()
  2112. }
  2113. str := string(respBytes)
  2114. fmt.Println(str)
  2115. return str
  2116. }
  2117. func Gdyb9102(baseParams models.BaseParams, file_name string, file_qury_no string) string {
  2118. // 生成签名
  2119. nonce := GetRandomString(32)
  2120. timestamp := time.Now().Unix()
  2121. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  2122. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  2123. input := make(map[string]interface{})
  2124. inputData := make(map[string]interface{})
  2125. inputMessage["infno"] = "9102" // 交易编码
  2126. inputData["file_name"] = file_name //文件名
  2127. inputData["file_qury_no"] = file_qury_no //文件数据
  2128. inputData["fixmedins_code"] = baseParams.FixmedinsCode //编码
  2129. input["fsDownloadIn"] = inputData
  2130. inputMessage["input"] = input //交易输入
  2131. bytesData, err := json.Marshal(inputMessage)
  2132. fmt.Println(string(bytesData))
  2133. if err != nil {
  2134. fmt.Println(err.Error())
  2135. return err.Error()
  2136. }
  2137. reader := bytes.NewReader(bytesData)
  2138. gdyb_url := beego.AppConfig.String("gdyb_url")
  2139. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2140. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2141. url := gdyb_url + "9102"
  2142. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/9102"
  2143. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9102"
  2144. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9102"
  2145. request, err := http.NewRequest("POST", url, reader)
  2146. if err != nil {
  2147. fmt.Println(err.Error())
  2148. return err.Error()
  2149. }
  2150. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2151. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2152. request.Header.Set("x-tif-signature", signature)
  2153. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2154. request.Header.Set("x-tif-nonce", nonce)
  2155. client := http.Client{}
  2156. resp, err := client.Do(request)
  2157. if err != nil {
  2158. fmt.Println(err.Error())
  2159. return err.Error()
  2160. }
  2161. respBytes, err := ioutil.ReadAll(resp.Body)
  2162. if err != nil {
  2163. fmt.Println(err.Error())
  2164. return err.Error()
  2165. }
  2166. str := string(respBytes)
  2167. enc := mahonia.NewEncoder("gbk")
  2168. //output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  2169. fmt.Println(enc.ConvertString(str))
  2170. return str
  2171. }
  2172. func Gdyb3202(baseParams models.BaseParams, businessParams models.BusinessParams) string {
  2173. // 生成签名
  2174. nonce := GetRandomString(32)
  2175. timestamp := time.Now().Unix()
  2176. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  2177. // 生成输入报文
  2178. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  2179. input := make(map[string]interface{})
  2180. inputData := make(map[string]interface{})
  2181. inputMessage["infno"] = "3202" // 交易编码
  2182. inputData["file_qury_no"] = businessParams.FileQuryNo // 险种
  2183. inputData["setl_optins"] = baseParams.InsuplcAdmdvs // 结算经办机构
  2184. inputData["stmt_begndate"] = businessParams.StmtBegndate // 对帐开始时间
  2185. inputData["stmt_enddate"] = businessParams.StmtEnddate //对帐结束时间
  2186. inputData["medfee_sumamt"] = businessParams.MedfeeSumamt //医疗费总额
  2187. inputData["fund_pay_sumamt"] = businessParams.FundPaySumamt //基金支付总额
  2188. inputData["cash_payamt"] = businessParams.CashPayamt //现金支付金额
  2189. inputData["fixmedins_setl_cnt"] = businessParams.FixmedinsSetlCnt //定点医药机构结算笔数
  2190. inputData["clr_type"] = "11" // 就诊 ID(来自2201接口返回)
  2191. inputData["refd_setl_flag"] = 1 // 就诊 ID(来自2201接口返回)
  2192. input["data"] = inputData
  2193. inputMessage["input"] = input //交易输入
  2194. bytesData, err := json.Marshal(inputMessage)
  2195. fmt.Println(string(bytesData))
  2196. if err != nil {
  2197. fmt.Println(err.Error())
  2198. return err.Error()
  2199. }
  2200. reader := bytes.NewReader(bytesData)
  2201. gdyb_url := beego.AppConfig.String("gdyb_url")
  2202. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2203. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2204. url := gdyb_url + "3202"
  2205. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3202"
  2206. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3202"
  2207. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3202"
  2208. request, err := http.NewRequest("POST", url, reader)
  2209. if err != nil {
  2210. fmt.Println(err.Error())
  2211. return err.Error()
  2212. }
  2213. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2214. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2215. request.Header.Set("x-tif-signature", signature)
  2216. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2217. request.Header.Set("x-tif-nonce", nonce)
  2218. client := http.Client{}
  2219. resp, err := client.Do(request)
  2220. if err != nil {
  2221. fmt.Println(err.Error())
  2222. return err.Error()
  2223. }
  2224. respBytes, err := ioutil.ReadAll(resp.Body)
  2225. if err != nil {
  2226. fmt.Println(err.Error())
  2227. return err.Error()
  2228. }
  2229. str := string(respBytes)
  2230. fmt.Println(str)
  2231. return str
  2232. }
  2233. func Gdyb5203(baseParams models.BaseParams, businessParams models.BusinessParams) string {
  2234. fmt.Println("~~~~~~1")
  2235. fmt.Println(baseParams)
  2236. fmt.Println(businessParams)
  2237. // 生成签名
  2238. nonce := GetRandomString(32)
  2239. timestamp := time.Now().Unix()
  2240. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  2241. fmt.Println("~~~~~~2")
  2242. // 生成输入报文
  2243. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  2244. input := make(map[string]interface{})
  2245. inputData := make(map[string]interface{})
  2246. inputMessage["infno"] = "5203" // 交易编码
  2247. inputData["psn_no"] = businessParams.PsnNo
  2248. inputData["setl_id"] = businessParams.SetlId
  2249. inputData["mdtrt_id"] = businessParams.MdtrtId
  2250. input["data"] = inputData
  2251. inputMessage["input"] = input //交易输入
  2252. bytesData, err := json.Marshal(inputMessage)
  2253. fmt.Println(string(bytesData))
  2254. fmt.Println("~~~~~~")
  2255. fmt.Println("~~~~~~")
  2256. fmt.Println(string(bytesData))
  2257. if err != nil {
  2258. fmt.Println(err.Error())
  2259. return err.Error()
  2260. }
  2261. reader := bytes.NewReader(bytesData)
  2262. gdyb_url := beego.AppConfig.String("gdyb_url")
  2263. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2264. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2265. //url := gdyb_url + "5203"
  2266. var url string
  2267. if baseParams.FixmedinsCode == "H15049901371" || baseParams.MdtrtareaAdmvs == "450127" || baseParams.MdtrtareaAdmvs == "450721" {
  2268. url = gdyb_url
  2269. } else {
  2270. url = gdyb_url + "5203"
  2271. }
  2272. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5203"
  2273. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
  2274. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
  2275. request, err := http.NewRequest("POST", url, reader)
  2276. if err != nil {
  2277. fmt.Println(err.Error())
  2278. return err.Error()
  2279. }
  2280. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2281. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2282. request.Header.Set("x-tif-signature", signature)
  2283. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2284. request.Header.Set("x-tif-nonce", nonce)
  2285. client := http.Client{}
  2286. resp, err := client.Do(request)
  2287. if err != nil {
  2288. fmt.Println(err.Error())
  2289. return err.Error()
  2290. }
  2291. respBytes, err := ioutil.ReadAll(resp.Body)
  2292. if err != nil {
  2293. fmt.Println(err.Error())
  2294. return err.Error()
  2295. }
  2296. str := string(respBytes)
  2297. fmt.Println(str)
  2298. return str
  2299. }
  2300. func Gdyb5204(baseParams models.BaseParams, businessParams models.BusinessParams) string {
  2301. // 生成签名
  2302. nonce := GetRandomString(32)
  2303. timestamp := time.Now().Unix()
  2304. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  2305. // 生成输入报文
  2306. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  2307. input := make(map[string]interface{})
  2308. inputData := make(map[string]interface{})
  2309. inputMessage["infno"] = "5204" // 交易编码
  2310. inputData["psn_no"] = businessParams.PsnNo
  2311. inputData["setl_id"] = businessParams.SetlId
  2312. inputData["mdtrt_id"] = businessParams.MdtrtId
  2313. input["data"] = inputData
  2314. inputMessage["input"] = input //交易输入
  2315. bytesData, err := json.Marshal(inputMessage)
  2316. fmt.Println(string(bytesData))
  2317. if err != nil {
  2318. fmt.Println(err.Error())
  2319. return err.Error()
  2320. }
  2321. reader := bytes.NewReader(bytesData)
  2322. gdyb_url := beego.AppConfig.String("gdyb_url")
  2323. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2324. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2325. //url := gdyb_url + "5203"
  2326. var url string
  2327. if baseParams.FixmedinsCode == "H15049901371" || baseParams.MdtrtareaAdmvs == "450127" || baseParams.MdtrtareaAdmvs == "450721" {
  2328. url = gdyb_url
  2329. } else {
  2330. url = gdyb_url + "5204"
  2331. }
  2332. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5203"
  2333. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
  2334. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
  2335. request, err := http.NewRequest("POST", url, reader)
  2336. if err != nil {
  2337. fmt.Println(err.Error())
  2338. return err.Error()
  2339. }
  2340. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2341. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2342. request.Header.Set("x-tif-signature", signature)
  2343. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2344. request.Header.Set("x-tif-nonce", nonce)
  2345. client := http.Client{}
  2346. resp, err := client.Do(request)
  2347. if err != nil {
  2348. fmt.Println(err.Error())
  2349. return err.Error()
  2350. }
  2351. respBytes, err := ioutil.ReadAll(resp.Body)
  2352. if err != nil {
  2353. fmt.Println(err.Error())
  2354. return err.Error()
  2355. }
  2356. str := string(respBytes)
  2357. fmt.Println(str)
  2358. return str
  2359. }
  2360. func Gdyb2001(baseParams models.BaseParams, psn_no string, insutype string, med_type string) string {
  2361. if med_type == "1111" || med_type == "1112" {
  2362. med_type = "11"
  2363. }
  2364. // 生成签名
  2365. nonce := GetRandomString(32)
  2366. timestamp := time.Now().Unix()
  2367. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  2368. // 生成输入报文
  2369. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  2370. input := make(map[string]interface{})
  2371. inputData := make(map[string]interface{})
  2372. inputMessage["infno"] = "2001" // 交易编码
  2373. inputData["psn_no"] = psn_no
  2374. inputData["insutype"] = insutype
  2375. inputData["fixmedins_code"] = baseParams.FixmedinsCode
  2376. inputData["med_type"] = med_type
  2377. inputData["begntime"] = "2021-01-01 00:00:00"
  2378. input["data"] = inputData
  2379. inputMessage["input"] = input //交易输入
  2380. bytesData, err := json.Marshal(inputMessage)
  2381. fmt.Println(string(bytesData))
  2382. if err != nil {
  2383. fmt.Println(err.Error())
  2384. return err.Error()
  2385. }
  2386. reader := bytes.NewReader(bytesData)
  2387. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3301"
  2388. gdyb_url := beego.AppConfig.String("gdyb_url")
  2389. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2390. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2391. url := gdyb_url
  2392. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3301"
  2393. request, err := http.NewRequest("POST", url, reader)
  2394. if err != nil {
  2395. fmt.Println(err.Error())
  2396. return err.Error()
  2397. }
  2398. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2399. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2400. request.Header.Set("x-tif-signature", signature)
  2401. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2402. request.Header.Set("x-tif-nonce", nonce)
  2403. client := http.Client{}
  2404. resp, err := client.Do(request)
  2405. if err != nil {
  2406. fmt.Println(err.Error())
  2407. return err.Error()
  2408. }
  2409. respBytes, err := ioutil.ReadAll(resp.Body)
  2410. if err != nil {
  2411. fmt.Println(err.Error())
  2412. return err.Error()
  2413. }
  2414. str := string(respBytes)
  2415. fmt.Println(str)
  2416. return str
  2417. }
  2418. func Gdyb3301(baseParams models.BaseParams, name string, codg string, list_type_code string, start_time string, ent_time string, list_type string, admin_user_id int64) string {
  2419. // 生成签名
  2420. nonce := GetRandomString(32)
  2421. timestamp := time.Now().Unix()
  2422. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  2423. inputMessage := make(map[string]interface{})
  2424. if baseParams.MdtrtareaAdmvs == "450721" {
  2425. inputMessage = SetInputMessage1111(nonce, timestamp, baseParams.OrgName, admin_user_id, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.Doctor)
  2426. //inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs,doctor)
  2427. } else {
  2428. inputMessage = SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  2429. //inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2430. }
  2431. // 生成输入报文
  2432. input := make(map[string]interface{})
  2433. //input2 := make([]map[string]interface{})
  2434. feedetail := make([]map[string]interface{}, 0)
  2435. inputData := make(map[string]interface{})
  2436. inputMessage["infno"] = "3301A" // 交易编码
  2437. inputData["fixmedins_hilist_id"] = codg
  2438. inputData["fixmedins_hilist_name"] = name
  2439. inputData["list_type"] = list_type
  2440. inputData["med_list_codg"] = codg
  2441. inputData["begndate"] = start_time
  2442. inputData["enddate"] = ent_time
  2443. inputData["aprvno"] = ""
  2444. inputData["dosform"] = ""
  2445. inputData["exct_cont"] = ""
  2446. inputData["item_cont"] = ""
  2447. inputData["prcunt"] = ""
  2448. inputData["spec"] = ""
  2449. inputData["pacspec"] = ""
  2450. inputData["memo"] = ""
  2451. feedetail = append(feedetail, inputData)
  2452. input["data"] = feedetail
  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/3301"
  2462. //
  2463. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3301"
  2464. gdyb_url := beego.AppConfig.String("gdyb_url")
  2465. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2466. url := ""
  2467. if baseParams.MdtrtareaAdmvs == "450721" {
  2468. url = gdyb_url
  2469. } else {
  2470. url = gdyb_url + "3301"
  2471. }
  2472. request, err := http.NewRequest("POST", url, reader)
  2473. if err != nil {
  2474. fmt.Println(err.Error())
  2475. return err.Error()
  2476. }
  2477. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2478. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2479. request.Header.Set("x-tif-signature", signature)
  2480. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2481. request.Header.Set("x-tif-nonce", nonce)
  2482. client := http.Client{}
  2483. resp, err := client.Do(request)
  2484. if err != nil {
  2485. fmt.Println(err.Error())
  2486. return err.Error()
  2487. }
  2488. respBytes, err := ioutil.ReadAll(resp.Body)
  2489. if err != nil {
  2490. fmt.Println(err.Error())
  2491. return err.Error()
  2492. }
  2493. str := string(respBytes)
  2494. fmt.Println(str)
  2495. return str
  2496. }
  2497. func Gdyb3302(baseParams *models.BaseParams, name string, codg string, list_type_code string) string {
  2498. // 生成签名
  2499. nonce := GetRandomString(32)
  2500. timestamp := time.Now().Unix()
  2501. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  2502. // 生成输入报文
  2503. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  2504. input := make(map[string]interface{})
  2505. inputData := make(map[string]interface{})
  2506. inputMessage["infno"] = "3302" // 交易编码
  2507. inputData["fixmedins_code"] = baseParams.FixmedinsCode
  2508. inputData["fixmedins_hilist_id"] = codg
  2509. inputData["list_type"] = list_type_code
  2510. inputData["med_list_codg"] = codg
  2511. input["data"] = inputData
  2512. inputMessage["input"] = input //交易输入
  2513. bytesData, err := json.Marshal(inputMessage)
  2514. fmt.Println(string(bytesData))
  2515. if err != nil {
  2516. fmt.Println(err.Error())
  2517. return err.Error()
  2518. }
  2519. reader := bytes.NewReader(bytesData)
  2520. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3302"
  2521. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3302"
  2522. gdyb_url := beego.AppConfig.String("gdyb_url")
  2523. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2524. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2525. url := gdyb_url + "3302"
  2526. request, err := http.NewRequest("POST", url, reader)
  2527. if err != nil {
  2528. fmt.Println(err.Error())
  2529. return err.Error()
  2530. }
  2531. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2532. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2533. request.Header.Set("x-tif-signature", signature)
  2534. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2535. request.Header.Set("x-tif-nonce", nonce)
  2536. client := http.Client{}
  2537. resp, err := client.Do(request)
  2538. if err != nil {
  2539. fmt.Println(err.Error())
  2540. return err.Error()
  2541. }
  2542. respBytes, err := ioutil.ReadAll(resp.Body)
  2543. if err != nil {
  2544. fmt.Println(err.Error())
  2545. return err.Error()
  2546. }
  2547. str := string(respBytes)
  2548. fmt.Println(str)
  2549. return str
  2550. }
  2551. func Gdyb2505(psnNo string, doctor string, org_name string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, start_time string, end_time string, admin_user_id int64) string {
  2552. // 生成签名
  2553. nonce := GetRandomString(32)
  2554. timestamp := time.Now().Unix()
  2555. signature := setSignature(timestamp, nonce, secret_key)
  2556. inputMessage := make(map[string]interface{})
  2557. //tempTime := time.Unix(timestamp, 0)
  2558. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2559. // 生成输入报文
  2560. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  2561. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  2562. } else {
  2563. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2564. }
  2565. // 生成输入报文
  2566. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2567. input := make(map[string]interface{})
  2568. inputData := make(map[string]interface{})
  2569. inputMessage["infno"] = "2505"
  2570. inputData["psn_no"] = psnNo
  2571. inputData["biz_appy_type"] = "01"
  2572. inputData["begndate"] = start_time
  2573. inputData["enddate"] = end_time
  2574. inputData["fixmedins_code"] = fixmedins_code
  2575. inputData["fixmedins_name"] = org_name
  2576. inputData["tel"] = ""
  2577. inputData["addr"] = ""
  2578. inputData["agnter_name"] = ""
  2579. inputData["agnter_cert_type"] = ""
  2580. inputData["agnter_certno"] = ""
  2581. inputData["agnter_tel"] = ""
  2582. inputData["agnter_addr"] = ""
  2583. inputData["agnter_rlts"] = ""
  2584. inputData["fix_srt_no"] = "1"
  2585. inputData["memo"] = ""
  2586. input["data"] = inputData
  2587. inputMessage["input"] = input //交易输入
  2588. bytesData, err := json.Marshal(inputMessage)
  2589. if err != nil {
  2590. fmt.Println(err.Error())
  2591. return err.Error()
  2592. }
  2593. reader := bytes.NewReader(bytesData)
  2594. //fmt.Println(String(bytesData))
  2595. fmt.Println(string(bytesData))
  2596. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2505"
  2597. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2505"
  2598. gdyb_url := beego.AppConfig.String("gdyb_url")
  2599. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2600. url := ""
  2601. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  2602. url = gdyb_url
  2603. } else {
  2604. url = gdyb_url + "2505"
  2605. }
  2606. request, err := http.NewRequest("POST", url, reader)
  2607. if err != nil {
  2608. fmt.Println(err.Error())
  2609. return err.Error()
  2610. }
  2611. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2612. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2613. request.Header.Set("x-tif-signature", signature)
  2614. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2615. request.Header.Set("x-tif-nonce", nonce)
  2616. client := http.Client{}
  2617. resp, err := client.Do(request)
  2618. if err != nil {
  2619. fmt.Println(err.Error())
  2620. return err.Error()
  2621. }
  2622. respBytes, err := ioutil.ReadAll(resp.Body)
  2623. if err != nil {
  2624. fmt.Println(err.Error())
  2625. return err.Error()
  2626. }
  2627. str := string(respBytes)
  2628. fmt.Println(str)
  2629. return str
  2630. }
  2631. 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 {
  2632. // 生成签名
  2633. nonce := GetRandomString(32)
  2634. timestamp := time.Now().Unix()
  2635. signature := setSignature(timestamp, nonce, secret_key)
  2636. // 生成输入报文
  2637. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2638. input := make(map[string]interface{})
  2639. inputData := make(map[string]interface{})
  2640. inputMessage["infno"] = "2506"
  2641. inputData["psn_no"] = psnNo
  2642. inputData["trt_dcla_detl_sn"] = trt_dcla_detl_sn
  2643. inputData["memo"] = ""
  2644. input["data"] = inputData
  2645. inputMessage["input"] = input //交易输入
  2646. bytesData, err := json.Marshal(inputMessage)
  2647. fmt.Println(string(bytesData))
  2648. if err != nil {
  2649. fmt.Println(err.Error())
  2650. return err.Error()
  2651. }
  2652. reader := bytes.NewReader(bytesData)
  2653. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2506"
  2654. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2506"
  2655. gdyb_url := beego.AppConfig.String("gdyb_url")
  2656. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2657. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2658. url := gdyb_url + "2506"
  2659. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  2660. request, err := http.NewRequest("POST", url, reader)
  2661. if err != nil {
  2662. fmt.Println(err.Error())
  2663. return err.Error()
  2664. }
  2665. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2666. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2667. request.Header.Set("x-tif-signature", signature)
  2668. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2669. request.Header.Set("x-tif-nonce", nonce)
  2670. client := http.Client{}
  2671. resp, err := client.Do(request)
  2672. if err != nil {
  2673. fmt.Println(err.Error())
  2674. return err.Error()
  2675. }
  2676. respBytes, err := ioutil.ReadAll(resp.Body)
  2677. if err != nil {
  2678. fmt.Println(err.Error())
  2679. return err.Error()
  2680. }
  2681. str := string(respBytes)
  2682. fmt.Println(str)
  2683. return str
  2684. }
  2685. 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 {
  2686. // 生成签名
  2687. nonce := GetRandomString(32)
  2688. timestamp := time.Now().Unix()
  2689. signature := setSignature(timestamp, nonce, secret_key)
  2690. //tempTime := time.Unix(timestamp, 0)
  2691. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2692. //timeFormatTwo := tempTime.Format("2006-01-02")
  2693. //t := time.Now()
  2694. //last := time.Date(t.Year(), time.December, 31, 0, 0, 0, 0, time.UTC)
  2695. //tm := time.Unix(last.Unix(), 0)
  2696. // 生成输入报文
  2697. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2698. input := make(map[string]interface{})
  2699. inputData := make(map[string]interface{})
  2700. inputMessage["infno"] = "2503" // 交易编码
  2701. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  2702. inputData["insutype"] = insutype // 险种类型(来自1101接口返回)
  2703. inputData["opsp_dise_code"] = sick_code // 险种类型(来自1101接口返回)
  2704. inputData["opsp_dise_name"] = sick_name // 险种类型(来自1101接口返回)
  2705. inputData["insu_optins"] = insuplc_admdvs // 险种类型(来自1101接口返回)
  2706. inputData["ide_fixmedins_no"] = hospital_code // 险种类型(来自1101接口返回)
  2707. inputData["ide_fixmedins_name"] = hospital_name // 险种类型(来自1101接口返回)
  2708. inputData["hosp_ide_date"] = check_time // 险种类型(来自1101接口返回)
  2709. inputData["diag_dr_codg"] = doctor_id // 开始时间
  2710. inputData["diag_dr_name"] = doctor // 开始时间
  2711. inputData["begndate"] = start_time // 医师编码
  2712. inputData["tel"] = "" // 医师编码
  2713. inputData["addr"] = "" // 医师编码
  2714. inputData["enddate"] = end_time // 医师编码
  2715. input["data"] = inputData
  2716. inputMessage["input"] = input //交易输入
  2717. bytesData, err := json.Marshal(inputMessage)
  2718. fmt.Println(string(bytesData))
  2719. if err != nil {
  2720. fmt.Println(err.Error())
  2721. return err.Error()
  2722. }
  2723. reader := bytes.NewReader(bytesData)
  2724. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2503"
  2725. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2503"
  2726. gdyb_url := beego.AppConfig.String("gdyb_url")
  2727. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2728. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2729. //url := gdyb_url + "2503"
  2730. var url string
  2731. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450721" {
  2732. url = gdyb_url
  2733. } else {
  2734. url = gdyb_url + "2503"
  2735. }
  2736. request, err := http.NewRequest("POST", url, reader)
  2737. if err != nil {
  2738. fmt.Println(err.Error())
  2739. return err.Error()
  2740. }
  2741. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2742. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2743. request.Header.Set("x-tif-signature", signature)
  2744. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2745. request.Header.Set("x-tif-nonce", nonce)
  2746. client := http.Client{}
  2747. resp, err := client.Do(request)
  2748. if err != nil {
  2749. fmt.Println(err.Error())
  2750. return err.Error()
  2751. }
  2752. respBytes, err := ioutil.ReadAll(resp.Body)
  2753. if err != nil {
  2754. fmt.Println(err.Error())
  2755. return err.Error()
  2756. }
  2757. str := string(respBytes)
  2758. fmt.Println(str)
  2759. return str
  2760. }
  2761. 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 {
  2762. // 生成签名
  2763. nonce := GetRandomString(32)
  2764. timestamp := time.Now().Unix()
  2765. signature := setSignature(timestamp, nonce, secret_key)
  2766. // 生成输入报文
  2767. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2768. input := make(map[string]interface{})
  2769. inputData := make(map[string]interface{})
  2770. inputMessage["infno"] = "2504" // 交易编码
  2771. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  2772. inputData["trt_dcla_detl_sn"] = trt_dcla_detl_sn // 人员编号 (来自1101接口返回)
  2773. inputData["memo"] = "撤销备案" // 人员编号 (来自1101接口返回)
  2774. input["data"] = inputData
  2775. inputMessage["input"] = input //交易输入
  2776. bytesData, err := json.Marshal(inputMessage)
  2777. fmt.Println(string(bytesData))
  2778. if err != nil {
  2779. fmt.Println(err.Error())
  2780. return err.Error()
  2781. }
  2782. reader := bytes.NewReader(bytesData)
  2783. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2504"
  2784. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2504"
  2785. gdyb_url := beego.AppConfig.String("gdyb_url")
  2786. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2787. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2788. url := gdyb_url + "2504"
  2789. request, err := http.NewRequest("POST", url, reader)
  2790. if err != nil {
  2791. fmt.Println(err.Error())
  2792. return err.Error()
  2793. }
  2794. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2795. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2796. request.Header.Set("x-tif-signature", signature)
  2797. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2798. request.Header.Set("x-tif-nonce", nonce)
  2799. client := http.Client{}
  2800. resp, err := client.Do(request)
  2801. if err != nil {
  2802. fmt.Println(err.Error())
  2803. return err.Error()
  2804. }
  2805. respBytes, err := ioutil.ReadAll(resp.Body)
  2806. if err != nil {
  2807. fmt.Println(err.Error())
  2808. return err.Error()
  2809. }
  2810. str := string(respBytes)
  2811. fmt.Println(str)
  2812. return str
  2813. }
  2814. //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 {
  2815. // // 生成签名
  2816. // nonce := GetRandomString(32)
  2817. // timestamp := time.Now().Unix()
  2818. // signature := setSignature(timestamp, nonce, secret_key)
  2819. // tempTime := time.Unix(timestamp, 0)
  2820. // timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2821. //
  2822. // // 生成输入报文
  2823. // inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2824. // input := make(map[string]interface{})
  2825. // inputData := make(map[string]interface{})
  2826. // diseinfo := make([]map[string]interface{}, 0)
  2827. //
  2828. // inputMessage["infno"] = "2203" // 交易编码
  2829. // inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  2830. // inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  2831. // inputData["med_type"] = med_type // 医疗类别 16门诊特殊病
  2832. // inputData["begntime"] = timeFormatOne // 开始时间
  2833. // inputData["main_cond_dscr"] = "" // 主要病情描述
  2834. // inputData["dise_codg"] = sick_code // 病种编码
  2835. // inputData["dise_name"] = sick_name // 病种名称
  2836. // inputData["birctrl_type"] = "" // 计划生育手术类别
  2837. // inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
  2838. //
  2839. // diseinfo_sun := make(map[string]interface{})
  2840. // diseinfo_sun["diag_type"] = "1" // 诊断类别
  2841. // diseinfo_sun["diag_srt_no"] = "1" // 诊断排序号
  2842. // diseinfo_sun["diag_code"] = diag_code // 诊断代码
  2843. // diseinfo_sun["diag_name"] = diag // 诊断名称
  2844. // diseinfo_sun["diag_dept"] = department // 诊断科室
  2845. // diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
  2846. // diseinfo_sun["dise_dor_name"] = doctor // 诊断医生姓名
  2847. // diseinfo_sun["diag_time"] = timeFormatOne // 诊断时间
  2848. // diseinfo_sun["vali_flag"] = "1" // 有效标志
  2849. //
  2850. // diseinfo = append(diseinfo, diseinfo_sun)
  2851. // input["diseinfo"] = diseinfo
  2852. // input["mdtrtinfo"] = inputData
  2853. // inputMessage["input"] = input //交易输入
  2854. //
  2855. // bytesData, err := json.Marshal(inputMessage)
  2856. // fmt.Println(string(bytesData))
  2857. // if err != nil {
  2858. // fmt.Println(err.Error())
  2859. // return err.Error()
  2860. // }
  2861. // reader := bytes.NewReader(bytesData)
  2862. //
  2863. // url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2203"
  2864. //
  2865. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  2866. // request, err := http.NewRequest("POST", url, reader)
  2867. // if err != nil {
  2868. // fmt.Println(err.Error())
  2869. // return err.Error()
  2870. // }
  2871. //
  2872. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2873. // request.Header.Set("x-tif-paasid", "sg03_prd")
  2874. // request.Header.Set("x-tif-signature", signature)
  2875. // request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2876. // request.Header.Set("x-tif-nonce", nonce)
  2877. //
  2878. // client := http.Client{}
  2879. // resp, err := client.Do(request)
  2880. // if err != nil {
  2881. // fmt.Println(err.Error())
  2882. // return err.Error()
  2883. // }
  2884. // respBytes, err := ioutil.ReadAll(resp.Body)
  2885. // if err != nil {
  2886. // fmt.Println(err.Error())
  2887. // return err.Error()
  2888. // }
  2889. // str := string(respBytes)
  2890. // fmt.Println(str)
  2891. // return str
  2892. //}
  2893. func Gdyb5301(psnNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, admin_user_id int64) string {
  2894. // 生成签名
  2895. nonce := GetRandomString(32)
  2896. timestamp := time.Now().Unix()
  2897. //timestamp := time.Now().UnixNano() / 1e6
  2898. signature := setSignature(timestamp, nonce, secret_key)
  2899. //tempTime := time.Unix(timestamp, 0)
  2900. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2901. //timeFormatTwo := tempTime.Format("2006-01-02")
  2902. inputMessage := make(map[string]interface{})
  2903. //tempTime := time.Unix(timestamp, 0)
  2904. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2905. // 生成输入报文
  2906. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  2907. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  2908. } else {
  2909. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2910. }
  2911. // 生成输入报文
  2912. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2913. input := make(map[string]interface{})
  2914. inputData := make(map[string]interface{})
  2915. inputMessage["infno"] = "5301" // 交易编码
  2916. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  2917. input["data"] = inputData
  2918. inputMessage["input"] = input //交易输入
  2919. bytesData, err := json.Marshal(inputMessage)
  2920. fmt.Println(string(bytesData))
  2921. if err != nil {
  2922. fmt.Println(err.Error())
  2923. return err.Error()
  2924. }
  2925. reader := bytes.NewReader(bytesData)
  2926. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  2927. gdyb_url := beego.AppConfig.String("gdyb_url")
  2928. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2929. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2930. var url string
  2931. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  2932. url = gdyb_url
  2933. } else {
  2934. url = gdyb_url + "5301"
  2935. }
  2936. request, err := http.NewRequest("POST", url, reader)
  2937. if err != nil {
  2938. fmt.Println(err.Error())
  2939. return err.Error()
  2940. }
  2941. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2942. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2943. request.Header.Set("x-tif-signature", signature)
  2944. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2945. request.Header.Set("x-tif-nonce", nonce)
  2946. client := http.Client{}
  2947. resp, err := client.Do(request)
  2948. if err != nil {
  2949. fmt.Println(err.Error())
  2950. return err.Error()
  2951. }
  2952. respBytes, err := ioutil.ReadAll(resp.Body)
  2953. if err != nil {
  2954. fmt.Println(err.Error())
  2955. return err.Error()
  2956. }
  2957. str := string(respBytes)
  2958. fmt.Println(str)
  2959. return str
  2960. }
  2961. func Gdyb5301Two(psnNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  2962. // 生成签名
  2963. nonce := GetRandomString(32)
  2964. timestamp := time.Now().Unix()
  2965. signature := setSignature(timestamp, nonce, secret_key)
  2966. //tempTime := time.Unix(timestamp, 0)
  2967. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2968. //timeFormatTwo := tempTime.Format("2006-01-02")
  2969. // 生成输入报文
  2970. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2971. input := make(map[string]interface{})
  2972. inputData := make(map[string]interface{})
  2973. inputMessage["infno"] = "5301" // 交易编码
  2974. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  2975. input["data"] = inputData
  2976. inputMessage["input"] = input //交易输入
  2977. bytesData, err := json.Marshal(inputMessage)
  2978. fmt.Println(string(bytesData))
  2979. if err != nil {
  2980. fmt.Println(err.Error())
  2981. return err.Error()
  2982. }
  2983. reader := bytes.NewReader(bytesData)
  2984. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  2985. gdyb_url := beego.AppConfig.String("gdyb_url")
  2986. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2987. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2988. url := gdyb_url
  2989. request, err := http.NewRequest("POST", url, reader)
  2990. if err != nil {
  2991. fmt.Println(err.Error())
  2992. return err.Error()
  2993. }
  2994. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2995. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2996. request.Header.Set("x-tif-signature", signature)
  2997. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2998. request.Header.Set("x-tif-nonce", nonce)
  2999. client := http.Client{}
  3000. resp, err := client.Do(request)
  3001. if err != nil {
  3002. fmt.Println(err.Error())
  3003. return err.Error()
  3004. }
  3005. respBytes, err := ioutil.ReadAll(resp.Body)
  3006. if err != nil {
  3007. fmt.Println(err.Error())
  3008. return err.Error()
  3009. }
  3010. str := string(respBytes)
  3011. fmt.Println(str)
  3012. return str
  3013. }
  3014. type CustomStruct struct {
  3015. FundPayType string
  3016. FundPayamt float64
  3017. }
  3018. type OpspdiseinfoStruct struct {
  3019. DiagName string
  3020. DiagCode string
  3021. OprnOprtName string
  3022. OprnOprtCode string
  3023. }
  3024. type DiaginfoStructTwo struct {
  3025. DiagType string
  3026. DiagCode string
  3027. DiagName string
  3028. MaindiagFlag string
  3029. }
  3030. type IteminfoStruct struct {
  3031. MedChrgitm string
  3032. Amt float64
  3033. ClaaSumfee float64
  3034. ClabAmt float64
  3035. FulamtOwnpayAmt float64
  3036. OthAmt float64
  3037. }
  3038. type Struct4101 struct {
  3039. PsnNo string
  3040. MdtrtId string
  3041. SetlId string
  3042. HiSetlLv string
  3043. PsnName string
  3044. Gend string
  3045. Brdy string
  3046. Ntly string
  3047. Naty string
  3048. PatnCertType string
  3049. Certno string
  3050. Prfs string
  3051. ConerName string
  3052. PatnRlts string
  3053. ConerAddr string
  3054. ConerTel string
  3055. HiType string
  3056. Insuplc string
  3057. AdmCaty string
  3058. DscgCaty string
  3059. MaindiagFlag string
  3060. BillCode string
  3061. BillNo string
  3062. BizSn string
  3063. SetlBegnDate string
  3064. SetlEndDate string
  3065. PsnSelfPay float64
  3066. PsnOwnPay float64
  3067. AcctPay float64
  3068. PsnCashpay float64
  3069. HiPaymtd string
  3070. Hsorg string
  3071. HsorgOpter string
  3072. MedinsFillDept string
  3073. MedinsFillPsn string
  3074. IptMedType string
  3075. Age int64
  3076. CustomStruct []CustomStruct
  3077. OpspdiseinfoStruct []OpspdiseinfoStruct
  3078. Diseinfo []DiaginfoStructTwo
  3079. IteminfoStruct []IteminfoStruct
  3080. AdmTime string
  3081. AdmEndTime string
  3082. HisNo string
  3083. DoctorName string
  3084. DoctorCode string
  3085. CurAddr string
  3086. }
  3087. func Gdyb4101(struct4101 Struct4101, secret_key string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, org_id int64, admin_user_id int64) (string, string) {
  3088. // 生成签名
  3089. nonce := GetRandomString(32)
  3090. timestamp := time.Now().Unix()
  3091. signature := setSignature(timestamp, nonce, secret_key)
  3092. inputMessage := make(map[string]interface{})
  3093. //tempTime := time.Unix(timestamp, 0)
  3094. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  3095. // 生成输入报文
  3096. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  3097. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  3098. } else {
  3099. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3100. }
  3101. // 生成输入报文
  3102. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3103. input := make(map[string]interface{})
  3104. inputData := make(map[string]interface{})
  3105. if org_id == 10106 || org_id == 10215 || org_id == 10138 || org_id == 9504 {
  3106. inputMessage["infno"] = "4101A" // 交易编码
  3107. } else {
  3108. inputMessage["infno"] = "4101A" // 交易编码
  3109. }
  3110. year := time.Now().Format("2006")
  3111. month := time.Now().Format("01")
  3112. day := time.Now().Format("02")
  3113. inputData["mdtrt_id"] = struct4101.MdtrtId // 就诊 ID 必填(来自2201接口返回)
  3114. inputData["setl_id"] = struct4101.SetlId // 结算 ID 必填
  3115. inputData["psn_no"] = struct4101.PsnNo // 结算 ID 必填
  3116. inputData["fixmedins_name"] = org_name // 定点医药机构名称 必填
  3117. inputData["fixmedins_code"] = fixmedins_code // 定点医药机构编码 必填
  3118. inputData["hi_setl_lv"] = "" // 医保结算等级
  3119. inputData["hi_no"] = struct4101.PsnNo // 医保编号
  3120. inputData["medcasno"] = struct4101.PsnNo // 病案号 必填
  3121. inputData["dcla_time"] = year + "-" + month + "-" + day // 申报时间 必填
  3122. inputData["psn_name"] = struct4101.PsnName // 人员姓名 必填
  3123. inputData["gend"] = struct4101.Gend // 性别 必填
  3124. inputData["brdy"] = struct4101.Brdy // 出生日期 必填
  3125. inputData["age"] = struct4101.Age // 年龄 必填
  3126. inputData["ntly"] = "CHN" // 国籍 必填
  3127. inputData["nwb_age"] = "" // 年龄 必填
  3128. inputData["naty"] = struct4101.Naty // 民族 必填
  3129. inputData["dscg_way"] = "9" // 民族 必填
  3130. //inputData["resp_nurs_code"] = "N441623001432" // 民族 必填
  3131. inputData["patn_cert_type"] = struct4101.PatnCertType // 患者证件类别 必填
  3132. inputData["certno"] = struct4101.Certno // 证件号码 必填
  3133. inputData["prfs"] = struct4101.Prfs // 职业 必填
  3134. inputData["curr_addr"] = "" // 现住址 必填
  3135. inputData["emp_name"] = "" // 单位名称 必填
  3136. inputData["emp_addr"] = "" // 单位地址 必填
  3137. inputData["emp_tel"] = "" // 单位电话 必填
  3138. inputData["poscode"] = "" // 邮编 必填
  3139. inputData["coner_name"] = struct4101.ConerName // 联系人姓名 必填
  3140. inputData["patn_rlts"] = struct4101.PatnRlts // 与患者关系 必填
  3141. inputData["coner_addr"] = struct4101.ConerAddr // 联系人地址 必填
  3142. inputData["coner_tel"] = struct4101.ConerTel // 联系人电话 必填
  3143. inputData["hi_type"] = struct4101.HiType // 医保类型 必填
  3144. inputData["insuplc"] = struct4101.Insuplc // 参保地 必填
  3145. inputData["sp_psn_type"] = "" // 特殊人员类型 必填
  3146. inputData["nwb_adm_type"] = "" // 新生儿入院类型 必填
  3147. inputData["nwb_bir_wt"] = "" // 新生儿出生体重 必填
  3148. inputData["nwb_adm_wt"] = "" // 新生儿入院体重 必填
  3149. inputData["opsp_diag_caty"] = "" // 门诊慢特病诊断 必填
  3150. inputData["opsp_mdtrt_date"] = "" // 门诊慢特病就诊日期 必填
  3151. inputData["ipt_med_type"] = "" // 住院医疗类型 必填
  3152. inputData["adm_way"] = "2" // 入院途径 必填
  3153. inputData["trt_type"] = "1" // 治疗类别 必填
  3154. inputData["adm_time"] = struct4101.SetlEndDate // 入院时间 必填
  3155. inputData["adm_caty"] = "A03.06" // 入院科别 必填
  3156. inputData["refldept_dept"] = "" // 转科科别 必填
  3157. inputData["dscg_time"] = struct4101.SetlBegnDate // 出院时间 必填
  3158. inputData["dscg_caty"] = "A03.06" // 出院科别 必填
  3159. inputData["caty"] = "A03.06" // 出院科别 必填
  3160. inputData["act_ipt_days"] = "" // 实际住院天数 必填
  3161. inputData["otp_wm_dise"] = "" // 门(急) 诊西医诊断 必填
  3162. inputData["wm_dise_code"] = "" // 门(急) 诊中医诊断 必填
  3163. inputData["otp_tcm_dise"] = "" // 西医诊断疾病代码 必填
  3164. inputData["tcm_dise_code"] = "" // 中医诊断代码 必填
  3165. inputData["oprn_oprt_code_cnt"] = "" // 手术操作代码计数 必填
  3166. inputData["vent_used_dura"] = "" // 呼吸机使用时长 必填
  3167. inputData["pwcry_bfadm_coma_dura"] = "" // 颅脑损伤患者入院前昏迷时长 必填
  3168. inputData["pwcry_afadm_coma_dura"] = "" // 颅脑损伤患者入院后昏迷时长 必填
  3169. inputData["bld_cat"] = "" // 输血品种 必填
  3170. inputData["bld_amt"] = "" // 输血量 必填
  3171. inputData["bld_unt"] = "" // 输血计量单位 必填
  3172. inputData["spga_nurscare_days"] = "" // 特级护理天数 必填
  3173. inputData["lv1_nurscare_days"] = "" // 一级护理天数 必填
  3174. inputData["scd_nurscare_days"] = "" // 二级护理天数 必填
  3175. inputData["lv3_nurscare_days"] = "" // 三级护理天数 必填
  3176. inputData["acp_medins_name"] = "" // 拟接收机构名称 必填
  3177. inputData["acp_optins_code"] = "" // 拟接收机构代码 必填
  3178. inputData["bill_code"] = struct4101.BillCode // 票据代码 必填
  3179. inputData["bill_no"] = struct4101.BillNo // 票据号码 必填
  3180. inputData["biz_sn"] = struct4101.BizSn // 业务流水号 必填
  3181. inputData["days_rinp_flag_31"] = "1" // 出院 31 天内再住院计划标志 必填
  3182. inputData["days_rinp_pup_31"] = "1" // 出院 31 天内再住院目的 必填
  3183. inputData["chfpdr_name"] = struct4101.DoctorName // 主诊医师姓名 必填
  3184. inputData["chfpdr_code"] = struct4101.DoctorCode // 主诊医师代码 必填
  3185. inputData["setl_begn_date"] = struct4101.SetlBegnDate // 结算开始日期 必填
  3186. inputData["setl_end_date"] = struct4101.SetlEndDate // 结算结束日期 必填
  3187. inputData["psn_selfpay"] = struct4101.PsnSelfPay // 个人自付 必填
  3188. inputData["psn_ownpay"] = struct4101.PsnOwnPay // 个人自费 必填
  3189. inputData["acct_pay"] = struct4101.AcctPay // 个人账户支出 必填
  3190. inputData["hi_paymtd"] = struct4101.HiPaymtd // 医保支付方式 必填
  3191. inputData["hsorg"] = struct4101.Hsorg // 医保机构 必填
  3192. inputData["hsorg_opter"] = struct4101.HsorgOpter // 医保机构经办人 必填
  3193. inputData["medins_fill_dept"] = struct4101.MedinsFillDept // 医疗机构填报部门 必填
  3194. inputData["medins_fill_psn"] = struct4101.MedinsFillPsn // 医疗机构填报人 必填
  3195. inputData["psn_cashpay"] = struct4101.PsnCashpay // 医疗机构填报人 必填
  3196. inputData["resp_nurs_code"] = "N440307016120" // 民族 必填
  3197. payinfo := make([]map[string]interface{}, 0) // 基金支付信息
  3198. for _, item := range struct4101.CustomStruct {
  3199. payinfotemp := make(map[string]interface{})
  3200. 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" {
  3201. payinfotemp["fund_pay_type"] = item.FundPayType // 基金支付类型 必填
  3202. payinfotemp["fund_payamt"] = item.FundPayamt // 基金支付金额
  3203. payinfo = append(payinfo, payinfotemp)
  3204. }
  3205. }
  3206. opspdiseinfo := make([]map[string]interface{}, 0) // 门诊慢特病诊断信息
  3207. opspdiseinfotemp := make(map[string]interface{})
  3208. opspdiseinfotemp["diag_name"] = "慢性肾功能不全(血透治疗)" // 诊断名称 必填
  3209. opspdiseinfotemp["diag_code"] = "N18.904" // 诊断代码 必填
  3210. opspdiseinfotemp["oprn_oprt_name"] = "血液透析" // 手术操作名称 必填
  3211. opspdiseinfotemp["oprn_oprt_code"] = "39.9500" // 手术操作代码 必填
  3212. opspdiseinfo = append(opspdiseinfo, opspdiseinfotemp)
  3213. diseinfo := make([]map[string]interface{}, 0) // 住院诊断信息
  3214. for _, item := range struct4101.Diseinfo {
  3215. diseinfotemp := make(map[string]interface{})
  3216. diseinfotemp["maindiag_flag"] = item.MaindiagFlag // 手术操作代码 必填
  3217. diseinfotemp["diag_type"] = item.DiagType // 诊断类别 必填
  3218. diseinfotemp["diag_code"] = item.DiagCode // 诊断代码 必填
  3219. diseinfotemp["diag_name"] = item.DiagName // 诊断名称 必填
  3220. diseinfotemp["adm_cond_type"] = "3" // 入院病情类型 必填
  3221. diseinfo = append(diseinfo, diseinfotemp)
  3222. }
  3223. oprninfo := make([]map[string]interface{}, 0) // 手术操作信息
  3224. oprninfotemp := make(map[string]interface{})
  3225. oprninfotemp["oprn_oprt_type"] = "" // 手术操作类别 必填
  3226. oprninfotemp["oprn_oprt_name"] = "" // 手术操作名称 必填
  3227. oprninfotemp["oprn_oprt_code"] = "" // 手术操作代码 必填
  3228. oprninfotemp["oprn_oprt_date"] = "" // 手术操作日期 必填
  3229. oprninfotemp["anst_way"] = "" // 麻醉方式 必填
  3230. oprninfotemp["oper_dr_name"] = "" // 术者医师姓名 必填
  3231. oprninfotemp["oper_dr_code"] = "" // 术者医师代码 必填
  3232. oprninfotemp["anst_dr_name"] = "" // 麻醉医师姓名 必填
  3233. oprninfotemp["anst_dr_code"] = "" // 麻醉医师代码 必填
  3234. oprninfo = append(oprninfo, oprninfotemp)
  3235. icuinfo := make([]map[string]interface{}, 0) // 重症监护信息
  3236. icuinfotemp := make(map[string]interface{})
  3237. icuinfotemp["scs_cutd_ward_type"] = "" // 重症监护病房类型 必填
  3238. icuinfotemp["scs_cutd_inpool_time"] = "" // 重症监护进入时间 必填
  3239. icuinfotemp["scs_cutd_exit_time"] = "" // 重症监护退出时间 必填
  3240. icuinfotemp["scs_cutd_sum_dura"] = "" // 重症监护合计时长 必填
  3241. icuinfo = append(icuinfo, icuinfotemp)
  3242. input["setlinfo"] = inputData
  3243. input["payinfo"] = payinfo
  3244. //input["opspdiseinfo"] = opspdiseinfo
  3245. input["diseinfo"] = diseinfo
  3246. inputMessage["input"] = input //交易输入
  3247. bytesData, err := json.Marshal(inputMessage)
  3248. fmt.Println(string(bytesData))
  3249. if err != nil {
  3250. fmt.Println(err.Error())
  3251. return err.Error(), ""
  3252. }
  3253. reader := bytes.NewReader(bytesData)
  3254. gdyb_url := beego.AppConfig.String("gdyb_url")
  3255. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3256. //url := gdyb_url + "4101"
  3257. var url string
  3258. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  3259. url = gdyb_url
  3260. //inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs,doctor)
  3261. } else {
  3262. //inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3263. url = gdyb_url + "4101A"
  3264. }
  3265. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/4101"
  3266. request, err := http.NewRequest("POST", url, reader)
  3267. if err != nil {
  3268. fmt.Println(err.Error())
  3269. return err.Error(), ""
  3270. }
  3271. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3272. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3273. request.Header.Set("x-tif-signature", signature)
  3274. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3275. request.Header.Set("x-tif-nonce", nonce)
  3276. client := http.Client{}
  3277. resp, err := client.Do(request)
  3278. if err != nil {
  3279. fmt.Println(err.Error())
  3280. return err.Error(), ""
  3281. }
  3282. respBytes, err := ioutil.ReadAll(resp.Body)
  3283. if err != nil {
  3284. fmt.Println(err.Error())
  3285. return err.Error(), ""
  3286. }
  3287. str := string(respBytes)
  3288. fmt.Println(str)
  3289. return str, string(bytesData)
  3290. }
  3291. func Gdyb4101fornm(struct4101 Struct4101, secret_key string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, org_id int64, admin_user_id int64) (string, string) {
  3292. // 生成签名
  3293. nonce := GetRandomString(32)
  3294. timestamp := time.Now().Unix()
  3295. signature := setSignature(timestamp, nonce, secret_key)
  3296. inputMessage := make(map[string]interface{})
  3297. //tempTime := time.Unix(timestamp, 0)
  3298. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  3299. // 生成输入报文
  3300. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  3301. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  3302. } else {
  3303. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3304. }
  3305. // 生成输入报文
  3306. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3307. input := make(map[string]interface{})
  3308. inputData := make(map[string]interface{})
  3309. if org_id == 10106 || org_id == 10215 || org_id == 10138 || org_id == 9504 {
  3310. inputMessage["infno"] = "4101A" // 交易编码
  3311. } else {
  3312. inputMessage["infno"] = "4101A" // 交易编码
  3313. }
  3314. year := time.Now().Format("2006")
  3315. month := time.Now().Format("01")
  3316. day := time.Now().Format("02")
  3317. inputData["mdtrt_id"] = struct4101.MdtrtId // 就诊 ID 必填(来自2201接口返回)
  3318. inputData["setl_id"] = struct4101.SetlId // 结算 ID 必填
  3319. inputData["psn_no"] = struct4101.PsnNo // 结算 ID 必填
  3320. inputData["fixmedins_name"] = org_name // 定点医药机构名称 必填
  3321. inputData["fixmedins_code"] = fixmedins_code // 定点医药机构编码 必填
  3322. inputData["hi_setl_lv"] = "" // 医保结算等级
  3323. inputData["hi_no"] = struct4101.PsnNo // 医保编号
  3324. inputData["medcasno"] = struct4101.PsnNo // 病案号 必填
  3325. inputData["dcla_time"] = year + "-" + month + "-" + day // 申报时间 必填
  3326. inputData["psn_name"] = struct4101.PsnName // 人员姓名 必填
  3327. inputData["gend"] = struct4101.Gend // 性别 必填
  3328. inputData["brdy"] = struct4101.Brdy // 出生日期 必填
  3329. inputData["age"] = struct4101.Age // 年龄 必填
  3330. inputData["ntly"] = struct4101.Ntly // 国籍 必填
  3331. inputData["nwb_age"] = "" // 年龄 必填
  3332. inputData["naty"] = struct4101.Naty // 民族 必填
  3333. //inputData["dscg_way"] = "9" // 民族 必填
  3334. //inputData["resp_nurs_code"] = "N441623001432" // 民族 必填
  3335. inputData["patn_cert_type"] = struct4101.PatnCertType // 患者证件类别 必填
  3336. inputData["certno"] = struct4101.Certno // 证件号码 必填
  3337. inputData["prfs"] = struct4101.Prfs // 职业 必填
  3338. inputData["curr_addr"] = "" // 现住址 必填
  3339. inputData["emp_name"] = "" // 单位名称 必填
  3340. inputData["emp_addr"] = "" // 单位地址 必填
  3341. inputData["emp_tel"] = "" // 单位电话 必填
  3342. inputData["poscode"] = "" // 邮编 必填
  3343. inputData["coner_name"] = struct4101.ConerName // 联系人姓名 必填
  3344. inputData["patn_rlts"] = struct4101.PatnRlts // 与患者关系 必填
  3345. inputData["coner_addr"] = struct4101.ConerAddr // 联系人地址 必填
  3346. inputData["coner_tel"] = struct4101.ConerTel // 联系人电话 必填
  3347. inputData["hi_type"] = struct4101.HiType // 医保类型 必填
  3348. inputData["insuplc"] = struct4101.Insuplc // 参保地 必填
  3349. inputData["sp_psn_type"] = "" // 特殊人员类型 必填
  3350. inputData["nwb_adm_type"] = "" // 新生儿入院类型 必填
  3351. inputData["nwb_bir_wt"] = "" // 新生儿出生体重 必填
  3352. inputData["nwb_adm_wt"] = "" // 新生儿入院体重 必填
  3353. inputData["opsp_diag_caty"] = "" // 门诊慢特病诊断 必填
  3354. inputData["opsp_mdtrt_date"] = "" // 门诊慢特病就诊日期 必填
  3355. inputData["ipt_med_type"] = "" // 住院医疗类型 必填
  3356. inputData["adm_way"] = "" // 入院途径 必填
  3357. inputData["trt_type"] = "10" // 治疗类别 必填
  3358. inputData["adm_time"] = "" // 入院时间 必填
  3359. inputData["adm_caty"] = "A03.06" // 入院科别 必填
  3360. inputData["refldept_dept"] = "" // 转科科别 必填
  3361. inputData["dscg_time"] = "" // 出院时间 必填
  3362. inputData["dscg_caty"] = "A03.06" // 出院科别 必填
  3363. inputData["caty"] = "A03.06" // 出院科别 必填
  3364. inputData["act_ipt_days"] = "" // 实际住院天数 必填
  3365. inputData["otp_wm_dise"] = "" // 门(急) 诊西医诊断 必填
  3366. inputData["wm_dise_code"] = "" // 门(急) 诊中医诊断 必填
  3367. inputData["otp_tcm_dise"] = "" // 西医诊断疾病代码 必填
  3368. inputData["tcm_dise_code"] = "" // 中医诊断代码 必填
  3369. inputData["oprn_oprt_code_cnt"] = "" // 手术操作代码计数 必填
  3370. inputData["vent_used_dura"] = "" // 呼吸机使用时长 必填
  3371. inputData["pwcry_bfadm_coma_dura"] = "" // 颅脑损伤患者入院前昏迷时长 必填
  3372. inputData["pwcry_afadm_coma_dura"] = "" // 颅脑损伤患者入院后昏迷时长 必填
  3373. inputData["bld_cat"] = "" // 输血品种 必填
  3374. inputData["bld_amt"] = "" // 输血量 必填
  3375. inputData["bld_unt"] = "" // 输血计量单位 必填
  3376. inputData["spga_nurscare_days"] = "" // 特级护理天数 必填
  3377. inputData["lv1_nurscare_days"] = "" // 一级护理天数 必填
  3378. inputData["scd_nurscare_days"] = "" // 二级护理天数 必填
  3379. inputData["lv3_nurscare_days"] = "" // 三级护理天数 必填
  3380. inputData["acp_medins_name"] = "" // 拟接收机构名称 必填
  3381. inputData["acp_optins_code"] = "" // 拟接收机构代码 必填
  3382. inputData["bill_code"] = struct4101.BillCode // 票据代码 必填
  3383. inputData["bill_no"] = struct4101.BillNo // 票据号码 必填
  3384. inputData["biz_sn"] = struct4101.BizSn // 业务流水号 必填
  3385. inputData["days_rinp_flag_31"] = "" // 出院 31 天内再住院计划标志 必填
  3386. inputData["days_rinp_pup_31"] = "" // 出院 31 天内再住院目的 必填
  3387. inputData["chfpdr_name"] = struct4101.DoctorName // 主诊医师姓名 必填
  3388. inputData["chfpdr_code"] = struct4101.DoctorCode // 主诊医师代码 必填
  3389. inputData["setl_begn_date"] = struct4101.SetlBegnDate // 结算开始日期 必填
  3390. inputData["setl_end_date"] = struct4101.SetlEndDate // 结算结束日期 必填
  3391. inputData["psn_selfpay"] = struct4101.PsnSelfPay // 个人自付 必填
  3392. inputData["psn_ownpay"] = struct4101.PsnOwnPay // 个人自费 必填
  3393. inputData["acct_pay"] = struct4101.AcctPay // 个人账户支出 必填
  3394. inputData["hi_paymtd"] = struct4101.HiPaymtd // 医保支付方式 必填
  3395. inputData["hsorg"] = struct4101.Hsorg // 医保机构 必填
  3396. inputData["hsorg_opter"] = struct4101.HsorgOpter // 医保机构经办人 必填
  3397. inputData["medins_fill_dept"] = struct4101.MedinsFillDept // 医疗机构填报部门 必填
  3398. inputData["medins_fill_psn"] = struct4101.MedinsFillPsn // 医疗机构填报人 必填
  3399. inputData["psn_cashpay"] = struct4101.PsnCashpay // 医疗机构填报人 必填
  3400. inputData["dscg_way"] = "1" // 医疗机构填报人 必填
  3401. payinfo := make([]map[string]interface{}, 0) // 基金支付信息
  3402. for _, item := range struct4101.CustomStruct {
  3403. payinfotemp := make(map[string]interface{})
  3404. 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" {
  3405. payinfotemp["fund_pay_type"] = item.FundPayType // 基金支付类型 必填
  3406. payinfotemp["fund_payamt"] = item.FundPayamt // 基金支付金额
  3407. payinfo = append(payinfo, payinfotemp)
  3408. }
  3409. }
  3410. opspdiseinfo := make([]map[string]interface{}, 0) // 门诊慢特病诊断信息
  3411. opspdiseinfotemp := make(map[string]interface{})
  3412. opspdiseinfotemp["diag_name"] = "慢性肾功能不全(血透治疗)" // 诊断名称 必填
  3413. opspdiseinfotemp["diag_code"] = "N18.904" // 诊断代码 必填
  3414. opspdiseinfotemp["oprn_oprt_name"] = "血液透析" // 手术操作名称 必填
  3415. opspdiseinfotemp["oprn_oprt_code"] = "39.9500" // 手术操作代码 必填
  3416. opspdiseinfo = append(opspdiseinfo, opspdiseinfotemp)
  3417. diseinfo := make([]map[string]interface{}, 0) // 住院诊断信息
  3418. for _, item := range struct4101.Diseinfo {
  3419. diseinfotemp := make(map[string]interface{})
  3420. diseinfotemp["maindiag_flag"] = item.MaindiagFlag // 手术操作代码 必填
  3421. diseinfotemp["diag_type"] = item.DiagType // 诊断类别 必填
  3422. diseinfotemp["diag_code"] = item.DiagCode // 诊断代码 必填
  3423. diseinfotemp["diag_name"] = item.DiagName // 诊断名称 必填
  3424. diseinfotemp["adm_cond_type"] = "3" // 入院病情类型 必填
  3425. diseinfo = append(diseinfo, diseinfotemp)
  3426. }
  3427. oprninfo := make([]map[string]interface{}, 0) // 手术操作信息
  3428. oprninfotemp := make(map[string]interface{})
  3429. oprninfotemp["oprn_oprt_type"] = "" // 手术操作类别 必填
  3430. oprninfotemp["oprn_oprt_name"] = "" // 手术操作名称 必填
  3431. oprninfotemp["oprn_oprt_code"] = "" // 手术操作代码 必填
  3432. oprninfotemp["oprn_oprt_date"] = "" // 手术操作日期 必填
  3433. oprninfotemp["anst_way"] = "" // 麻醉方式 必填
  3434. oprninfotemp["oper_dr_name"] = "" // 术者医师姓名 必填
  3435. oprninfotemp["oper_dr_code"] = "" // 术者医师代码 必填
  3436. oprninfotemp["anst_dr_name"] = "" // 麻醉医师姓名 必填
  3437. oprninfotemp["anst_dr_code"] = "" // 麻醉医师代码 必填
  3438. oprninfo = append(oprninfo, oprninfotemp)
  3439. icuinfo := make([]map[string]interface{}, 0) // 重症监护信息
  3440. icuinfotemp := make(map[string]interface{})
  3441. icuinfotemp["scs_cutd_ward_type"] = "" // 重症监护病房类型 必填
  3442. icuinfotemp["scs_cutd_inpool_time"] = "" // 重症监护进入时间 必填
  3443. icuinfotemp["scs_cutd_exit_time"] = "" // 重症监护退出时间 必填
  3444. icuinfotemp["scs_cutd_sum_dura"] = "" // 重症监护合计时长 必填
  3445. icuinfo = append(icuinfo, icuinfotemp)
  3446. input["setlinfo"] = inputData
  3447. input["payinfo"] = payinfo
  3448. input["opspdiseinfo"] = opspdiseinfo
  3449. input["diseinfo"] = diseinfo
  3450. inputMessage["input"] = input //交易输入
  3451. bytesData, err := json.Marshal(inputMessage)
  3452. fmt.Println(string(bytesData))
  3453. if err != nil {
  3454. fmt.Println(err.Error())
  3455. return err.Error(), ""
  3456. }
  3457. reader := bytes.NewReader(bytesData)
  3458. gdyb_url := beego.AppConfig.String("gdyb_url")
  3459. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3460. //url := gdyb_url + "4101"
  3461. var url string
  3462. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  3463. url = gdyb_url
  3464. //inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs,doctor)
  3465. } else {
  3466. //inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3467. url = gdyb_url
  3468. }
  3469. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/4101"
  3470. request, err := http.NewRequest("POST", url, reader)
  3471. if err != nil {
  3472. fmt.Println(err.Error())
  3473. return err.Error(), ""
  3474. }
  3475. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3476. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3477. request.Header.Set("x-tif-signature", signature)
  3478. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3479. request.Header.Set("x-tif-nonce", nonce)
  3480. client := http.Client{}
  3481. resp, err := client.Do(request)
  3482. if err != nil {
  3483. fmt.Println(err.Error())
  3484. return err.Error(), ""
  3485. }
  3486. respBytes, err := ioutil.ReadAll(resp.Body)
  3487. if err != nil {
  3488. fmt.Println(err.Error())
  3489. return err.Error(), ""
  3490. }
  3491. str := string(respBytes)
  3492. fmt.Println(str)
  3493. return str, string(bytesData)
  3494. }
  3495. 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) {
  3496. // 生成签名
  3497. nonce := GetRandomString(32)
  3498. timestamp := time.Now().Unix()
  3499. signature := setSignature(timestamp, nonce, secret_key)
  3500. // 生成输入报文
  3501. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3502. input := make(map[string]interface{})
  3503. inputData := make(map[string]interface{})
  3504. inputMessage["infno"] = "4101A" // 交易编码
  3505. year := time.Now().Format("2006")
  3506. month := time.Now().Format("01")
  3507. day := time.Now().Format("02")
  3508. inputData["mdtrt_id"] = struct4101.MdtrtId // 就诊 ID 必填(来自2201接口返回)
  3509. inputData["setl_id"] = struct4101.SetlId // 结算 ID 必填
  3510. inputData["psn_no"] = struct4101.PsnNo // 结算 ID 必填
  3511. inputData["fixmedins_name"] = org_name // 定点医药机构名称 必填
  3512. inputData["fixmedins_code"] = fixmedins_code // 定点医药机构编码 必填
  3513. inputData["hi_setl_lv"] = "" // 医保结算等级
  3514. inputData["hi_no"] = struct4101.PsnNo // 医保编号
  3515. inputData["medcasno"] = struct4101.PsnNo // 病案号 必填
  3516. inputData["dcla_time"] = year + "-" + month + "-" + day // 申报时间 必填
  3517. inputData["psn_name"] = struct4101.PsnName // 人员姓名 必填
  3518. inputData["gend"] = struct4101.Gend // 性别 必填
  3519. inputData["brdy"] = struct4101.Brdy // 出生日期 必填
  3520. inputData["age"] = struct4101.Age // 年龄 必填
  3521. inputData["ntly"] = struct4101.Ntly // 国籍 必填
  3522. inputData["nwb_age"] = "" // 年龄 必填
  3523. inputData["naty"] = struct4101.Naty // 民族 必填
  3524. inputData["patn_cert_type"] = struct4101.PatnCertType // 患者证件类别 必填
  3525. inputData["certno"] = struct4101.Certno // 证件号码 必填
  3526. inputData["prfs"] = struct4101.Prfs // 职业 必填
  3527. inputData["curr_addr"] = "" // 现住址 必填
  3528. inputData["emp_name"] = "" // 单位名称 必填
  3529. inputData["emp_addr"] = "" // 单位地址 必填
  3530. inputData["emp_tel"] = "" // 单位电话 必填
  3531. inputData["poscode"] = "" // 邮编 必填
  3532. inputData["coner_name"] = struct4101.ConerName // 联系人姓名 必填
  3533. inputData["patn_rlts"] = struct4101.PatnRlts // 与患者关系 必填
  3534. inputData["coner_addr"] = struct4101.ConerAddr // 联系人地址 必填
  3535. inputData["coner_tel"] = struct4101.ConerTel // 联系人电话 必填
  3536. inputData["hi_type"] = struct4101.HiType // 医保类型 必填
  3537. inputData["insuplc"] = struct4101.Insuplc // 参保地 必填
  3538. inputData["sp_psn_type"] = "" // 特殊人员类型 必填
  3539. inputData["nwb_adm_type"] = "" // 新生儿入院类型 必填
  3540. inputData["nwb_bir_wt"] = "" // 新生儿出生体重 必填
  3541. inputData["nwb_adm_wt"] = "" // 新生儿入院体重 必填
  3542. inputData["opsp_diag_caty"] = "" // 门诊慢特病诊断 必填
  3543. inputData["opsp_mdtrt_date"] = "" // 门诊慢特病就诊日期 必填
  3544. inputData["ipt_med_type"] = "" // 住院医疗类型 必填
  3545. inputData["adm_way"] = "" // 入院途径 必填
  3546. inputData["trt_type"] = "10" // 治疗类别 必填
  3547. inputData["adm_time"] = struct4101.AdmTime // 入院时间 必填
  3548. inputData["adm_caty"] = struct4101.AdmCaty // 入院科别 必填
  3549. inputData["refldept_dept"] = "" // 转科科别 必填
  3550. inputData["dscg_time"] = struct4101.AdmEndTime // 出院时间 必填
  3551. inputData["dscg_caty"] = struct4101.DscgCaty // 出院科别 必填
  3552. inputData["act_ipt_days"] = "" // 实际住院天数 必填
  3553. inputData["otp_wm_dise"] = "" // 门(急) 诊西医诊断 必填
  3554. inputData["wm_dise_code"] = "" // 门(急) 诊中医诊断 必填
  3555. inputData["otp_tcm_dise"] = "" // 西医诊断疾病代码 必填
  3556. inputData["tcm_dise_code"] = "" // 中医诊断代码 必填
  3557. inputData["oprn_oprt_code_cnt"] = "" // 手术操作代码计数 必填
  3558. inputData["vent_used_dura"] = "" // 呼吸机使用时长 必填
  3559. inputData["pwcry_bfadm_coma_dura"] = "" // 颅脑损伤患者入院前昏迷时长 必填
  3560. inputData["pwcry_afadm_coma_dura"] = "" // 颅脑损伤患者入院后昏迷时长 必填
  3561. inputData["bld_cat"] = "" // 输血品种 必填
  3562. inputData["bld_amt"] = "" // 输血量 必填
  3563. inputData["bld_unt"] = "" // 输血计量单位 必填
  3564. inputData["spga_nurscare_days"] = "" // 特级护理天数 必填
  3565. inputData["lv1_nurscare_days"] = "" // 一级护理天数 必填
  3566. inputData["scd_nurscare_days"] = "" // 二级护理天数 必填
  3567. inputData["lv3_nurscare_days"] = "" // 三级护理天数 必填
  3568. inputData["acp_medins_name"] = "" // 拟接收机构名称 必填
  3569. inputData["acp_optins_code"] = "" // 拟接收机构代码 必填
  3570. inputData["bill_code"] = struct4101.BillCode // 票据代码 必填
  3571. inputData["bill_no"] = struct4101.BillNo // 票据号码 必填
  3572. inputData["biz_sn"] = struct4101.BizSn // 业务流水号 必填
  3573. inputData["days_rinp_flag_31"] = "" // 出院 31 天内再住院计划标志 必填
  3574. inputData["days_rinp_pup_31"] = "" // 出院 31 天内再住院目的 必填
  3575. inputData["chfpdr_name"] = struct4101.DoctorName // 主诊医师姓名 必填
  3576. inputData["chfpdr_code"] = struct4101.DoctorCode // 主诊医师代码 必填
  3577. inputData["setl_begn_date"] = struct4101.SetlBegnDate // 结算开始日期 必填
  3578. inputData["setl_end_date"] = struct4101.SetlEndDate // 结算结束日期 必填
  3579. inputData["psn_selfpay"] = struct4101.PsnSelfPay // 个人自付 必填
  3580. inputData["psn_ownpay"] = struct4101.PsnOwnPay // 个人自费 必填
  3581. inputData["acct_pay"] = struct4101.AcctPay // 个人账户支出 必填
  3582. inputData["hi_paymtd"] = struct4101.HiPaymtd // 医保支付方式 必填
  3583. inputData["hsorg"] = struct4101.Hsorg // 医保机构 必填
  3584. inputData["hsorg_opter"] = struct4101.HsorgOpter // 医保机构经办人 必填
  3585. inputData["medins_fill_dept"] = struct4101.MedinsFillDept // 医疗机构填报部门 必填
  3586. inputData["medins_fill_psn"] = struct4101.MedinsFillPsn // 医疗机构填报人 必填
  3587. inputData["psn_cashpay"] = struct4101.PsnCashpay // 医疗机构填报人 必填
  3588. payinfo := make([]map[string]interface{}, 0) // 基金支付信息
  3589. for _, item := range struct4101.CustomStruct {
  3590. payinfotemp := make(map[string]interface{})
  3591. 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" {
  3592. payinfotemp["fund_pay_type"] = item.FundPayType // 基金支付类型 必填
  3593. payinfotemp["fund_payamt"] = item.FundPayamt // 基金支付金额
  3594. payinfo = append(payinfo, payinfotemp)
  3595. }
  3596. }
  3597. opspdiseinfo := make([]map[string]interface{}, 0) // 门诊慢特病诊断信息
  3598. opspdiseinfotemp := make(map[string]interface{})
  3599. opspdiseinfotemp["diag_name"] = struct4101.Diseinfo[len(struct4101.Diseinfo)-1].DiagName // 诊断名称 必填
  3600. opspdiseinfotemp["diag_code"] = struct4101.Diseinfo[len(struct4101.Diseinfo)-1].DiagCode // 诊断代码 必填
  3601. opspdiseinfotemp["oprn_oprt_name"] = "血液透析" // 手术操作名称 必填
  3602. opspdiseinfotemp["oprn_oprt_code"] = "39.9500" // 手术操作代码 必填
  3603. opspdiseinfo = append(opspdiseinfo, opspdiseinfotemp)
  3604. diseinfo := make([]map[string]interface{}, 0) // 住院诊断信息
  3605. for _, item := range struct4101.Diseinfo {
  3606. diseinfotemp := make(map[string]interface{})
  3607. diseinfotemp["maindiag_flag"] = item.MaindiagFlag // 手术操作代码 必填
  3608. diseinfotemp["diag_type"] = item.DiagType // 诊断类别 必填
  3609. diseinfotemp["diag_code"] = item.DiagCode // 诊断代码 必填
  3610. diseinfotemp["diag_name"] = item.DiagName // 诊断名称 必填
  3611. diseinfotemp["adm_cond_type"] = "3" // 入院病情类型 必填
  3612. diseinfo = append(diseinfo, diseinfotemp)
  3613. }
  3614. iteminfo := make([]map[string]interface{}, 0)
  3615. for _, item := range struct4101.IteminfoStruct {
  3616. iteminfotemp := make(map[string]interface{})
  3617. iteminfotemp["med_chrgitm"] = item.MedChrgitm // 医疗收费项目 必填
  3618. iteminfotemp["amt"] = item.Amt // 金额 必填
  3619. iteminfotemp["claa_sumfee"] = item.ClaaSumfee // 甲类费用合计 必填
  3620. iteminfotemp["clab_amt"] = item.ClabAmt // 乙类金额 必填
  3621. iteminfotemp["fulamt_ownpay_amt"] = item.FulamtOwnpayAmt // 全自费金额 必填
  3622. iteminfotemp["oth_amt"] = item.OthAmt // 其他金额 必填
  3623. iteminfo = append(iteminfo, iteminfotemp)
  3624. }
  3625. oprninfo := make([]map[string]interface{}, 0) // 手术操作信息
  3626. oprninfotemp := make(map[string]interface{})
  3627. oprninfotemp["oprn_oprt_type"] = "" // 手术操作类别 必填
  3628. oprninfotemp["oprn_oprt_name"] = "" // 手术操作名称 必填
  3629. oprninfotemp["oprn_oprt_code"] = "" // 手术操作代码 必填
  3630. oprninfotemp["oprn_oprt_date"] = "" // 手术操作日期 必填
  3631. oprninfotemp["anst_way"] = "" // 麻醉方式 必填
  3632. oprninfotemp["oper_dr_name"] = "" // 术者医师姓名 必填
  3633. oprninfotemp["oper_dr_code"] = "" // 术者医师代码 必填
  3634. oprninfotemp["anst_dr_name"] = "" // 麻醉医师姓名 必填
  3635. oprninfotemp["anst_dr_code"] = "" // 麻醉医师代码 必填
  3636. oprninfo = append(oprninfo, oprninfotemp)
  3637. icuinfo := make([]map[string]interface{}, 0) // 重症监护信息
  3638. icuinfotemp := make(map[string]interface{})
  3639. icuinfotemp["scs_cutd_ward_type"] = "" // 重症监护病房类型 必填
  3640. icuinfotemp["scs_cutd_inpool_time"] = "" // 重症监护进入时间 必填
  3641. icuinfotemp["scs_cutd_exit_time"] = "" // 重症监护退出时间 必填
  3642. icuinfotemp["scs_cutd_sum_dura"] = "" // 重症监护合计时长 必填
  3643. icuinfo = append(icuinfo, icuinfotemp)
  3644. input["setlinfo"] = inputData
  3645. input["payinfo"] = payinfo
  3646. input["opspdiseinfo"] = opspdiseinfo
  3647. input["diseinfo"] = diseinfo
  3648. input["iteminfo"] = iteminfo
  3649. inputMessage["input"] = input //交易输入
  3650. bytesData, err := json.Marshal(inputMessage)
  3651. fmt.Println(string(bytesData))
  3652. if err != nil {
  3653. fmt.Println(err.Error())
  3654. return err.Error(), ""
  3655. }
  3656. reader := bytes.NewReader(bytesData)
  3657. gdyb_url := beego.AppConfig.String("gdyb_url")
  3658. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3659. //url := gdyb_url + "4101"
  3660. var url string
  3661. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  3662. url = gdyb_url
  3663. } else {
  3664. url = gdyb_url + "4101A"
  3665. }
  3666. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/4101"
  3667. request, err := http.NewRequest("POST", url, reader)
  3668. if err != nil {
  3669. fmt.Println(err.Error())
  3670. return err.Error(), ""
  3671. }
  3672. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3673. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3674. request.Header.Set("x-tif-signature", signature)
  3675. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3676. request.Header.Set("x-tif-nonce", nonce)
  3677. client := http.Client{}
  3678. resp, err := client.Do(request)
  3679. if err != nil {
  3680. fmt.Println(err.Error())
  3681. return err.Error(), ""
  3682. }
  3683. respBytes, err := ioutil.ReadAll(resp.Body)
  3684. if err != nil {
  3685. fmt.Println(err.Error())
  3686. return err.Error(), ""
  3687. }
  3688. str := string(respBytes)
  3689. fmt.Println(str)
  3690. return str, string(bytesData)
  3691. }
  3692. 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) {
  3693. // 生成签名
  3694. nonce := GetRandomString(32)
  3695. timestamp := time.Now().Unix()
  3696. signature := setSignature(timestamp, nonce, secret_key)
  3697. // 生成输入报文
  3698. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3699. input := make(map[string]interface{})
  3700. inputData := make(map[string]interface{})
  3701. inputMessage["infno"] = "4101A" // 交易编码
  3702. year := time.Now().Format("2006")
  3703. month := time.Now().Format("01")
  3704. day := time.Now().Format("02")
  3705. inputData["psn_no"] = struct4101.PsnNo // 结算 ID 必填
  3706. inputData["mdtrt_id"] = struct4101.MdtrtId // 就诊 ID 必填(来自2201接口返回)
  3707. inputData["setl_id"] = struct4101.SetlId // 结算 ID 必填
  3708. inputData["hi_no"] = struct4101.PsnNo // 医保编号
  3709. inputData["medcasno"] = struct4101.PsnNo // 病案号 必填
  3710. inputData["dcla_time"] = year + "-" + month + "-" + day // 申报时间 必填
  3711. inputData["ntly"] = struct4101.Ntly // 国籍 必填
  3712. inputData["prfs"] = struct4101.Prfs // 职业 必填
  3713. inputData["curr_addr"] = struct4101.CurAddr // 现住址 必填
  3714. inputData["emp_name"] = "" // 单位名称 必填
  3715. inputData["emp_addr"] = "" // 单位地址 必填
  3716. inputData["emp_tel"] = ""
  3717. inputData["poscode"] = "" // 邮编 必填
  3718. inputData["coner_name"] = "" // 联系人姓名 必填
  3719. inputData["patn_rlts"] = "" // 与患者关系 必填
  3720. inputData["coner_addr"] = "" // 联系人地址 必填
  3721. inputData["coner_tel"] = ""
  3722. inputData["nwb_adm_type"] = "" // 新生儿入院类型 必填
  3723. inputData["nwb_bir_wt"] = "" // 新生儿出生体重 必填
  3724. inputData["nwb_adm_wt"] = "" // 新生儿入院体重 必填
  3725. inputData["mul_nwb_bir_wt"] = "" // 新生儿入院体重 必填
  3726. inputData["mul_nwb_adm_wt"] = "" // 新生儿入院体重 必填
  3727. inputData["opsp_diag_caty"] = "" // 门诊慢特病诊断 必填
  3728. inputData["opsp_mdtrt_date"] = "" // 门诊慢特病就诊日期 必填
  3729. inputData["adm_way"] = "" // 入院途径 必填
  3730. inputData["trt_type"] = "" // 治疗类别 必填
  3731. inputData["adm_time"] = "" // 入院时间 必填
  3732. inputData["refldept_dept"] = "" // 转科科别 必填
  3733. inputData["dscg_time"] = "" // 出院时间 必填
  3734. inputData["dscg_caty"] = "" // 出院科别 必填
  3735. inputData["otp_wm_dise"] = "" // 门(急) 诊西医诊断 必填
  3736. inputData["wm_dise_code"] = "" // 门(急) 诊中医诊断 必填
  3737. inputData["otp_tcm_dise"] = "" // 西医诊断疾病代码 必填
  3738. inputData["tcm_dise_code"] = "" // 中医诊断代码 必填
  3739. inputData["vent_used_dura"] = "" // 呼吸机使用时长 必填
  3740. inputData["pwcry_bfadm_coma_dura"] = "" // 颅脑损伤患者入院前昏迷时长 必填
  3741. inputData["pwcry_afadm_coma_dura"] = "" // 颅脑损伤患者入院后昏迷时长 必填
  3742. inputData["spga_nurscare_days"] = "" // 特级护理天数 必填
  3743. inputData["lv1_nurscare_days"] = "" // 一级护理天数 必填
  3744. inputData["scd_nurscare_days"] = "" // 二级护理天数 必填
  3745. inputData["lv3_nurscare_days"] = "" // 三级护理天数 必填
  3746. inputData["acp_medins_name"] = "" // 拟接收机构名称 必填
  3747. inputData["acp_optins_code"] = "" // 拟接收机构代码 必填
  3748. inputData["bill_code"] = struct4101.BillCode // 票据代码 必填
  3749. inputData["bill_no"] = struct4101.BillNo // 票据号码 必填
  3750. inputData["biz_sn"] = struct4101.BizSn // 业务流水号 必填
  3751. inputData["hi_paymtd"] = "1" // 业务流水号 必填
  3752. inputData["days_rinp_flag_31"] = "" // 出院 31 天内再住院计划标志 必填
  3753. inputData["days_rinp_pup_31"] = "" // 出院 31 天内再住院目的 必填
  3754. //inputData["chfpdr_name"] = struct4101.DoctorName // 主诊医师姓名 必填
  3755. //inputData["chfpdr_code"] = struct4101.DoctorCode // 主诊医师代码 必填
  3756. inputData["setl_begn_date"] = struct4101.SetlBegnDate // 结算开始日期 必填
  3757. inputData["setl_end_date"] = struct4101.SetlEndDate // 结算结束日期 必填
  3758. inputData["medins_fill_dept"] = struct4101.MedinsFillDept // 医疗机构填报部门 必填
  3759. inputData["medins_fill_psn"] = struct4101.MedinsFillPsn // 医疗机构填报人 必填
  3760. //payinfo := make([]map[string]interface{}, 0) // 基金支付信息
  3761. //for _, item := range struct4101.CustomStruct {
  3762. // payinfotemp := make(map[string]interface{})
  3763. // 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" {
  3764. // payinfotemp["fund_pay_type"] = item.FundPayType // 基金支付类型 必填
  3765. // payinfotemp["fund_payamt"] = item.FundPayamt // 基金支付金额
  3766. // payinfo = append(payinfo, payinfotemp)
  3767. // }
  3768. //}
  3769. opspdiseinfo := make([]map[string]interface{}, 0) // 门诊慢特病诊断信息
  3770. opspdiseinfotemp := make(map[string]interface{})
  3771. opspdiseinfotemp["diag_name"] = "慢性肾脏病5期" // 诊断名称 必填
  3772. opspdiseinfotemp["diag_code"] = "N18.500" // 诊断代码 必填
  3773. opspdiseinfotemp["oprn_oprt_name"] = "血液透析" // 手术操作名称 必填
  3774. opspdiseinfotemp["oprn_oprt_code"] = "39.9500" // 手术操作代码 必填
  3775. opspdiseinfo = append(opspdiseinfo, opspdiseinfotemp)
  3776. diseinfo := make([]map[string]interface{}, 0) // 住院诊断信息
  3777. for _, item := range struct4101.Diseinfo {
  3778. diseinfotemp := make(map[string]interface{})
  3779. diseinfotemp["maindiag_flag"] = item.MaindiagFlag // 手术操作代码 必填
  3780. diseinfotemp["diag_type"] = item.DiagType // 诊断类别 必填
  3781. diseinfotemp["diag_code"] = item.DiagCode // 诊断代码 必填
  3782. diseinfotemp["diag_name"] = item.DiagName // 诊断名称 必填
  3783. diseinfotemp["adm_cond_type"] = "3" // 入院病情类型 必填
  3784. diseinfo = append(diseinfo, diseinfotemp)
  3785. }
  3786. //iteminfo := make([]map[string]interface{}, 0)
  3787. //for _, item := range struct4101.IteminfoStruct {
  3788. // iteminfotemp := make(map[string]interface{})
  3789. // iteminfotemp["med_chrgitm"] = item.MedChrgitm // 医疗收费项目 必填
  3790. // iteminfotemp["amt"] = item.Amt // 金额 必填
  3791. // iteminfotemp["claa_sumfee"] = item.ClaaSumfee // 甲类费用合计 必填
  3792. // iteminfotemp["clab_amt"] = item.ClabAmt // 乙类金额 必填
  3793. // iteminfotemp["fulamt_ownpay_amt"] = item.FulamtOwnpayAmt // 全自费金额 必填
  3794. // iteminfotemp["oth_amt"] = item.OthAmt // 其他金额 必填
  3795. // iteminfo = append(iteminfo, iteminfotemp)
  3796. //}
  3797. oprninfo := make([]map[string]interface{}, 0) // 手术操作信息
  3798. oprninfotemp := make(map[string]interface{})
  3799. oprninfotemp["oprn_oprt_type"] = "" // 手术操作类别 必填
  3800. oprninfotemp["oprn_oprt_name"] = "" // 手术操作名称 必填
  3801. oprninfotemp["oprn_oprt_code"] = "" // 手术操作代码 必填
  3802. oprninfotemp["oprn_oprt_date"] = "" // 手术操作日期 必填
  3803. oprninfotemp["anst_way"] = "" // 麻醉方式 必填
  3804. oprninfotemp["oper_dr_name"] = "" // 术者医师姓名 必填
  3805. oprninfotemp["oper_dr_code"] = "" // 术者医师代码 必填
  3806. oprninfotemp["anst_dr_name"] = "" // 麻醉医师姓名 必填
  3807. oprninfotemp["anst_dr_code"] = "" // 麻醉医师代码 必填
  3808. oprninfo = append(oprninfo, oprninfotemp)
  3809. icuinfo := make([]map[string]interface{}, 0) // 重症监护信息
  3810. icuinfotemp := make(map[string]interface{})
  3811. icuinfotemp["scs_cutd_ward_type"] = "" // 重症监护病房类型 必填
  3812. icuinfotemp["scs_cutd_inpool_time"] = "" // 重症监护进入时间 必填
  3813. icuinfotemp["scs_cutd_exit_time"] = "" // 重症监护退出时间 必填
  3814. icuinfotemp["scs_cutd_sum_dura"] = "" // 重症监护合计时长 必填
  3815. icuinfo = append(icuinfo, icuinfotemp)
  3816. input["setlinfo"] = inputData
  3817. input["opspdiseinfo"] = opspdiseinfo
  3818. //input["diseinfo"] = diseinfo
  3819. //input["oprninfo"] = payinfo
  3820. //input["icuinfo"] = payinfo
  3821. //input["bldinfo"] = payinfo
  3822. inputMessage["input"] = input //交易输入
  3823. bytesData, err := json.Marshal(inputMessage)
  3824. fmt.Println(string(bytesData))
  3825. if err != nil {
  3826. fmt.Println(err.Error())
  3827. return err.Error(), ""
  3828. }
  3829. reader := bytes.NewReader(bytesData)
  3830. gdyb_url := beego.AppConfig.String("gdyb_url")
  3831. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3832. //url := gdyb_url + "4101"
  3833. var url string
  3834. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  3835. url = gdyb_url
  3836. } else {
  3837. url = gdyb_url + "4101A"
  3838. }
  3839. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/4101"
  3840. request, err := http.NewRequest("POST", url, reader)
  3841. if err != nil {
  3842. fmt.Println(err.Error())
  3843. return err.Error(), ""
  3844. }
  3845. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3846. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3847. request.Header.Set("x-tif-signature", signature)
  3848. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3849. request.Header.Set("x-tif-nonce", nonce)
  3850. client := http.Client{}
  3851. resp, err := client.Do(request)
  3852. if err != nil {
  3853. fmt.Println(err.Error())
  3854. return err.Error(), ""
  3855. }
  3856. respBytes, err := ioutil.ReadAll(resp.Body)
  3857. if err != nil {
  3858. fmt.Println(err.Error())
  3859. return err.Error(), ""
  3860. }
  3861. str := string(respBytes)
  3862. fmt.Println(str)
  3863. return str, string(bytesData)
  3864. }
  3865. //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 {
  3866. // // 生成签名
  3867. // nonce := GetRandomString(32)
  3868. // timestamp := time.Now().Unix()
  3869. // signature := setSignature(timestamp, nonce, secret_key)
  3870. // tempTime := time.Unix(timestamp, 0)
  3871. // //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  3872. //
  3873. // timeFormatTwo := tempTime.Format("2006-01-02")
  3874. //
  3875. // t := time.Now()
  3876. // last := time.Date(t.Year(), time.December, 31, 0, 0, 0, 0, time.UTC)
  3877. // tm := time.Unix(last.Unix(), 0)
  3878. //
  3879. // // 生成输入报文
  3880. // inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3881. // input := make(map[string]interface{})
  3882. // inputData := make(map[string]interface{})
  3883. //
  3884. // inputData2 := make(map[string]interface{})
  3885. //
  3886. // inputMessage["infno"] = "7101" // 交易编码
  3887. // inputData["hosp_rxno"] = psnNo // 人员编号 (来自1101接口返回)
  3888. // inputData["init_rxno"] = insutype // 险种类型(来自1101接口返回)
  3889. // inputData["rx_type_code"] = sick_code // 险种类型(来自1101接口返回)
  3890. // inputData["prsc_time"] = sick_name // 险种类型(来自1101接口返回)
  3891. // inputData["rx_drug_nums"] = insuplc_admdvs // 险种类型(来自1101接口返回)
  3892. // inputData["rx_way_codg"] = fixmedins_code // 险种类型(来自1101接口返回)
  3893. // inputData["rx_way_name"] = org_name // 险种类型(来自1101接口返回)
  3894. // inputData["rx_freq_codg"] = timeFormatTwo // 险种类型(来自1101接口返回)
  3895. // inputData["rx_freq_name"] = doctor_id // 开始时间
  3896. // inputData["rx_dosunt"] = doctor // 开始时间
  3897. // inputData["rx_doscnt"] = timeFormatTwo // 医师编码
  3898. // inputData["rx_drord_dscr"] = "" // 医师编码
  3899. // inputData["valid_days"] = "" // 医师编码
  3900. // inputData["valid_end_time"] = tm.Format("2006-01-02") // 医师编码
  3901. // inputData["rept_flag"] = tm.Format("2006-01-02") // 医师编码
  3902. // inputData["max_rept_cnt"] = tm.Format("2006-01-02") // 医师编码
  3903. // inputData["reptd_cnt"] = tm.Format("2006-01-02") // 医师编码
  3904. // inputData["min_inrv_days"] = tm.Format("2006-01-02") // 医师编码
  3905. // inputData["dr_sign_info"] = tm.Format("2006-01-02") // 医师编码
  3906. // inputData["phar_sign_info"] = tm.Format("2006-01-02") // 医师编码
  3907. // inputData["fixmedins_sign_info"] = tm.Format("2006-01-02") // 医师编码
  3908. // inputData["rx_cotn_flag"] = tm.Format("2006-01-02") // 医师编码
  3909. // inputData["rx_file"] = tm.Format("2006-01-02") // 医师编码
  3910. // input["data"] = inputData
  3911. //
  3912. //
  3913. // inputData2["med_list_codg"] = psnNo // 人员编号 (来自1101接口返回)
  3914. // inputData2["fixmedins_hilist_id"] = insutype // 险种类型(来自1101接口返回)
  3915. // inputData["hosp_prep_flag"] = sick_code // 险种类型(来自1101接口返回)
  3916. // inputData["rx_item_type_code"] = sick_name // 险种类型(来自1101接口返回)
  3917. // inputData["rx_item_type_name"] = insuplc_admdvs // 险种类型(来自1101接口返回)
  3918. // inputData["tcmdrug_type_name"] = fixmedins_code // 险种类型(来自1101接口返回)
  3919. // inputData["tcmdrug_type_code"] = org_name // 险种类型(来自1101接口返回)
  3920. // inputData["tcmherb_foote"] = timeFormatTwo // 险种类型(来自1101接口返回)
  3921. // inputData["medn_type_code"] = doctor_id // 开始时间
  3922. // inputData["medn_type_name"] = doctor // 开始时间
  3923. // inputData["main_medc_flag"] = timeFormatTwo // 医师编码
  3924. // inputData["urgt_flag"] = "" // 医师编码
  3925. // inputData["bas_medn_flag"] = "" // 医师编码
  3926. // inputData["imp_drug_flag"] = tm.Format("2006-01-02") // 医师编码
  3927. // inputData["prod_barc"] = tm.Format("2006-01-02") // 医师编码
  3928. // inputData["drug_prodname"] = tm.Format("2006-01-02") // 医师编码
  3929. //
  3930. // inputData["genname_codg"] = tm.Format("2006-01-02") // 医师编码
  3931. // inputData["drug_genname"] = tm.Format("2006-01-02") // 医师编码
  3932. // inputData["chemname"] = tm.Format("2006-01-02") // 医师编码
  3933. //
  3934. // inputData["drugstdcode"] = tm.Format("2006-01-02") // 医师编码
  3935. // inputData["drug_dosform"] = tm.Format("2006-01-02") // 医师编码
  3936. //
  3937. //
  3938. // inputData["drug_spec"] = tm.Format("2006-01-02") // 医师编码
  3939. // inputData["prdr_name"] = tm.Format("2006-01-02") // 医师编码
  3940. //
  3941. //
  3942. // inputData["drug_pric"] = tm.Format("2006-01-02") // 医师编码
  3943. // inputData["drug_cnt"] = tm.Format("2006-01-02") // 医师编码
  3944. // inputData["drug_cnt_unit"] = tm.Format("2006-01-02") // 医师编码
  3945. // inputData["drug_sumamt"] = tm.Format("2006-01-02") // 医师编码
  3946. // inputData["medc_way_codg"] = tm.Format("2006-01-02") // 医师编码
  3947. // inputData["medc_way_dscr"] = tm.Format("2006-01-02") // 医师编码
  3948. // inputData["medc_starttime"] = tm.Format("2006-01-02") // 医师编码
  3949. //
  3950. // inputData["medc_endtime"] = tm.Format("2006-01-02") // 医师编码
  3951. //
  3952. //
  3953. // inputData["medc_days"] = tm.Format("2006-01-02") // 医师编码
  3954. // inputData["drug_dosunt"] = tm.Format("2006-01-02") // 医师编码
  3955. // inputData["sin_doscnt"] = tm.Format("2006-01-02") // 医师编码
  3956. // inputData["sin_dosunt"] = tm.Format("2006-01-02") // 医师编码
  3957. // inputData["used_frqu_codg"] = tm.Format("2006-01-02") // 医师编码
  3958. //
  3959. //
  3960. // inputData["used_frqu_name"] = tm.Format("2006-01-02") // 医师编码
  3961. // inputData["drug_totlnt"] = tm.Format("2006-01-02") // 医师编码
  3962. //
  3963. // inputData["drug_totlnt_emp"] = tm.Format("2006-01-02") // 医师编码
  3964. // inputData["dise_codg"] = tm.Format("2006-01-02") // 医师编码
  3965. // inputData["drug_res"] = tm.Format("2006-01-02") // 医师编码
  3966. // inputData["drug_limit"] = tm.Format("2006-01-02") // 医师编码
  3967. //
  3968. //
  3969. //
  3970. //
  3971. //
  3972. //
  3973. //
  3974. //
  3975. //
  3976. // input["rxdrugdetail"] = inputData2
  3977. //
  3978. //
  3979. //
  3980. //
  3981. // inputMessage["input"] = input //交易输入
  3982. // bytesData, err := json.Marshal(inputMessage)
  3983. // fmt.Println(string(bytesData))
  3984. // if err != nil {
  3985. // fmt.Println(err.Error())
  3986. // return err.Error()
  3987. // }
  3988. // reader := bytes.NewReader(bytesData)
  3989. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2503"
  3990. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2503"
  3991. // gdyb_url := beego.AppConfig.String("gdyb_url")
  3992. // gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3993. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  3994. // url := gdyb_url + "2503"
  3995. //
  3996. // request, err := http.NewRequest("POST", url, reader)
  3997. // if err != nil {
  3998. // fmt.Println(err.Error())
  3999. // return err.Error()
  4000. // }
  4001. //
  4002. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4003. // request.Header.Set("x-tif-paasid", gdyb_paasid)
  4004. // request.Header.Set("x-tif-signature", signature)
  4005. // request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4006. // request.Header.Set("x-tif-nonce", nonce)
  4007. //
  4008. // client := http.Client{}
  4009. // resp, err := client.Do(request)
  4010. // if err != nil {
  4011. // fmt.Println(err.Error())
  4012. // return err.Error()
  4013. // }
  4014. // respBytes, err := ioutil.ReadAll(resp.Body)
  4015. // if err != nil {
  4016. // fmt.Println(err.Error())
  4017. // return err.Error()
  4018. // }
  4019. // str := string(respBytes)
  4020. // fmt.Println(str)
  4021. // return str
  4022. //}
  4023. // 生成签名
  4024. func setSignature(timestamp int64, nonce string, secret_key string) string {
  4025. fmt.Println(timestamp)
  4026. fmt.Println(nonce)
  4027. fmt.Println(secret_key)
  4028. fmt.Println(strconv.FormatInt(timestamp, 10))
  4029. fmt.Println(time.Now().UnixNano() / 1e6)
  4030. str := strconv.FormatInt(timestamp, 10) + secret_key + nonce + strconv.FormatInt(timestamp, 10)
  4031. hash := sha256.New()
  4032. //输入数据
  4033. hash.Write([]byte(str))
  4034. //计算哈希值
  4035. bytes := hash.Sum(nil)
  4036. //将字符串编码为16进制格式,返回字符串
  4037. hashCode := hex.EncodeToString(bytes)
  4038. //返回哈希值
  4039. return hashCode
  4040. }
  4041. const charset = "abcdefghijklmnopqrstuvwxyz" +
  4042. "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
  4043. var seededRand *rand.Rand = rand.New(
  4044. rand.NewSource(time.Now().UnixNano()))
  4045. // 生成随机字符串
  4046. func GetRandomString(l int) string {
  4047. //str := "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
  4048. //bytes := []byte(str)
  4049. //result := []byte{}
  4050. //r := rand.New(rand.NewSource(time.Now().UnixNano()))
  4051. //for i := 0; i < l; i++ {
  4052. // result = append(result, bytes[r.Intn(len(bytes))])
  4053. //}
  4054. return String(32)
  4055. }
  4056. func StringWithCharset(length int, charset string) string {
  4057. b := make([]byte, length)
  4058. for i := range b {
  4059. b[i] = charset[seededRand.Intn(len(charset))]
  4060. }
  4061. return string(b)
  4062. }
  4063. func String(length int) string {
  4064. return StringWithCharset(length, charset)
  4065. }
  4066. // 生成基础报文
  4067. func SetInputMessage1111(nonce string, timestamp int64, org_name string, doctor int64, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, op_name string) map[string]interface{} {
  4068. // 生成签名
  4069. tempTime := time.Unix(timestamp, 0)
  4070. //timeFormat := tempTime.Format("20060102150405")
  4071. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  4072. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  4073. month := time.Unix(1557042972, 0).Format("1")
  4074. year := time.Now().Format("2006")
  4075. month = time.Now().Format("01")
  4076. day := time.Now().Format("02")
  4077. hour := time.Now().Format("15")
  4078. min := time.Now().Format("04")
  4079. sec := time.Now().Format("05")
  4080. msec := time.Now().Format("000")
  4081. // 生成输入报文
  4082. inputMessage := make(map[string]interface{})
  4083. inputMessage["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  4084. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  4085. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  4086. inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  4087. inputMessage["dev_no"] = "" // 设备编号
  4088. inputMessage["dev_safe_info"] = "" // 设备安全信息
  4089. inputMessage["cainfo"] = "" // 数字签名信息
  4090. inputMessage["signtype"] = "MOCK" // 签名类型
  4091. inputMessage["infver"] = "V1.0" // 接收方系统代码
  4092. inputMessage["opter_type"] = "1" // 经办人类别
  4093. inputMessage["opter"] = doctor // 经办人
  4094. inputMessage["opter_name"] = op_name // 经办人姓名
  4095. inputMessage["inf_time"] = timeFormatOne // 交易时间
  4096. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  4097. inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  4098. if mdtrtarea_admvs == "440100" {
  4099. inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号
  4100. } else {
  4101. inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号 //交易签到流水号
  4102. }
  4103. return inputMessage
  4104. }
  4105. func SetInputMessage(nonce string, timestamp int64, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) map[string]interface{} {
  4106. // 生成签名
  4107. tempTime := time.Unix(timestamp, 0)
  4108. //timeFormat := tempTime.Format("20060102150405")
  4109. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  4110. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  4111. month := time.Unix(1557042972, 0).Format("1")
  4112. year := time.Now().Format("2006")
  4113. month = time.Now().Format("01")
  4114. day := time.Now().Format("02")
  4115. hour := time.Now().Format("15")
  4116. min := time.Now().Format("04")
  4117. sec := time.Now().Format("05")
  4118. msec := time.Now().Format("000")
  4119. // 生成输入报文
  4120. inputMessage := make(map[string]interface{})
  4121. inputMessage["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  4122. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  4123. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  4124. inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  4125. inputMessage["dev_no"] = "" // 设备编号
  4126. inputMessage["dev_safe_info"] = "" // 设备安全信息
  4127. inputMessage["cainfo"] = "" // 数字签名信息
  4128. inputMessage["signtype"] = "MOCK" // 签名类型
  4129. inputMessage["infver"] = "V1.0" // 接收方系统代码
  4130. inputMessage["opter_type"] = "1" // 经办人类别
  4131. inputMessage["opter"] = doctor // 经办人
  4132. inputMessage["opter_name"] = doctor // 经办人姓名
  4133. inputMessage["inf_time"] = timeFormatOne // 交易时间
  4134. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  4135. inputMessage["fixmedins_name"] = org_name
  4136. inputMessage["sign_no"] = "489925883" //交易签到流水号
  4137. //定点医药机构名称
  4138. //if mdtrtarea_admvs == "440100" {
  4139. // inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号
  4140. //} else {
  4141. // inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号 //交易签到流水号
  4142. //}
  4143. return inputMessage
  4144. }
  4145. func SetInputMessagenosign(nonce string, timestamp int64, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) map[string]interface{} {
  4146. // 生成签名
  4147. tempTime := time.Unix(timestamp, 0)
  4148. //timeFormat := tempTime.Format("20060102150405")
  4149. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  4150. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  4151. month := time.Unix(1557042972, 0).Format("1")
  4152. year := time.Now().Format("2006")
  4153. month = time.Now().Format("01")
  4154. day := time.Now().Format("02")
  4155. hour := time.Now().Format("15")
  4156. min := time.Now().Format("04")
  4157. sec := time.Now().Format("05")
  4158. msec := time.Now().Format("000")
  4159. // 生成输入报文
  4160. inputMessage := make(map[string]interface{})
  4161. inputMessage["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  4162. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  4163. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  4164. inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  4165. inputMessage["dev_no"] = "" // 设备编号
  4166. inputMessage["dev_safe_info"] = "" // 设备安全信息
  4167. inputMessage["cainfo"] = "" // 数字签名信息
  4168. inputMessage["signtype"] = "MOCK" // 签名类型
  4169. inputMessage["infver"] = "V1.0" // 接收方系统代码
  4170. inputMessage["opter_type"] = "1" // 经办人类别
  4171. inputMessage["opter"] = doctor // 经办人
  4172. inputMessage["opter_name"] = doctor // 经办人姓名
  4173. inputMessage["inf_time"] = timeFormatOne // 交易时间
  4174. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  4175. inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  4176. if mdtrtarea_admvs == "440100" {
  4177. inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号
  4178. } else {
  4179. inputMessage["sign_no"] = ""
  4180. }
  4181. return inputMessage
  4182. }
  4183. //func GetSignInInfo(code string) string {
  4184. // var sign models.HisSignIn
  4185. // err = readDb.Model(&models.HisSignIn{}).Where("fixmedins_code = ? AND status = 1", code).Last(&sign).Error
  4186. // return sign.SignNo
  4187. //}
  4188. 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{} {
  4189. // 生成签名
  4190. tempTime := time.Unix(timestamp, 0)
  4191. //timeFormat := tempTime.Format("20060102150405")
  4192. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  4193. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  4194. // 生成输入报文
  4195. inputMessage := make(map[string]interface{})
  4196. inputMessage["msgid"] = msg_id // 发送方报文 ID
  4197. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  4198. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  4199. inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  4200. inputMessage["dev_no"] = "" // 设备编号
  4201. inputMessage["dev_safe_info"] = "" // 设备安全信息
  4202. inputMessage["cainfo"] = "" // 数字签名信息
  4203. inputMessage["signtype"] = "SM3" // 签名类型
  4204. inputMessage["infver"] = "V1.0" // 接收方系统代码
  4205. inputMessage["opter_type"] = "1" // 经办人类别
  4206. inputMessage["opter"] = doctor // 经办人
  4207. inputMessage["opter_name"] = doctor // 经办人姓名
  4208. inputMessage["inf_time"] = timeFormatOne // 交易时间
  4209. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  4210. inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  4211. if mdtrtarea_admvs == "440100" {
  4212. inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号
  4213. } else {
  4214. inputMessage["sign_no"] = "" //交易签到流水号
  4215. }
  4216. return inputMessage
  4217. }
  4218. 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{} {
  4219. // 生成签名
  4220. tempTime := time.Unix(timestamp, 0)
  4221. //timeFormat := tempTime.Format("20060102150405")
  4222. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  4223. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  4224. month := time.Unix(1557042972, 0).Format("1")
  4225. year := time.Now().Format("2006")
  4226. month = time.Now().Format("01")
  4227. day := time.Now().Format("02")
  4228. hour := time.Now().Format("15")
  4229. min := time.Now().Format("04")
  4230. sec := time.Now().Format("05")
  4231. msec := time.Now().Format("000")
  4232. // 生成输入报文
  4233. inputMessage := make(map[string]interface{})
  4234. inputMessage["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  4235. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  4236. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  4237. inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  4238. inputMessage["dev_no"] = "" // 设备编号
  4239. inputMessage["dev_safe_info"] = "" // 设备安全信息
  4240. inputMessage["cainfo"] = "" // 数字签名信息
  4241. inputMessage["signtype"] = "SM3" // 签名类型
  4242. inputMessage["infver"] = "V1.0" // 接收方系统代码
  4243. inputMessage["opter_type"] = "1" // 经办人类别
  4244. inputMessage["opter"] = doctor // 经办人
  4245. inputMessage["opter_name"] = doctor // 经办人姓名
  4246. inputMessage["inf_time"] = timeFormatOne // 交易时间
  4247. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  4248. inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  4249. if mdtrtarea_admvs == "440100" {
  4250. inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号
  4251. } else {
  4252. inputMessage["sign_no"] = sign_no //交易签到流水号
  4253. }
  4254. return inputMessage
  4255. }
  4256. func postFile(filename string, target_url string) (*http.Response, error) {
  4257. body_buf := bytes.NewBufferString("")
  4258. body_writer := multipart.NewWriter(body_buf)
  4259. // use the body_writer to write the Part headers to the buffer
  4260. _, err := body_writer.CreateFormFile("userfile", filename)
  4261. if err != nil {
  4262. fmt.Println("error writing to buffer")
  4263. return nil, err
  4264. }
  4265. // the file data will be the second part of the body
  4266. fh, err := os.Open(filename)
  4267. if err != nil {
  4268. fmt.Println("error opening file")
  4269. return nil, err
  4270. }
  4271. // need to know the boundary to properly close the part myself.
  4272. boundary := body_writer.Boundary()
  4273. //close_string := fmt.Sprintf("\r\n--%s--\r\n", boundary)
  4274. close_buf := bytes.NewBufferString(fmt.Sprintf("\r\n--%s--\r\n", boundary))
  4275. // use multi-reader to defer the reading of the file data until
  4276. // writing to the socket buffer.
  4277. request_reader := io.MultiReader(body_buf, fh, close_buf)
  4278. fi, err := fh.Stat()
  4279. if err != nil {
  4280. fmt.Printf("Error Stating file: %s", filename)
  4281. return nil, err
  4282. }
  4283. req, err := http.NewRequest("POST", target_url, request_reader)
  4284. if err != nil {
  4285. return nil, err
  4286. }
  4287. // Set headers for multipart, and Content Length
  4288. req.Header.Add("Content-Type", "multipart/form-data; boundary="+boundary)
  4289. req.ContentLength = fi.Size() + int64(body_buf.Len()) + int64(close_buf.Len())
  4290. return http.DefaultClient.Do(req)
  4291. }
  4292. //func Gdyb1201(psnNo string, org_name string, doctor string) string {
  4293. // // 生成签名
  4294. // nonce := GetRandomString(32)
  4295. // timestamp := time.Now().Unix()
  4296. // signature := setSignature(timestamp, nonce)
  4297. //
  4298. // // 生成输入报文
  4299. // inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, "")
  4300. // input := make(map[string]interface{})
  4301. // inputData := make(map[string]interface{})
  4302. // inputMessage["infno"] = "1201" // 交易编码
  4303. // inputData["fixmedins_type"] = psnNo // 人员编号 (来自1101接口返回)
  4304. // inputData["fixmedins_name"] = org_name // 人员编号 (来自1101接口返回)
  4305. // inputData["fixmedins_code"] = "" // 人员编号 (来自1101接口返回)
  4306. //
  4307. // input["medinsinfo"] = inputData
  4308. // inputMessage["input"] = input //交易输入
  4309. //
  4310. // bytesData, err := json.Marshal(inputMessage)
  4311. // fmt.Println(string(bytesData))
  4312. // if err != nil {
  4313. // fmt.Println(err.Error())
  4314. // return err.Error()
  4315. // }
  4316. // reader := bytes.NewReader(bytesData)
  4317. //
  4318. // url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1201"
  4319. // request, err := http.NewRequest("POST", url, reader)
  4320. // if err != nil {
  4321. // fmt.Println(err.Error())
  4322. // return err.Error()
  4323. // }
  4324. //
  4325. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4326. // request.Header.Set("x-tif-paasid", "test_hosp")
  4327. // request.Header.Set("x-tif-signature", signature)
  4328. // request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4329. // request.Header.Set("x-tif-nonce", nonce)
  4330. //
  4331. // client := http.Client{}
  4332. // resp, err := client.Do(request)
  4333. // if err != nil {
  4334. // fmt.Println(err.Error())
  4335. // return err.Error()
  4336. // }
  4337. // respBytes, err := ioutil.ReadAll(resp.Body)
  4338. // if err != nil {
  4339. // fmt.Println(err.Error())
  4340. // return err.Error()
  4341. // }
  4342. // str := string(respBytes)
  4343. // fmt.Println(str)
  4344. // return str
  4345. //}
  4346. func newfileUploadRequest(uri string, params map[string]string, paramName, path string) (*http.Request, error) {
  4347. file, err := os.Open(path)
  4348. if err != nil {
  4349. return nil, err
  4350. }
  4351. defer file.Close()
  4352. body := &bytes.Buffer{}
  4353. writer := multipart.NewWriter(body)
  4354. part, err := writer.CreateFormFile(paramName, filepath.Base(path))
  4355. if err != nil {
  4356. return nil, err
  4357. }
  4358. _, err = io.Copy(part, file)
  4359. for key, val := range params {
  4360. _ = writer.WriteField(key, val)
  4361. }
  4362. err = writer.Close()
  4363. if err != nil {
  4364. return nil, err
  4365. }
  4366. req, err := http.NewRequest("POST", uri, body)
  4367. req.Header.Set("Content-Type", writer.FormDataContentType())
  4368. return req, err
  4369. }
  4370. func CreateMedicalInsuranceCostCompareRecord(record *models.MedicalInsuranceCostCompare) error {
  4371. err := writeDb.Save(&record).Error
  4372. return err
  4373. }
  4374. //func Gdyb5203(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  4375. // // 生成签名
  4376. // nonce := GetRandomString(32)
  4377. // timestamp := time.Now().Unix()
  4378. // signature := setSignature(timestamp, nonce, secret_key)
  4379. //
  4380. // // 生成输入报文
  4381. // inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4382. // input := make(map[string]interface{})
  4383. // inputData := make(map[string]interface{})
  4384. // inputMessage["infno"] = "5203" // 交易编码
  4385. //
  4386. // inputData["fixmedins_type"] = "1"
  4387. // inputData["fixmedins_name"] = org_name
  4388. // inputData["fixmedins_code"] = fixmedins_code
  4389. // input["medinsinfo"] = inputData
  4390. // inputMessage["input"] = input //交易输入
  4391. //
  4392. // bytesData, err := json.Marshal(inputMessage)
  4393. // fmt.Println(string(bytesData))
  4394. // if err != nil {
  4395. // fmt.Println(err.Error())
  4396. // return err.Error()
  4397. // }
  4398. // reader := bytes.NewReader(bytesData)
  4399. // url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1201"
  4400. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1201"
  4401. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4402. // request, err := http.NewRequest("POST", url, reader)
  4403. // if err != nil {
  4404. // fmt.Println(err.Error())
  4405. // return err.Error()
  4406. // }
  4407. //
  4408. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4409. // request.Header.Set("x-tif-paasid", "sg03_prd")
  4410. // request.Header.Set("x-tif-signature", signature)
  4411. // request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4412. // request.Header.Set("x-tif-nonce", nonce)
  4413. //
  4414. // client := http.Client{}
  4415. // resp, err := client.Do(request)
  4416. // if err != nil {
  4417. // fmt.Println(err.Error())
  4418. // return err.Error()
  4419. // }
  4420. // respBytes, err := ioutil.ReadAll(resp.Body)
  4421. // if err != nil {
  4422. // fmt.Println(err.Error())
  4423. // return err.Error()
  4424. // }
  4425. // fmt.Println(string(respBytes))
  4426. // str := string(respBytes)
  4427. // return str
  4428. //}
  4429. func CreatePsnRecord(record *models.GdybPsnRecord) {
  4430. writeDb.Save(&record)
  4431. return
  4432. }
  4433. func GetPsnRecordById(id int64) (record models.GdybPsnRecord, err error) {
  4434. err = readDb.Model(&models.GdybPsnRecord{}).Where("id = ?").First(&record).Error
  4435. return
  4436. }
  4437. func CreatePsnNCDSRecord(record *models.GdybPsnNcdsRecord) {
  4438. writeDb.Save(&record)
  4439. return
  4440. }
  4441. func GetPsnNCDSRecordById(id int64) (record models.GdybPsnNcdsRecord, err error) {
  4442. err = readDb.Model(&models.GdybPsnNcdsRecord{}).Where("id = ?", id).First(&record).Error
  4443. return
  4444. }
  4445. func GetPatientsByIds(ids []string, current_org_id int64) (patients []*models.Patients, err error) {
  4446. err = readDb.Model(&models.Patients{}).Where("id IN (?) AND user_org_id = ?", ids, current_org_id).Find(&patients).Error
  4447. return
  4448. }
  4449. 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 {
  4450. // 生成签名
  4451. nonce := GetRandomString(32)
  4452. timestamp := time.Now().Unix()
  4453. signature := setSignature(timestamp, nonce, secret_key)
  4454. // 生成输入报文
  4455. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4456. input := make(map[string]interface{})
  4457. inputData := make(map[string]interface{})
  4458. inputMessage["infno"] = "2601" // 交易编码
  4459. inputData["psn_no"] = psnNo
  4460. inputData["omsgid"] = omsgid
  4461. inputData["oinfno"] = oinfno
  4462. input["data"] = inputData
  4463. inputMessage["input"] = input //交易输入
  4464. bytesData, err := json.Marshal(inputMessage)
  4465. fmt.Println(string(bytesData))
  4466. if err != nil {
  4467. fmt.Println(err.Error())
  4468. return err.Error()
  4469. }
  4470. reader := bytes.NewReader(bytesData)
  4471. gdyb_url := beego.AppConfig.String("gdyb_url")
  4472. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4473. url := gdyb_url + "2601"
  4474. request, err := http.NewRequest("POST", url, reader)
  4475. if err != nil {
  4476. fmt.Println(err.Error())
  4477. return err.Error()
  4478. }
  4479. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4480. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4481. request.Header.Set("x-tif-signature", signature)
  4482. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4483. request.Header.Set("x-tif-nonce", nonce)
  4484. client := http.Client{}
  4485. resp, err := client.Do(request)
  4486. if err != nil {
  4487. fmt.Println(err.Error())
  4488. return err.Error()
  4489. }
  4490. respBytes, err := ioutil.ReadAll(resp.Body)
  4491. if err != nil {
  4492. fmt.Println(err.Error())
  4493. return err.Error()
  4494. }
  4495. str := string(respBytes)
  4496. fmt.Println(str)
  4497. return str
  4498. }
  4499. // 人员信息版本3
  4500. func Gdyb1101B(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, card_sn string, certificates int64, name string, cardNumber string, admin_user_id int64) string {
  4501. //生成签名
  4502. nonce := GetRandomString(32)
  4503. timestamp := time.Now().Unix()
  4504. signature := setSignature(timestamp, nonce, secret_key)
  4505. //生成输入报文
  4506. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4507. inputMessage := make(map[string]interface{})
  4508. //生成输入报文
  4509. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  4510. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  4511. } else {
  4512. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4513. }
  4514. input := make(map[string]interface{})
  4515. inputData := make(map[string]interface{})
  4516. inputMessage["infno"] = "1101" // 交易编码
  4517. if certificates == 3 {
  4518. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  4519. inputData["certno"] = "01836483" // 证件号码
  4520. inputData["psn_cert_type"] = "01" // 人员证件类型
  4521. inputData["mdtrt_cert_no"] = "01836483" // 就诊凭证编号
  4522. } else {
  4523. if certificates == 1 {
  4524. if id_card_type == 1 {
  4525. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  4526. inputData["card_sn"] = card_sn // 卡识别码
  4527. inputData["certno"] = certNo // 证件号码
  4528. inputData["psn_cert_type"] = "01" // 人员证件类型
  4529. inputData["mdtrt_cert_no"] = cardNumber // 就诊凭证编号
  4530. } else {
  4531. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  4532. inputData["card_sn"] = "" // 卡识别码
  4533. inputData["certno"] = certNo // 证件号码
  4534. inputData["psn_cert_type"] = "01" // 人员证件类型
  4535. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  4536. }
  4537. } else if certificates == 6 {
  4538. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  4539. inputData["card_sn"] = "" // 卡识别码
  4540. inputData["certno"] = certNo // 证件号码
  4541. inputData["psn_cert_type"] = "17" // 人员证件类型
  4542. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  4543. }
  4544. }
  4545. inputData["begntime"] = "" // 开始时间
  4546. inputData["psn_name"] = name // 人员姓名
  4547. input["data"] = inputData
  4548. inputMessage["input"] = input //交易输入
  4549. bytesData, err := json.Marshal(inputMessage)
  4550. fmt.Println(string(bytesData))
  4551. if err != nil {
  4552. fmt.Println(err.Error())
  4553. return err.Error()
  4554. }
  4555. reader := bytes.NewReader(bytesData)
  4556. gdyb_url := beego.AppConfig.String("gdyb_url")
  4557. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4558. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4559. //url := gdyb_url + "1101"
  4560. var url string
  4561. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  4562. url = gdyb_url
  4563. } else {
  4564. url = gdyb_url + "1101"
  4565. }
  4566. fmt.Println(url)
  4567. fmt.Println(gdyb_paasid)
  4568. fmt.Println(secret_key)
  4569. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4570. request, err := http.NewRequest("POST", url, reader)
  4571. if err != nil {
  4572. fmt.Println(err.Error())
  4573. return err.Error()
  4574. }
  4575. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4576. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4577. request.Header.Set("x-tif-signature", signature)
  4578. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4579. request.Header.Set("x-tif-nonce", nonce)
  4580. client := http.Client{}
  4581. resp, err := client.Do(request)
  4582. if err != nil {
  4583. fmt.Println(err.Error())
  4584. return err.Error()
  4585. }
  4586. respBytes, err := ioutil.ReadAll(resp.Body)
  4587. if err != nil {
  4588. fmt.Println(err.Error())
  4589. return err.Error()
  4590. }
  4591. fmt.Println(string(respBytes))
  4592. str := string(respBytes)
  4593. return str
  4594. }
  4595. func Gdyb1101d(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, card_sn string, certificates int64, name string, token string, admin_user_id int64) string {
  4596. //生成签名
  4597. nonce := GetRandomString(32)
  4598. timestamp := time.Now().Unix()
  4599. signature := setSignature(timestamp, nonce, secret_key)
  4600. inputMessage := make(map[string]interface{})
  4601. //生成输入报文
  4602. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  4603. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  4604. } else {
  4605. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4606. }
  4607. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4608. input := make(map[string]interface{})
  4609. inputData := make(map[string]interface{})
  4610. inputMessage["infno"] = "1101" // 交易编码
  4611. if certificates == 3 {
  4612. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  4613. inputData["certno"] = "01836483" // 证件号码
  4614. inputData["psn_cert_type"] = "01" // 人员证件类型
  4615. inputData["mdtrt_cert_no"] = "01836483" // 就诊凭证编号
  4616. } else {
  4617. if certificates == 1 {
  4618. if id_card_type == 4 {
  4619. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  4620. inputData["card_sn"] = card_sn // 卡识别码
  4621. inputData["certno"] = certNo // 证件号码
  4622. inputData["psn_cert_type"] = "01" // 人员证件类型
  4623. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  4624. }
  4625. } else if certificates == 6 {
  4626. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  4627. inputData["card_sn"] = "" // 卡识别码
  4628. inputData["certno"] = certNo // 证件号码
  4629. inputData["psn_cert_type"] = "17" // 人员证件类型
  4630. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  4631. }
  4632. }
  4633. inputData["begntime"] = "" // 开始时间
  4634. inputData["psn_name"] = name // 人员姓名
  4635. input["data"] = inputData
  4636. inputMessage["input"] = input //交易输入
  4637. bytesData, err := json.Marshal(inputMessage)
  4638. fmt.Println(string(bytesData))
  4639. if err != nil {
  4640. fmt.Println(err.Error())
  4641. return err.Error()
  4642. }
  4643. reader := bytes.NewReader(bytesData)
  4644. gdyb_url := beego.AppConfig.String("gdyb_url")
  4645. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4646. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4647. //url := gdyb_url + "1101"
  4648. var url string
  4649. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  4650. url = gdyb_url
  4651. } else {
  4652. url = gdyb_url + "1101"
  4653. }
  4654. fmt.Println(url)
  4655. fmt.Println(gdyb_paasid)
  4656. fmt.Println(secret_key)
  4657. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4658. request, err := http.NewRequest("POST", url, reader)
  4659. if err != nil {
  4660. fmt.Println(err.Error())
  4661. return err.Error()
  4662. }
  4663. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4664. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4665. request.Header.Set("x-tif-signature", signature)
  4666. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4667. request.Header.Set("x-tif-nonce", nonce)
  4668. client := http.Client{}
  4669. resp, err := client.Do(request)
  4670. if err != nil {
  4671. fmt.Println(err.Error())
  4672. return err.Error()
  4673. }
  4674. respBytes, err := ioutil.ReadAll(resp.Body)
  4675. if err != nil {
  4676. fmt.Println(err.Error())
  4677. return err.Error()
  4678. }
  4679. fmt.Println(string(respBytes))
  4680. str := string(respBytes)
  4681. return str
  4682. }
  4683. 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 {
  4684. //生成签名
  4685. nonce := GetRandomString(32)
  4686. timestamp := time.Now().Unix()
  4687. signature := setSignature(timestamp, nonce, secret_key)
  4688. //生成输入报文
  4689. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4690. input := make(map[string]interface{})
  4691. inputData := make(map[string]interface{})
  4692. inputMessage["infno"] = "1101" // 交易编码
  4693. if certificates == 3 {
  4694. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  4695. inputData["certno"] = "01836483" // 证件号码
  4696. inputData["psn_cert_type"] = "01" // 人员证件类型
  4697. inputData["mdtrt_cert_no"] = "01836483" // 就诊凭证编号
  4698. } else {
  4699. if certificates == 1 {
  4700. if id_card_type == 1 {
  4701. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  4702. inputData["card_sn"] = "" // 卡识别码
  4703. inputData["certno"] = certNo // 证件号码
  4704. inputData["psn_cert_type"] = "01" // 人员证件类型
  4705. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  4706. } else {
  4707. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  4708. inputData["card_sn"] = "" // 卡识别码
  4709. inputData["certno"] = certNo // 证件号码
  4710. inputData["psn_cert_type"] = "" // 人员证件类型
  4711. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  4712. }
  4713. } else if certificates == 6 {
  4714. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  4715. inputData["card_sn"] = "" // 卡识别码
  4716. inputData["certno"] = certNo // 证件号码
  4717. inputData["psn_cert_type"] = "" // 人员证件类型
  4718. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  4719. }
  4720. }
  4721. inputData["begntime"] = "" // 开始时间
  4722. inputData["psn_name"] = "" // 人员姓名
  4723. input["data"] = inputData
  4724. inputMessage["input"] = input //交易输入
  4725. bytesData, err := json.Marshal(inputMessage)
  4726. fmt.Println(string(bytesData))
  4727. if err != nil {
  4728. fmt.Println(err.Error())
  4729. return err.Error()
  4730. }
  4731. reader := bytes.NewReader(bytesData)
  4732. gdyb_url := beego.AppConfig.String("gdyb_url")
  4733. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4734. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4735. //url := gdyb_url + "1101"
  4736. var url string
  4737. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  4738. url = gdyb_url
  4739. } else {
  4740. url = gdyb_url + "1101"
  4741. }
  4742. fmt.Println(url)
  4743. fmt.Println(gdyb_paasid)
  4744. fmt.Println(secret_key)
  4745. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4746. request, err := http.NewRequest("POST", url, reader)
  4747. if err != nil {
  4748. fmt.Println(err.Error())
  4749. return err.Error()
  4750. }
  4751. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4752. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4753. request.Header.Set("x-tif-signature", signature)
  4754. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4755. request.Header.Set("x-tif-nonce", nonce)
  4756. client := http.Client{}
  4757. resp, err := client.Do(request)
  4758. if err != nil {
  4759. fmt.Println(err.Error())
  4760. return err.Error()
  4761. }
  4762. respBytes, err := ioutil.ReadAll(resp.Body)
  4763. if err != nil {
  4764. fmt.Println(err.Error())
  4765. return err.Error()
  4766. }
  4767. fmt.Println(string(respBytes))
  4768. str := string(respBytes)
  4769. return str
  4770. }
  4771. 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 {
  4772. //生成签名
  4773. nonce := GetRandomString(32)
  4774. timestamp := time.Now().Unix()
  4775. signature := setSignature(timestamp, nonce, secret_key)
  4776. //生成输入报文
  4777. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4778. input := make(map[string]interface{})
  4779. inputData := make(map[string]interface{})
  4780. inputMessage["infno"] = "1101" // 交易编码
  4781. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  4782. inputData["card_sn"] = card_sn // 卡识别码
  4783. inputData["certno"] = certNo // 证件号码
  4784. inputData["psn_cert_type"] = "01" // 人员证件类型
  4785. inputData["mdtrt_cert_no"] = cardNumber // 就诊凭证编号
  4786. inputData["begntime"] = "" // 开始时间
  4787. inputData["psn_name"] = name // 人员姓名
  4788. input["data"] = inputData
  4789. inputMessage["input"] = input //交易输入
  4790. bytesData, err := json.Marshal(inputMessage)
  4791. fmt.Println(string(bytesData))
  4792. if err != nil {
  4793. fmt.Println(err.Error())
  4794. return err.Error()
  4795. }
  4796. reader := bytes.NewReader(bytesData)
  4797. gdyb_url := beego.AppConfig.String("gdyb_url")
  4798. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4799. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4800. //url := gdyb_url + "1101"
  4801. var url string
  4802. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  4803. url = gdyb_url
  4804. } else {
  4805. url = gdyb_url + "1101"
  4806. }
  4807. fmt.Println(url)
  4808. fmt.Println(gdyb_paasid)
  4809. fmt.Println(secret_key)
  4810. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4811. request, err := http.NewRequest("POST", url, reader)
  4812. if err != nil {
  4813. fmt.Println(err.Error())
  4814. return err.Error()
  4815. }
  4816. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4817. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4818. request.Header.Set("x-tif-signature", signature)
  4819. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4820. request.Header.Set("x-tif-nonce", nonce)
  4821. client := http.Client{}
  4822. resp, err := client.Do(request)
  4823. if err != nil {
  4824. fmt.Println(err.Error())
  4825. return err.Error()
  4826. }
  4827. respBytes, err := ioutil.ReadAll(resp.Body)
  4828. if err != nil {
  4829. fmt.Println(err.Error())
  4830. return err.Error()
  4831. }
  4832. fmt.Println(string(respBytes))
  4833. str := string(respBytes)
  4834. return str
  4835. }
  4836. func Gdyb1101ForEleCert1111(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, token string, user_name string, idNo string, certificates int64) (string, string) {
  4837. //生成签名
  4838. nonce := GetRandomString(32)
  4839. timestamp := time.Now().Unix()
  4840. signature := setSignature(timestamp, nonce, secret_key)
  4841. //生成输入报文
  4842. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4843. input := make(map[string]interface{})
  4844. inputData := make(map[string]interface{})
  4845. inputMessage["infno"] = "1101" // 交易编码
  4846. if certificates == 6 {
  4847. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  4848. inputData["psn_cert_type"] = "" // 人员证件类型
  4849. } else {
  4850. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  4851. inputData["psn_cert_type"] = "01" // 人员证件类型
  4852. }
  4853. inputData["card_sn"] = "" // 卡识别码
  4854. inputData["certno"] = idNo // 证件号码
  4855. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  4856. inputData["begntime"] = "" // 开始时间
  4857. inputData["psn_name"] = user_name // 人员姓名
  4858. input["data"] = inputData
  4859. inputMessage["input"] = input //交易输入
  4860. bytesData, err := json.Marshal(inputMessage)
  4861. fmt.Println(string(bytesData))
  4862. if err != nil {
  4863. fmt.Println(err.Error())
  4864. return err.Error(), ""
  4865. }
  4866. reader := bytes.NewReader(bytesData)
  4867. gdyb_url := beego.AppConfig.String("gdyb_url")
  4868. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4869. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4870. //url := gdyb_url + "1101"
  4871. var url string
  4872. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  4873. url = gdyb_url
  4874. } else {
  4875. url = gdyb_url + "1101"
  4876. }
  4877. fmt.Println(url)
  4878. fmt.Println(gdyb_paasid)
  4879. fmt.Println(secret_key)
  4880. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4881. request, err := http.NewRequest("POST", url, reader)
  4882. if err != nil {
  4883. fmt.Println(err.Error())
  4884. return err.Error(), ""
  4885. }
  4886. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4887. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4888. request.Header.Set("x-tif-signature", signature)
  4889. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4890. request.Header.Set("x-tif-nonce", nonce)
  4891. client := http.Client{}
  4892. resp, err := client.Do(request)
  4893. if err != nil {
  4894. fmt.Println(err.Error())
  4895. return err.Error(), ""
  4896. }
  4897. respBytes, err := ioutil.ReadAll(resp.Body)
  4898. if err != nil {
  4899. fmt.Println(err.Error())
  4900. return err.Error(), ""
  4901. }
  4902. fmt.Println(string(respBytes))
  4903. str := string(respBytes)
  4904. return str, string(bytesData)
  4905. }
  4906. 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) {
  4907. //生成签名
  4908. nonce := GetRandomString(32)
  4909. timestamp := time.Now().Unix()
  4910. signature := setSignature(timestamp, nonce, secret_key)
  4911. //生成输入报文
  4912. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4913. input := make(map[string]interface{})
  4914. inputData := make(map[string]interface{})
  4915. inputMessage["infno"] = "1101" // 交易编码
  4916. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  4917. inputData["psn_cert_type"] = "01" // 人员证件类型
  4918. inputData["card_sn"] = "" // 卡识别码
  4919. inputData["certno"] = idNo // 证件号码
  4920. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  4921. inputData["begntime"] = "" // 开始时间
  4922. inputData["psn_name"] = user_name // 人员姓名
  4923. input["data"] = inputData
  4924. inputMessage["input"] = input //交易输入
  4925. bytesData, err := json.Marshal(inputMessage)
  4926. fmt.Println(string(bytesData))
  4927. if err != nil {
  4928. fmt.Println(err.Error())
  4929. return err.Error(), ""
  4930. }
  4931. reader := bytes.NewReader(bytesData)
  4932. gdyb_url := beego.AppConfig.String("gdyb_url")
  4933. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4934. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  4935. //url := gdyb_url + "1101"
  4936. var url string
  4937. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  4938. url = gdyb_url
  4939. } else {
  4940. url = gdyb_url + "1101"
  4941. }
  4942. fmt.Println(url)
  4943. fmt.Println(gdyb_paasid)
  4944. fmt.Println(secret_key)
  4945. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  4946. request, err := http.NewRequest("POST", url, reader)
  4947. if err != nil {
  4948. fmt.Println(err.Error())
  4949. return err.Error(), ""
  4950. }
  4951. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  4952. request.Header.Set("x-tif-paasid", gdyb_paasid)
  4953. request.Header.Set("x-tif-signature", signature)
  4954. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  4955. request.Header.Set("x-tif-nonce", nonce)
  4956. client := http.Client{}
  4957. resp, err := client.Do(request)
  4958. if err != nil {
  4959. fmt.Println(err.Error())
  4960. return err.Error(), ""
  4961. }
  4962. respBytes, err := ioutil.ReadAll(resp.Body)
  4963. if err != nil {
  4964. fmt.Println(err.Error())
  4965. return err.Error(), ""
  4966. }
  4967. fmt.Println(string(respBytes))
  4968. str := string(respBytes)
  4969. return str, string(bytesData)
  4970. }
  4971. 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) {
  4972. //生成签名
  4973. nonce := GetRandomString(32)
  4974. timestamp := time.Now().Unix()
  4975. signature := setSignature(timestamp, nonce, secret_key)
  4976. //生成输入报文
  4977. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  4978. input := make(map[string]interface{})
  4979. inputData := make(map[string]interface{})
  4980. inputMessage["infno"] = "1101" // 交易编码
  4981. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  4982. inputData["card_sn"] = "" // 卡识别码
  4983. inputData["certno"] = idNo // 证件号码
  4984. inputData["psn_cert_type"] = "01" // 人员证件类型
  4985. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  4986. inputData["begntime"] = "" // 开始时间
  4987. inputData["psn_name"] = user_name // 人员姓名
  4988. input["data"] = inputData
  4989. inputMessage["input"] = input //交易输入
  4990. bytesData, err := json.Marshal(inputMessage)
  4991. fmt.Println(string(bytesData))
  4992. if err != nil {
  4993. fmt.Println(err.Error())
  4994. return err.Error(), ""
  4995. }
  4996. reader := bytes.NewReader(bytesData)
  4997. gdyb_url := beego.AppConfig.String("gdyb_url")
  4998. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  4999. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  5000. //url := gdyb_url + "1101"
  5001. var url string
  5002. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5003. url = gdyb_url
  5004. } else {
  5005. url = gdyb_url + "1101"
  5006. }
  5007. fmt.Println(url)
  5008. fmt.Println(gdyb_paasid)
  5009. fmt.Println(secret_key)
  5010. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  5011. request, err := http.NewRequest("POST", url, reader)
  5012. if err != nil {
  5013. fmt.Println(err.Error())
  5014. return err.Error(), ""
  5015. }
  5016. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5017. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5018. request.Header.Set("x-tif-signature", signature)
  5019. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5020. request.Header.Set("x-tif-nonce", nonce)
  5021. client := http.Client{}
  5022. resp, err := client.Do(request)
  5023. if err != nil {
  5024. fmt.Println(err.Error())
  5025. return err.Error(), ""
  5026. }
  5027. respBytes, err := ioutil.ReadAll(resp.Body)
  5028. if err != nil {
  5029. fmt.Println(err.Error())
  5030. return err.Error(), ""
  5031. }
  5032. fmt.Println(string(respBytes))
  5033. str := string(respBytes)
  5034. return str, string(bytesData)
  5035. }
  5036. func Gdyb6101(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) (string, string) {
  5037. //生成签名
  5038. nonce := GetRandomString(32)
  5039. timestamp := time.Now().Unix()
  5040. signature := setSignature(timestamp, nonce, secret_key)
  5041. //生成输入报文
  5042. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  5043. input := make(map[string]interface{})
  5044. inputData := make(map[string]interface{})
  5045. inputMessage["infno"] = "6101" // 交易编码
  5046. inputData["orgId"] = fixmedins_code // 就诊凭证类型
  5047. inputData["businessType"] = "01101" // 卡识别码
  5048. inputData["businessInfo"] = "" // 证件号码
  5049. inputData["operateorId"] = "01" // 人员证件类型
  5050. inputData["operateornName"] = doctor // 就诊凭证编号
  5051. inputData["officeId"] = "01" // 开始时间
  5052. inputData["officeName"] = "血透" // 人员姓名
  5053. inputData["deviceType"] = "" // 人员姓名
  5054. input["InData"] = inputData
  5055. inputMessage["input"] = input //交易输入
  5056. bytesData, err := json.Marshal(inputMessage)
  5057. fmt.Println(string(bytesData))
  5058. if err != nil {
  5059. fmt.Println(err.Error())
  5060. return err.Error(), ""
  5061. }
  5062. reader := bytes.NewReader(bytesData)
  5063. gdyb_url := beego.AppConfig.String("gdyb_url")
  5064. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5065. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  5066. //url := gdyb_url + "1101"
  5067. var url string
  5068. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450127" || mdtrtarea_admvs == "450127" {
  5069. url = gdyb_url
  5070. } else {
  5071. url = gdyb_url + "1101"
  5072. }
  5073. fmt.Println(url)
  5074. fmt.Println(gdyb_paasid)
  5075. fmt.Println(secret_key)
  5076. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  5077. request, err := http.NewRequest("POST", url, reader)
  5078. if err != nil {
  5079. fmt.Println(err.Error())
  5080. return err.Error(), ""
  5081. }
  5082. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5083. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5084. request.Header.Set("x-tif-signature", signature)
  5085. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5086. request.Header.Set("x-tif-nonce", nonce)
  5087. client := http.Client{}
  5088. resp, err := client.Do(request)
  5089. if err != nil {
  5090. fmt.Println(err.Error())
  5091. return err.Error(), ""
  5092. }
  5093. respBytes, err := ioutil.ReadAll(resp.Body)
  5094. if err != nil {
  5095. fmt.Println(err.Error())
  5096. return err.Error(), ""
  5097. }
  5098. fmt.Println(string(respBytes))
  5099. str := string(respBytes)
  5100. return str, string(bytesData)
  5101. }
  5102. // 人员信息版本4
  5103. 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) {
  5104. //生成签名
  5105. nonce := GetRandomString(32)
  5106. timestamp := time.Now().Unix()
  5107. //signature := setSignature(timestamp, nonce, secret_key)
  5108. //生成输入报文
  5109. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  5110. input := make(map[string]interface{})
  5111. inputData := make(map[string]interface{})
  5112. inputMessage["infno"] = "1101" // 交易编码
  5113. if certificates == 3 {
  5114. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  5115. inputData["certno"] = certNo // 证件号码
  5116. inputData["psn_cert_type"] = "99" // 人员证件类型
  5117. } else {
  5118. if id_card_type == 1 {
  5119. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  5120. inputData["card_sn"] = "" // 卡识别码
  5121. inputData["certno"] = "" // 证件号码
  5122. inputData["psn_cert_type"] = "" // 人员证件类型
  5123. } else {
  5124. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  5125. inputData["card_sn"] = "" // 卡识别码
  5126. inputData["certno"] = certNo // 证件号码
  5127. inputData["psn_cert_type"] = "1" // 人员证件类型
  5128. }
  5129. }
  5130. inputData["mdtrt_cert_no"] = "" // 就诊凭证编号
  5131. inputData["begntime"] = "" // 开始时间
  5132. inputData["psn_name"] = "" // 人员姓名
  5133. input["data"] = inputData
  5134. inputMessage["input"] = input //交易输入
  5135. bytesData, err := json.Marshal(inputMessage)
  5136. fmt.Println(string(bytesData))
  5137. if err != nil {
  5138. fmt.Println(err.Error())
  5139. return err.Error(), ""
  5140. }
  5141. var json2 string
  5142. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  5143. out, err := cmd.Output()
  5144. if err != nil {
  5145. fmt.Println("error:", err.Error())
  5146. }
  5147. fmt.Println(string(out))
  5148. return string(out), string(bytesData)
  5149. }
  5150. func StrPtr(s string) uintptr {
  5151. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  5152. }
  5153. 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 {
  5154. //生成签名
  5155. nonce := GetRandomString(32)
  5156. timestamp := time.Now().Unix()
  5157. signature := setSignature(timestamp, nonce, secret_key)
  5158. //生成输入报文
  5159. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  5160. input := make(map[string]interface{})
  5161. inputData := make(map[string]interface{})
  5162. inputMessage["infno"] = "90991" // 交易编码
  5163. inputData["fixmedins_code"] = fixmedins_code // 就诊凭证编号
  5164. inputData["psn_no"] = psn_no // 开始时间
  5165. inputData["card_pwd"] = pwd // 人员姓名
  5166. inputData["sscno"] = card_number // 人员姓名
  5167. input["data"] = inputData
  5168. inputMessage["input"] = input //交易输入
  5169. bytesData, err := json.Marshal(inputMessage)
  5170. fmt.Println(string(bytesData))
  5171. if err != nil {
  5172. fmt.Println(err.Error())
  5173. return err.Error()
  5174. }
  5175. reader := bytes.NewReader(bytesData)
  5176. gdyb_url := beego.AppConfig.String("gdyb_url")
  5177. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5178. url := gdyb_url + "90991"
  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. fmt.Println(string(respBytes))
  5201. str := string(respBytes)
  5202. return str
  5203. }
  5204. func Gdyb90100(psn_no string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  5205. //生成签名
  5206. nonce := GetRandomString(32)
  5207. timestamp := time.Now().Unix()
  5208. signature := setSignature(timestamp, nonce, secret_key)
  5209. //生成输入报文
  5210. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  5211. input := make(map[string]interface{})
  5212. inputData := make(map[string]interface{})
  5213. inputMessage["infno"] = "90100" // 交易编码
  5214. inputData["psn_no"] = psn_no // 开始时间
  5215. input["data"] = inputData
  5216. inputMessage["input"] = input //交易输入
  5217. bytesData, err := json.Marshal(inputMessage)
  5218. fmt.Println(string(bytesData))
  5219. if err != nil {
  5220. fmt.Println(err.Error())
  5221. return err.Error()
  5222. }
  5223. reader := bytes.NewReader(bytesData)
  5224. gdyb_url := beego.AppConfig.String("gdyb_url")
  5225. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5226. url := gdyb_url + "90100"
  5227. request, err := http.NewRequest("POST", url, reader)
  5228. if err != nil {
  5229. fmt.Println(err.Error())
  5230. return err.Error()
  5231. }
  5232. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5233. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5234. request.Header.Set("x-tif-signature", signature)
  5235. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5236. request.Header.Set("x-tif-nonce", nonce)
  5237. client := http.Client{}
  5238. resp, err := client.Do(request)
  5239. if err != nil {
  5240. fmt.Println(err.Error())
  5241. return err.Error()
  5242. }
  5243. respBytes, err := ioutil.ReadAll(resp.Body)
  5244. if err != nil {
  5245. fmt.Println(err.Error())
  5246. return err.Error()
  5247. }
  5248. fmt.Println(string(respBytes))
  5249. str := string(respBytes)
  5250. return str
  5251. }
  5252. 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) {
  5253. //生成签名
  5254. nonce := GetRandomString(32)
  5255. timestamp := time.Now().Unix()
  5256. signature := setSignature(timestamp, nonce, secret_key)
  5257. //生成输入报文
  5258. inputMessage := SetInputMessageTwo(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, sign)
  5259. input := make(map[string]interface{})
  5260. inputData := make(map[string]interface{})
  5261. inputMessage["infno"] = "3260" // 交易编码
  5262. inputData["sign"] = sign // 就诊凭证编号
  5263. inputData["trt_year"] = year // 就诊凭证编号
  5264. inputData["trt_month"] = month // 开始时间
  5265. inputData["startrow"] = count // 人员姓名
  5266. input["data"] = inputData
  5267. inputMessage["input"] = input //交易输入
  5268. var inputLog string
  5269. bytesData, err := json.Marshal(inputMessage)
  5270. inputLog = string(bytesData)
  5271. fmt.Println(string(bytesData))
  5272. if err != nil {
  5273. fmt.Println(err.Error())
  5274. return err.Error(), ""
  5275. }
  5276. reader := bytes.NewReader(bytesData)
  5277. gdyb_url := beego.AppConfig.String("gdyb_url")
  5278. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5279. var url string
  5280. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5281. url = gdyb_url
  5282. } else {
  5283. url = gdyb_url + "3260"
  5284. }
  5285. if insuplc_admdvs == "421300" {
  5286. var json2 string
  5287. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  5288. out, err := cmd.Output()
  5289. if err != nil {
  5290. fmt.Println("error:", err.Error())
  5291. }
  5292. fmt.Println(string(out))
  5293. return hex.EncodeToString(out), inputLog
  5294. } else {
  5295. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  5296. request, err := http.NewRequest("POST", url, reader)
  5297. if err != nil {
  5298. fmt.Println(err.Error())
  5299. return err.Error(), ""
  5300. }
  5301. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5302. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5303. request.Header.Set("x-tif-signature", signature)
  5304. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5305. request.Header.Set("x-tif-nonce", nonce)
  5306. client := http.Client{}
  5307. resp, err := client.Do(request)
  5308. if err != nil {
  5309. fmt.Println(err.Error())
  5310. return err.Error(), ""
  5311. }
  5312. respBytes, err := ioutil.ReadAll(resp.Body)
  5313. if err != nil {
  5314. fmt.Println(err.Error())
  5315. return err.Error(), ""
  5316. }
  5317. fmt.Println(string(respBytes))
  5318. str := string(respBytes)
  5319. return str, inputLog
  5320. }
  5321. }
  5322. 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) {
  5323. //msg_month := time.Unix(1557042972, 0).Format("1")
  5324. //msg_year := time.Now().Format("2006")
  5325. //msg_month = time.Now().Format("01")
  5326. //day := time.Now().Format("02")
  5327. //
  5328. //hour := time.Now().Format("15")
  5329. //min := time.Now().Format("04")
  5330. //sec := time.Now().Format("05")
  5331. //
  5332. //msec := time.Now().Format("000")
  5333. //msg_id := fixmedins_code + msg_year + msg_month + day + hour + min + sec + msec + "0"
  5334. feedetail := make([]map[string]interface{}, 0)
  5335. for _, subitem := range result3260 {
  5336. for _, item := range subitem.Output.Data {
  5337. if item.MdtrtId != "out20230406681871" && item.MdtrtId != "out20230406681868" {
  5338. feedetailInfo := make(map[string]interface{})
  5339. feedetailInfo["certno"] = item.Certno
  5340. feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5341. feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5342. feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5343. feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5344. feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5345. feedetailInfo["cnfm_flag"] = "1" // 处方号
  5346. feedetail = append(feedetail, feedetailInfo)
  5347. }
  5348. }
  5349. }
  5350. for _, subitem := range result3260 {
  5351. for _, item := range subitem.Output.Data {
  5352. if item.MdtrtId == "out20230406681871" {
  5353. feedetailInfo := make(map[string]interface{})
  5354. feedetailInfo["certno"] = item.Certno
  5355. feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5356. feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5357. feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5358. feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5359. feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5360. feedetailInfo["cnfm_flag"] = "0" // 处方号
  5361. feedetail = append(feedetail, feedetailInfo)
  5362. }
  5363. }
  5364. }
  5365. for _, subitem := range result3260 {
  5366. for _, item := range subitem.Output.Data {
  5367. if item.MdtrtId == "out20230406681868" {
  5368. feedetailInfo := make(map[string]interface{})
  5369. feedetailInfo["certno"] = item.Certno
  5370. feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5371. feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5372. feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5373. feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5374. feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5375. feedetailInfo["cnfm_flag"] = "0" // 处方号
  5376. feedetail = append(feedetail, feedetailInfo)
  5377. }
  5378. }
  5379. }
  5380. // 分页操作
  5381. pageSize := 100
  5382. pages := paginate(feedetail, pageSize)
  5383. //aa := 0
  5384. // 输出每一页的数据
  5385. for _, page := range pages {
  5386. nonce := GetRandomString(32)
  5387. timestamp := time.Now().Unix()
  5388. signature := setSignature(timestamp, nonce, secret_key)
  5389. //生成输入报文
  5390. //aa = aa + len(page)
  5391. //nonce := GetRandomString(32)
  5392. //timestamp := time.Now().Unix()
  5393. inputMessage := SetInputMessageTwo(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, sign_no)
  5394. input := make(map[string]interface{})
  5395. inputData := make(map[string]interface{})
  5396. inputMessage["infno"] = "3261" // 交易编码
  5397. inputData["trt_year"] = year // 就诊凭证编号
  5398. inputData["trt_month"] = month // 开始时间
  5399. inputData["totalrow"] = len(feedetail) // 人员姓名
  5400. input["data"] = inputData
  5401. input["detail"] = page
  5402. inputMessage["input"] = input //交易输入
  5403. //var inputLog string
  5404. bytesData, err := json.Marshal(inputMessage)
  5405. //inputLog = string(bytesData)
  5406. fmt.Println(string(bytesData))
  5407. if err != nil {
  5408. fmt.Println(err.Error())
  5409. return
  5410. }
  5411. reader := bytes.NewReader(bytesData)
  5412. gdyb_url := beego.AppConfig.String("gdyb_url")
  5413. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5414. var url string
  5415. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5416. url = gdyb_url
  5417. } else {
  5418. url = gdyb_url + "3261"
  5419. }
  5420. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  5421. request, err := http.NewRequest("POST", url, reader)
  5422. if err != nil {
  5423. fmt.Println(err.Error())
  5424. return
  5425. }
  5426. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5427. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5428. request.Header.Set("x-tif-signature", signature)
  5429. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5430. request.Header.Set("x-tif-nonce", nonce)
  5431. client := http.Client{}
  5432. resp, err := client.Do(request)
  5433. if err != nil {
  5434. fmt.Println(err.Error())
  5435. return
  5436. }
  5437. respBytes, err := ioutil.ReadAll(resp.Body)
  5438. if err != nil {
  5439. fmt.Println(err.Error())
  5440. return
  5441. }
  5442. fmt.Println(string(respBytes))
  5443. str := string(respBytes)
  5444. fmt.Println(str)
  5445. }
  5446. //for _, item := range result3260.Output.Data[start-1 : stop] {
  5447. // if item.MdtrtId != "out20230406681871" && item.MdtrtId != "out20230406681868" {
  5448. // feedetailInfo := make(map[string]interface{})
  5449. // feedetailInfo["certno"] = item.Certno
  5450. // feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5451. // feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5452. // feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5453. // feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5454. // feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5455. // feedetailInfo["cnfm_flag"] = "1" // 处方号
  5456. // feedetail = append(feedetail, feedetailInfo)
  5457. // }
  5458. //}
  5459. //for _, item := range result3260.Output.Data[start-1 : stop] {
  5460. // if item.MdtrtId == "out20230406681871" {
  5461. // feedetailInfo := make(map[string]interface{})
  5462. // feedetailInfo["certno"] = item.Certno
  5463. // feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5464. // feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5465. // feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5466. // feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5467. // feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5468. // feedetailInfo["cnfm_flag"] = "0" // 处方号
  5469. // feedetail = append(feedetail, feedetailInfo)
  5470. // }
  5471. //
  5472. //}
  5473. //for _, item := range result3260.Output.Data[start-1 : stop] {
  5474. // if item.MdtrtId == "out20230406681868" {
  5475. // feedetailInfo := make(map[string]interface{})
  5476. // feedetailInfo["certno"] = item.Certno
  5477. // feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5478. // feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5479. // feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5480. // feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5481. // feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5482. // feedetailInfo["cnfm_flag"] = "0" // 处方号
  5483. // feedetail = append(feedetail, feedetailInfo)
  5484. // }
  5485. //
  5486. //}
  5487. return
  5488. }
  5489. func Gdyb3263(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, year string, month string, result3260 []models.Result3260, sign_no string) {
  5490. //msg_month := time.Unix(1557042972, 0).Format("1")
  5491. //msg_year := time.Now().Format("2006")
  5492. //msg_month = time.Now().Format("01")
  5493. //day := time.Now().Format("02")
  5494. //
  5495. //hour := time.Now().Format("15")
  5496. //min := time.Now().Format("04")
  5497. //sec := time.Now().Format("05")
  5498. //
  5499. //msec := time.Now().Format("000")
  5500. //msg_id := fixmedins_code + msg_year + msg_month + day + hour + min + sec + msec + "0"
  5501. feedetail := make([]map[string]interface{}, 0)
  5502. for _, subitem := range result3260 {
  5503. for _, item := range subitem.Output.Data {
  5504. if item.MdtrtId != "out20230406681871" && item.MdtrtId != "out20230406681868" {
  5505. feedetailInfo := make(map[string]interface{})
  5506. feedetailInfo["certno"] = item.Certno
  5507. feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5508. feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5509. feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5510. feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5511. feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5512. feedetailInfo["cnfm_flag"] = "1" // 处方号
  5513. feedetail = append(feedetail, feedetailInfo)
  5514. }
  5515. }
  5516. }
  5517. for _, subitem := range result3260 {
  5518. for _, item := range subitem.Output.Data {
  5519. if item.MdtrtId == "out20230406681871" {
  5520. feedetailInfo := make(map[string]interface{})
  5521. feedetailInfo["certno"] = item.Certno
  5522. feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5523. feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5524. feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5525. feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5526. feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5527. feedetailInfo["cnfm_flag"] = "0" // 处方号
  5528. feedetail = append(feedetail, feedetailInfo)
  5529. }
  5530. }
  5531. }
  5532. for _, subitem := range result3260 {
  5533. for _, item := range subitem.Output.Data {
  5534. if item.MdtrtId == "out20230406681868" {
  5535. feedetailInfo := make(map[string]interface{})
  5536. feedetailInfo["certno"] = item.Certno
  5537. feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5538. feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5539. feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5540. feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5541. feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5542. feedetailInfo["cnfm_flag"] = "0" // 处方号
  5543. feedetail = append(feedetail, feedetailInfo)
  5544. }
  5545. }
  5546. }
  5547. var firstSlice, secondSlice []map[string]interface{}
  5548. if len(feedetail) > 500 {
  5549. firstSlice = feedetail[:500]
  5550. secondSlice = feedetail[500:]
  5551. } else {
  5552. firstSlice = feedetail
  5553. secondSlice = []map[string]interface{}{}
  5554. }
  5555. fmt.Println(firstSlice)
  5556. nonce := GetRandomString(32)
  5557. timestamp := time.Now().Unix()
  5558. signature := setSignature(timestamp, nonce, secret_key)
  5559. //生成输入报文
  5560. total := 0
  5561. for _, item := range result3260 {
  5562. total = total + len(item.Output.Data)
  5563. }
  5564. //nonce := GetRandomString(32)
  5565. //timestamp := time.Now().Unix()
  5566. inputMessage := SetInputMessageTwo(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, sign_no)
  5567. input := make(map[string]interface{})
  5568. inputData := make(map[string]interface{})
  5569. inputMessage["infno"] = "3261" // 交易编码
  5570. inputData["trt_year"] = year // 就诊凭证编号
  5571. inputData["trt_month"] = month // 开始时间
  5572. inputData["totalrow"] = len(secondSlice) // 人员姓名
  5573. input["data"] = inputData
  5574. input["detail"] = secondSlice
  5575. inputMessage["input"] = input //交易输入
  5576. //var inputLog string
  5577. bytesData, err := json.Marshal(inputMessage)
  5578. //inputLog = string(bytesData)
  5579. fmt.Println(string(bytesData))
  5580. if err != nil {
  5581. fmt.Println(err.Error())
  5582. return
  5583. }
  5584. reader := bytes.NewReader(bytesData)
  5585. gdyb_url := beego.AppConfig.String("gdyb_url")
  5586. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5587. var url string
  5588. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5589. url = gdyb_url
  5590. } else {
  5591. url = gdyb_url + "3261"
  5592. }
  5593. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  5594. request, err := http.NewRequest("POST", url, reader)
  5595. if err != nil {
  5596. fmt.Println(err.Error())
  5597. return
  5598. }
  5599. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5600. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5601. request.Header.Set("x-tif-signature", signature)
  5602. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5603. request.Header.Set("x-tif-nonce", nonce)
  5604. client := http.Client{}
  5605. resp, err := client.Do(request)
  5606. if err != nil {
  5607. fmt.Println(err.Error())
  5608. return
  5609. }
  5610. respBytes, err := ioutil.ReadAll(resp.Body)
  5611. if err != nil {
  5612. fmt.Println(err.Error())
  5613. return
  5614. }
  5615. fmt.Println(string(respBytes))
  5616. str := string(respBytes)
  5617. fmt.Println(str)
  5618. //for _, item := range result3260.Output.Data[start-1 : stop] {
  5619. // if item.MdtrtId != "out20230406681871" && item.MdtrtId != "out20230406681868" {
  5620. // feedetailInfo := make(map[string]interface{})
  5621. // feedetailInfo["certno"] = item.Certno
  5622. // feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5623. // feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5624. // feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5625. // feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5626. // feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5627. // feedetailInfo["cnfm_flag"] = "1" // 处方号
  5628. // feedetail = append(feedetail, feedetailInfo)
  5629. // }
  5630. //}
  5631. //for _, item := range result3260.Output.Data[start-1 : stop] {
  5632. // if item.MdtrtId == "out20230406681871" {
  5633. // feedetailInfo := make(map[string]interface{})
  5634. // feedetailInfo["certno"] = item.Certno
  5635. // feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5636. // feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5637. // feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5638. // feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5639. // feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5640. // feedetailInfo["cnfm_flag"] = "0" // 处方号
  5641. // feedetail = append(feedetail, feedetailInfo)
  5642. // }
  5643. //
  5644. //}
  5645. //for _, item := range result3260.Output.Data[start-1 : stop] {
  5646. // if item.MdtrtId == "out20230406681868" {
  5647. // feedetailInfo := make(map[string]interface{})
  5648. // feedetailInfo["certno"] = item.Certno
  5649. // feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  5650. // feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  5651. // feedetailInfo["setl_sn"] = item.SetlSn // 收费批次号
  5652. // feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  5653. // feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  5654. // feedetailInfo["cnfm_flag"] = "0" // 处方号
  5655. // feedetail = append(feedetail, feedetailInfo)
  5656. // }
  5657. //
  5658. //}
  5659. return
  5660. }
  5661. 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) {
  5662. //生成签名
  5663. nonce := GetRandomString(32)
  5664. timestamp := time.Now().Unix()
  5665. signature := setSignature(timestamp, nonce, secret_key)
  5666. //生成输入报文
  5667. inputMessage := SetInputMessageTwo(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, sign_no)
  5668. input := make(map[string]interface{})
  5669. inputData := make(map[string]interface{})
  5670. inputMessage["infno"] = "3262" // 交易编码
  5671. inputData["trt_year"] = year // 就诊凭证编号
  5672. inputData["trt_month"] = month // 开始时间
  5673. inputData["otransid"] = "0" // 开始时间
  5674. input["data"] = inputData
  5675. inputMessage["input"] = input //交易输入
  5676. var inputLog string
  5677. bytesData, err := json.Marshal(inputMessage)
  5678. inputLog = string(bytesData)
  5679. fmt.Println(string(bytesData))
  5680. if err != nil {
  5681. fmt.Println(err.Error())
  5682. return err.Error(), ""
  5683. }
  5684. reader := bytes.NewReader(bytesData)
  5685. gdyb_url := beego.AppConfig.String("gdyb_url")
  5686. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5687. var url string
  5688. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5689. url = gdyb_url
  5690. } else {
  5691. url = gdyb_url + "3262"
  5692. }
  5693. if insuplc_admdvs == "421300" {
  5694. var json2 string
  5695. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  5696. out, err := cmd.Output()
  5697. if err != nil {
  5698. fmt.Println("error:", err.Error())
  5699. }
  5700. fmt.Println(string(out))
  5701. return hex.EncodeToString(out), inputLog
  5702. } else {
  5703. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  5704. request, err := http.NewRequest("POST", url, reader)
  5705. if err != nil {
  5706. fmt.Println(err.Error())
  5707. return err.Error(), ""
  5708. }
  5709. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5710. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5711. request.Header.Set("x-tif-signature", signature)
  5712. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5713. request.Header.Set("x-tif-nonce", nonce)
  5714. client := http.Client{}
  5715. resp, err := client.Do(request)
  5716. if err != nil {
  5717. fmt.Println(err.Error())
  5718. return err.Error(), ""
  5719. }
  5720. respBytes, err := ioutil.ReadAll(resp.Body)
  5721. if err != nil {
  5722. fmt.Println(err.Error())
  5723. return err.Error(), ""
  5724. }
  5725. fmt.Println(string(respBytes))
  5726. str := string(respBytes)
  5727. return str, inputLog
  5728. }
  5729. }
  5730. 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) {
  5731. //生成签名
  5732. nonce := GetRandomString(32)
  5733. timestamp := time.Now().Unix()
  5734. signature := setSignature(timestamp, nonce, "d6Ad0P1B3z6Dsdst0gYAFPlz8YlIvFDx")
  5735. inputMessage := make(map[string]interface{})
  5736. //生成输入报文
  5737. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5738. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  5739. } else {
  5740. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  5741. }
  5742. input := make(map[string]interface{})
  5743. inputData := make(map[string]interface{})
  5744. inputMessage["infno"] = "9001" // 交易编码
  5745. inputData["opter_no"] = admin_user_id // 就诊凭证编号
  5746. inputData["mac"] = "11-11-11-11-11" // 开始时间
  5747. inputData["ip"] = "11.11.11.11"
  5748. //inputData["userid"] = "H44010400081"
  5749. //month := time.Unix(1557042972, 0).Format("1")
  5750. //year := time.Now().Format("2006")
  5751. //month = time.Now().Format("01")
  5752. //day := time.Now().Format("02")
  5753. //hour := time.Now().Format("15")
  5754. //min := time.Now().Format("04")
  5755. //sec := time.Now().Format("05")
  5756. //custom_time := year + month + day + hour + min + sec
  5757. //inputData["currenttime"] = custom_time
  5758. //var psd string
  5759. //psd = custom_time + "Gzyb$867"
  5760. //h := md5.New()
  5761. //h.Write([]byte(psd))
  5762. //inputData["password"] = strings.ToUpper(hex.EncodeToString(h.Sum(nil)))
  5763. input["data"] = inputData
  5764. inputMessage["input"] = input //交易输入
  5765. var inputLog string
  5766. bytesData, err := json.Marshal(inputMessage)
  5767. inputLog = string(bytesData)
  5768. fmt.Println(string(bytesData))
  5769. if err != nil {
  5770. fmt.Println(err.Error())
  5771. return err.Error(), ""
  5772. }
  5773. reader := bytes.NewReader(bytesData)
  5774. gdyb_url := beego.AppConfig.String("gdyb_url")
  5775. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5776. var url string
  5777. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5778. url = gdyb_url
  5779. } else {
  5780. url = gdyb_url + "9001"
  5781. }
  5782. if insuplc_admdvs == "421300" {
  5783. var json2 string
  5784. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  5785. out, err := cmd.Output()
  5786. if err != nil {
  5787. fmt.Println("error:", err.Error())
  5788. }
  5789. fmt.Println(string(out))
  5790. return hex.EncodeToString(out), inputLog
  5791. } else {
  5792. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  5793. request, err := http.NewRequest("POST", url, reader)
  5794. if err != nil {
  5795. fmt.Println(err.Error())
  5796. return err.Error(), ""
  5797. }
  5798. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5799. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5800. request.Header.Set("x-tif-signature", signature)
  5801. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5802. request.Header.Set("x-tif-nonce", nonce)
  5803. fmt.Println(string(bytesData))
  5804. fmt.Println(gdyb_url)
  5805. fmt.Println(gdyb_paasid)
  5806. fmt.Println(request.Header)
  5807. client := http.Client{}
  5808. resp, err := client.Do(request)
  5809. if err != nil {
  5810. fmt.Println(err.Error())
  5811. return err.Error(), ""
  5812. }
  5813. respBytes, err := ioutil.ReadAll(resp.Body)
  5814. if err != nil {
  5815. fmt.Println(err.Error())
  5816. return err.Error(), ""
  5817. }
  5818. fmt.Println(string(respBytes))
  5819. str := string(respBytes)
  5820. return str, inputLog
  5821. }
  5822. }
  5823. 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) {
  5824. //生成签名
  5825. nonce := GetRandomString(32)
  5826. timestamp := time.Now().Unix()
  5827. signature := setSignature(timestamp, nonce, secret_key)
  5828. inputMessage := make(map[string]interface{})
  5829. //生成输入报文
  5830. //生成输入报文
  5831. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5832. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  5833. } else {
  5834. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  5835. }
  5836. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  5837. input := make(map[string]interface{})
  5838. inputData := make(map[string]interface{})
  5839. inputMessage["infno"] = "9001" // 交易编码
  5840. inputData["opter_no"] = admin_user_id // 就诊凭证编号
  5841. inputData["mac"] = GetMac() // 开始时间
  5842. inputData["ip"] = GetLocalIp()
  5843. input["signIn"] = inputData
  5844. inputMessage["input"] = input //交易输入
  5845. var inputLog string
  5846. bytesData, err := json.Marshal(inputMessage)
  5847. inputLog = string(bytesData)
  5848. fmt.Println(string(bytesData))
  5849. if err != nil {
  5850. fmt.Println(err.Error())
  5851. return err.Error(), ""
  5852. }
  5853. reader := bytes.NewReader(bytesData)
  5854. gdyb_url := beego.AppConfig.String("gdyb_url")
  5855. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5856. var url string
  5857. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5858. url = gdyb_url
  5859. } else {
  5860. url = gdyb_url + "9001"
  5861. }
  5862. if insuplc_admdvs == "421300" {
  5863. var json2 string
  5864. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  5865. out, err := cmd.Output()
  5866. if err != nil {
  5867. fmt.Println("error:", err.Error())
  5868. }
  5869. fmt.Println(string(out))
  5870. return hex.EncodeToString(out), inputLog
  5871. } else {
  5872. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  5873. request, err := http.NewRequest("POST", url, reader)
  5874. if err != nil {
  5875. fmt.Println(err.Error())
  5876. return err.Error(), ""
  5877. }
  5878. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  5879. request.Header.Set("x-tif-paasid", gdyb_paasid)
  5880. request.Header.Set("x-tif-signature", signature)
  5881. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  5882. request.Header.Set("x-tif-nonce", nonce)
  5883. fmt.Println(string(bytesData))
  5884. fmt.Println(gdyb_url)
  5885. fmt.Println(gdyb_paasid)
  5886. fmt.Println(request.Header)
  5887. client := http.Client{}
  5888. resp, err := client.Do(request)
  5889. if err != nil {
  5890. fmt.Println(err.Error())
  5891. return err.Error(), ""
  5892. }
  5893. respBytes, err := ioutil.ReadAll(resp.Body)
  5894. if err != nil {
  5895. fmt.Println(err.Error())
  5896. return err.Error(), ""
  5897. }
  5898. fmt.Println(string(respBytes))
  5899. str := string(respBytes)
  5900. return str, inputLog
  5901. }
  5902. }
  5903. // 获取本机ip
  5904. func GetLocalIp() string {
  5905. addrs, err := net.InterfaceAddrs()
  5906. if err != nil {
  5907. fmt.Println("get local ip failed")
  5908. }
  5909. for _, address := range addrs {
  5910. if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
  5911. if ipnet.IP.To4() != nil {
  5912. return ipnet.IP.String()
  5913. }
  5914. }
  5915. }
  5916. return ""
  5917. }
  5918. // 获取本机Mac
  5919. func GetMac() string {
  5920. interfaces, err := net.Interfaces()
  5921. if err != nil {
  5922. fmt.Println("Get loacl Mac failed")
  5923. }
  5924. for _, inter := range interfaces {
  5925. mac := inter.HardwareAddr
  5926. fmt.Println("+======" + mac.String())
  5927. if mac.String() != "" {
  5928. return mac.String()
  5929. }
  5930. }
  5931. return ""
  5932. }
  5933. // 人员基本信息
  5934. func Gdyb1101D(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, card_sn string, certificates string, psn_name string, record_date string, admin_user_id int64) (string, string) {
  5935. //生成签名
  5936. fmt.Println("DDDDD")
  5937. nonce := GetRandomString(32)
  5938. timestamp := time.Now().Unix()
  5939. signature := setSignature(timestamp, nonce, secret_key)
  5940. //生成输入报文
  5941. inputMessage := make(map[string]interface{})
  5942. //tempTime := time.Unix(timestamp, 0)
  5943. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  5944. // 生成输入报文
  5945. if mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  5946. inputMessage = SetInputMessage1111(nonce, timestamp, org_name, admin_user_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, doctor)
  5947. } else {
  5948. inputMessage = SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  5949. }
  5950. //inputMessage := SetInputMessagenosign(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  5951. input := make(map[string]interface{})
  5952. inputData := make(map[string]interface{})
  5953. inputMessage["infno"] = "1101" // 交易编码
  5954. if certificates == "3" {
  5955. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  5956. inputData["certno"] = certNo // 证件号码
  5957. inputData["psn_cert_type"] = "99" // 人员证件类型
  5958. } else {
  5959. if certificates == "1" {
  5960. if id_card_type == 1 {
  5961. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  5962. inputData["card_sn"] = "" // 卡识别码
  5963. inputData["certno"] = certNo // 证件号码
  5964. inputData["psn_cert_type"] = "01" // 人员证件类型
  5965. } else if id_card_type == 4 {
  5966. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  5967. inputData["certno"] = certNo // 证件号码
  5968. inputData["psn_cert_type"] = "01" // 人员证件类型
  5969. } else {
  5970. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  5971. inputData["card_sn"] = "" // 卡识别码
  5972. inputData["certno"] = certNo // 证件号码
  5973. inputData["psn_cert_type"] = "01" // 人员证件类型
  5974. }
  5975. } else if certificates == "6" {
  5976. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  5977. inputData["card_sn"] = "" // 卡识别码
  5978. inputData["certno"] = certNo // 证件号码
  5979. inputData["psn_cert_type"] = "17" // 人员证件类型
  5980. }
  5981. }
  5982. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  5983. inputData["begntime"] = "" // 开始时间
  5984. inputData["psn_name"] = "" // 人员姓名
  5985. input["data"] = inputData
  5986. inputMessage["input"] = input //交易输入
  5987. var inputLog string
  5988. bytesData, err := json.Marshal(inputMessage)
  5989. inputLog = string(bytesData)
  5990. fmt.Println(string(bytesData))
  5991. if err != nil {
  5992. fmt.Println(err.Error())
  5993. return err.Error(), ""
  5994. }
  5995. reader := bytes.NewReader(bytesData)
  5996. gdyb_url := beego.AppConfig.String("gdyb_url")
  5997. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  5998. //DllDef := syscall.MustLoadDLL("yh_hb_sctrl.dll")
  5999. //Iinit := DllDef.MustFindProc("yh_hb_call")
  6000. //var str3 string
  6001. //ret, _, _ := Iinit.Call(StrPtr("1101"), StrPtr(string(bytesData)), StrPtr(str3))
  6002. //fmt.Println(ret)
  6003. //fmt.Println(str3)
  6004. //
  6005. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6006. var url string
  6007. if fixmedins_code == "H15049901371" || mdtrtarea_admvs == "450721" || mdtrtarea_admvs == "450127" {
  6008. url = gdyb_url
  6009. } else {
  6010. url = gdyb_url + "1101"
  6011. }
  6012. if insuplc_admdvs == "421300" {
  6013. var json2 string
  6014. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  6015. out, err := cmd.Output()
  6016. if err != nil {
  6017. fmt.Println("error:", err.Error())
  6018. }
  6019. fmt.Println(string(out))
  6020. return hex.EncodeToString(out), inputLog
  6021. } else {
  6022. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  6023. request, err := http.NewRequest("POST", url, reader)
  6024. if err != nil {
  6025. fmt.Println(err.Error())
  6026. return err.Error(), ""
  6027. }
  6028. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6029. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6030. request.Header.Set("x-tif-signature", signature)
  6031. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6032. request.Header.Set("x-tif-nonce", nonce)
  6033. client := http.Client{}
  6034. resp, err := client.Do(request)
  6035. if err != nil {
  6036. fmt.Println(err.Error())
  6037. return err.Error(), ""
  6038. }
  6039. respBytes, err := ioutil.ReadAll(resp.Body)
  6040. if err != nil {
  6041. fmt.Println(err.Error())
  6042. return err.Error(), ""
  6043. }
  6044. fmt.Println(string(respBytes))
  6045. str := string(respBytes)
  6046. return str, inputLog
  6047. }
  6048. }
  6049. //func SetInputMessageFour(nonce string, timestamp int64, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) map[string]interface{} {
  6050. // // 生成签名
  6051. // //tempTime := time.Unix(timestamp, 0)
  6052. // //timeFormat := tempTime.Format("20060102150405")
  6053. // //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  6054. // //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  6055. //
  6056. // msec := time.Now().Format("000")
  6057. // fmt.Println(utils.GetNetTime())
  6058. // // 生成输入报文
  6059. // inputMessage := make(map[string]interface{})
  6060. // inputMessage["msgid"] = fixmedins_code + utils.GetNetTime() + msec + "0" // 发送方报文 ID
  6061. // inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  6062. // inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  6063. // inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  6064. // inputMessage["dev_no"] = "" // 设备编号
  6065. // inputMessage["dev_safe_info"] = "" // 设备安全信息
  6066. // inputMessage["cainfo"] = "" // 数字签名信息
  6067. // inputMessage["signtype"] = "SM3" // 签名类型
  6068. // inputMessage["infver"] = "V1.0" // 接收方系统代码
  6069. // inputMessage["opter_type"] = "1" // 经办人类别
  6070. // inputMessage["opter"] = doctor // 经办人
  6071. // inputMessage["opter_name"] = doctor // 经办人姓名
  6072. // inputMessage["inf_time"] = utils.GetNetTime() // 交易时间
  6073. // inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  6074. // inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  6075. // inputMessage["sign_no"] = "" //交易签到流水号
  6076. // return inputMessage
  6077. //}
  6078. func Gdyb5302(psnNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  6079. // 生成签名
  6080. nonce := GetRandomString(32)
  6081. //timestamp := time.Now().Unix()
  6082. timestamp := time.Now().UnixNano() / 1e6
  6083. signature := setSignature(timestamp, nonce, secret_key)
  6084. // 生成输入报文
  6085. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  6086. input := make(map[string]interface{})
  6087. inputData := make(map[string]interface{})
  6088. inputMessage["infno"] = "5302" // 交易编码
  6089. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  6090. inputData["biz_appy_type"] = "03" // 人员编号 (来自1101接口返回)
  6091. input["data"] = inputData
  6092. inputMessage["input"] = input //交易输入
  6093. bytesData, err := json.Marshal(inputMessage)
  6094. fmt.Println(string(bytesData))
  6095. if err != nil {
  6096. fmt.Println(err.Error())
  6097. return err.Error()
  6098. }
  6099. reader := bytes.NewReader(bytesData)
  6100. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6101. gdyb_url := beego.AppConfig.String("gdyb_url")
  6102. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6103. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6104. url := gdyb_url + "5302"
  6105. request, err := http.NewRequest("POST", url, reader)
  6106. if err != nil {
  6107. fmt.Println(err.Error())
  6108. return err.Error()
  6109. }
  6110. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6111. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6112. request.Header.Set("x-tif-signature", signature)
  6113. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6114. request.Header.Set("x-tif-nonce", nonce)
  6115. client := http.Client{}
  6116. resp, err := client.Do(request)
  6117. if err != nil {
  6118. fmt.Println(err.Error())
  6119. return err.Error()
  6120. }
  6121. respBytes, err := ioutil.ReadAll(resp.Body)
  6122. if err != nil {
  6123. fmt.Println(err.Error())
  6124. return err.Error()
  6125. }
  6126. str := string(respBytes)
  6127. fmt.Println(str)
  6128. return str
  6129. }
  6130. func CreateSignIn(record *models.HisSignIn) (err error) {
  6131. err = writeDb.Save(&record).Error
  6132. return
  6133. }
  6134. func GetSignInInfo(code string) string {
  6135. var sign models.HisSignIn
  6136. err = readDb.Model(&models.HisSignIn{}).Where("fixmedins_code = ? AND status = 1", code).Last(&sign).Error
  6137. return sign.SignNo
  6138. }
  6139. func Gdyb3501(struct3501 models.Struct3501, secret_key string) (string, string) {
  6140. // 生成签名
  6141. nonce := GetRandomString(32)
  6142. timestamp := time.Now().Unix()
  6143. signature := setSignature(timestamp, nonce, secret_key)
  6144. // 生成输入报文
  6145. inputMessage := SetGdInputMessage(timestamp, struct3501.OrgName, struct3501.Opter, struct3501.Code, struct3501.InsuplcAdmdvs, struct3501.MdtrtareaAdmvs, struct3501.Cainfo)
  6146. input := make(map[string]interface{})
  6147. inputData := make(map[string]interface{})
  6148. inputMessage["infno"] = "3501" // 交易编码
  6149. inputData["med_list_codg"] = struct3501.MedListCodg // 定点医药机构目录编号
  6150. inputData["fixmedins_hilist_id"] = struct3501.FixmedinsHilistId // 定点医药机构目录编号
  6151. inputData["fixmedins_hilist_name"] = struct3501.FixmedinsHilistName // 定点医药机构目录名称
  6152. inputData["rx_flag"] = struct3501.RxFlag //
  6153. inputData["invdate"] = struct3501.Invdate // 人员编号 (来自1101接口返回)
  6154. inputData["inv_cnt"] = struct3501.InvCnt // 人员编号 (来自1101接口返回)
  6155. inputData["manu_lotnum"] = struct3501.ManuLotnum // 人员编号 (来自1101接口返回)
  6156. inputData["fixmedins_bchno"] = struct3501.FixmedinsBchno // 人员编号 (来自1101接口返回)
  6157. inputData["manu_date"] = struct3501.ManuDate // 人员编号 (来自1101接口返回)
  6158. inputData["expy_end"] = struct3501.ExpyEnd // 人员编号 (来自1101接口返回)
  6159. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  6160. feedetail := make([]map[string]interface{}, 0)
  6161. codes := strings.Split(struct3501.DrugTracCodg, ",")
  6162. for _, item := range codes {
  6163. if len(item) > 0 {
  6164. druginputData := make(map[string]interface{})
  6165. druginputData["drug_trac_codg"] = item
  6166. feedetail = append(feedetail, druginputData)
  6167. }
  6168. }
  6169. inputData["drugtracinfo"] = feedetail
  6170. input["invinfo"] = inputData
  6171. inputMessage["input"] = input //交易输入
  6172. bytesData, err := json.Marshal(inputMessage)
  6173. fmt.Println(string(bytesData))
  6174. if err != nil {
  6175. fmt.Println(err.Error())
  6176. return err.Error(), ""
  6177. }
  6178. reader := bytes.NewReader(bytesData)
  6179. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6180. gdyb_url := beego.AppConfig.String("gdyb_url")
  6181. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6182. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6183. url := gdyb_url + "3501"
  6184. request, err := http.NewRequest("POST", url, reader)
  6185. if err != nil {
  6186. fmt.Println(err.Error())
  6187. return err.Error(), ""
  6188. }
  6189. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6190. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6191. request.Header.Set("x-tif-signature", signature)
  6192. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6193. request.Header.Set("x-tif-nonce", nonce)
  6194. client := http.Client{}
  6195. resp, err := client.Do(request)
  6196. if err != nil {
  6197. fmt.Println(err.Error())
  6198. return err.Error(), ""
  6199. }
  6200. respBytes, err := ioutil.ReadAll(resp.Body)
  6201. if err != nil {
  6202. fmt.Println(err.Error())
  6203. return err.Error(), ""
  6204. }
  6205. str := string(respBytes)
  6206. fmt.Println(str)
  6207. return str, string(bytesData)
  6208. }
  6209. func Gdyb3502(struct3502 models.Struct3502, secret_key string) (string, string) {
  6210. // 生成签名
  6211. nonce := GetRandomString(32)
  6212. timestamp := time.Now().Unix()
  6213. signature := setSignature(timestamp, nonce, secret_key)
  6214. // 生成输入报文
  6215. inputMessage := SetGdInputMessage(timestamp, struct3502.OrgName, struct3502.Opter, struct3502.FixmedinsCode, struct3502.InsuplcAdmdvs, struct3502.MdtrtareaAdmvs, struct3502.Cainfo)
  6216. input := make(map[string]interface{})
  6217. inputData := make(map[string]interface{})
  6218. inputMessage["infno"] = "3502" // 交易编码
  6219. inputData["med_list_codg"] = struct3502.MedListCodg // 定点医药机构目录编号
  6220. inputData["inv_chg_type"] = struct3502.InvChgType // 定点医药机构目录编号
  6221. inputData["fixmedins_hilist_id"] = struct3502.FixmedinsCode // 定点医药机构目录编号
  6222. inputData["fixmedins_hilist_name"] = struct3502.FixmedinsHilistName // 定点医药机构目录名称
  6223. inputData["fixmedins_bchno"] = struct3502.FixmedinsBchno // 人员编号 (来自1101接口返回)
  6224. inputData["pric"] = struct3502.Pric // 人员编号 (来自1101接口返回)
  6225. inputData["cnt"] = struct3502.Cnt // 人员编号 (来自1101接口返回)
  6226. inputData["rx_flag"] = struct3502.RxFlag //
  6227. inputData["inv_chg_time"] = struct3502.InvChgTime // 人员编号 (来自1101接口返回)
  6228. inputData["inv_chg_opter_name"] = "" // 人员编号 (来自1101接口返回)
  6229. inputData["memo"] = struct3502.Memo // 人员编号 (来自1101接口返回)
  6230. inputData["trdn_flag"] = "" // 人员编号 (来自1101接口返回)
  6231. input["invinfo"] = inputData
  6232. //feedetail := make([]map[string]interface{}, 0)
  6233. //druginputData := make(map[string]interface{})
  6234. //druginputData["drug_trac_codg"] = struct3502.DrugTracCodg
  6235. //feedetail = append(feedetail, druginputData)
  6236. //inputData["drugtracinfo"] = feedetail
  6237. feedetail := make([]map[string]interface{}, 0)
  6238. codes := strings.Split(struct3502.DrugTracCodg, ",")
  6239. for _, item := range codes {
  6240. druginputData := make(map[string]interface{})
  6241. druginputData["drug_trac_codg"] = item
  6242. feedetail = append(feedetail, druginputData)
  6243. }
  6244. inputData["drugtracinfo"] = feedetail
  6245. input["invinfo"] = inputData
  6246. inputMessage["input"] = input //交易输入
  6247. bytesData, err := json.Marshal(inputMessage)
  6248. fmt.Println(string(bytesData))
  6249. if err != nil {
  6250. fmt.Println(err.Error())
  6251. return err.Error(), ""
  6252. }
  6253. reader := bytes.NewReader(bytesData)
  6254. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6255. gdyb_url := beego.AppConfig.String("gdyb_url")
  6256. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6257. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6258. url := gdyb_url + "3502"
  6259. request, err := http.NewRequest("POST", url, reader)
  6260. if err != nil {
  6261. fmt.Println(err.Error())
  6262. return err.Error(), ""
  6263. }
  6264. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6265. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6266. request.Header.Set("x-tif-signature", signature)
  6267. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6268. request.Header.Set("x-tif-nonce", nonce)
  6269. client := http.Client{}
  6270. resp, err := client.Do(request)
  6271. if err != nil {
  6272. fmt.Println(err.Error())
  6273. return err.Error(), ""
  6274. }
  6275. respBytes, err := ioutil.ReadAll(resp.Body)
  6276. if err != nil {
  6277. fmt.Println(err.Error())
  6278. return err.Error(), ""
  6279. }
  6280. str := string(respBytes)
  6281. fmt.Println(str)
  6282. return str, string(bytesData)
  6283. }
  6284. func Gdyb3503(struct3503 models.Struct3503, secret_key string) (string, string) {
  6285. // 生成签名
  6286. nonce := GetRandomString(32)
  6287. timestamp := time.Now().Unix()
  6288. signature := setSignature(timestamp, nonce, secret_key)
  6289. // 生成输入报文
  6290. inputMessage := SetGdInputMessage(timestamp, struct3503.OrgName, struct3503.Opter, struct3503.FixmedinsHilistId, struct3503.InsuplcAdmdvs, struct3503.MdtrtareaAdmvs, struct3503.Cainfo)
  6291. input := make(map[string]interface{})
  6292. inputMessage["infno"] = "3503"
  6293. item := struct3503
  6294. feedetailInfo := make(map[string]interface{})
  6295. feedetailInfo["med_list_codg"] = item.MedListCodg
  6296. feedetailInfo["fixmedins_hilist_id"] = item.FixmedinsHilistId
  6297. feedetailInfo["fixmedins_hilist_name"] = item.FixmedinsHilistName
  6298. feedetailInfo["dynt_no"] = ""
  6299. feedetailInfo["fixmedins_bchno"] = item.FixmedinsBchno // 人员编号 (来自1101接口返回)
  6300. feedetailInfo["spler_name"] = item.SplerName // 人员编号 (来自1101接口返回)
  6301. feedetailInfo["spler_pmtno"] = "" // 人员编号 (来自1101接口返回)
  6302. feedetailInfo["manu_lotnum"] = item.ManuLotnum // 人员编号 (来自1101接口返回)
  6303. feedetailInfo["prodentp_name"] = item.ProdentpName // 人员编号 (来自1101接口返回)
  6304. feedetailInfo["aprvno"] = item.Aprvno // 人员编号 (来自1101接口返回)
  6305. feedetailInfo["manu_date"] = item.ManuDate // 人员编号 (来自1101接口返回)
  6306. feedetailInfo["expy_end"] = item.ExpyEnd // 人员编号 (来自1101接口返回)
  6307. feedetailInfo["finl_trns_pric"] = item.FinlTrnsPric // 人员编号 (来自1101接口返回)
  6308. feedetailInfo["purc_retn_cnt"] = item.PurcRetnCnt // 人员编号 (来自1101接口返回)
  6309. feedetailInfo["purc_invo_codg"] = item.PurcInvoCodg // 人员编号 (来自1101接口返回)
  6310. feedetailInfo["purc_invo_no"] = item.PurcInvoNo // 人员编号 (来自1101接口返回)
  6311. feedetailInfo["rx_flag"] = item.RxFlag // 人员编号 (来自1101接口返回)
  6312. feedetailInfo["purc_retn_stoin_time"] = item.PurcRetnStoinTime // 人员编号 (来自1101接口返回)
  6313. feedetailInfo["purc_retn_opter_name"] = item.PurcRetnOpterName // 人员编号 (来自1101接口返回)
  6314. feedetailInfo["prod_geay_flag"] = "" // 人员编号 (来自1101接口返回)
  6315. feedetailInfo["memo"] = "" // 人员编号 (来自1101接口返回)
  6316. input["purcinfo"] = feedetailInfo
  6317. inputMessage["input"] = input //交易输入
  6318. bytesData, err := json.Marshal(inputMessage)
  6319. fmt.Println(string(bytesData))
  6320. if err != nil {
  6321. fmt.Println(err.Error())
  6322. return err.Error(), ""
  6323. }
  6324. reader := bytes.NewReader(bytesData)
  6325. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6326. gdyb_url := beego.AppConfig.String("gdyb_url")
  6327. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6328. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6329. url := gdyb_url + "3503"
  6330. request, err := http.NewRequest("POST", url, reader)
  6331. if err != nil {
  6332. fmt.Println(err.Error())
  6333. return err.Error(), ""
  6334. }
  6335. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6336. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6337. request.Header.Set("x-tif-signature", signature)
  6338. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6339. request.Header.Set("x-tif-nonce", nonce)
  6340. client := http.Client{}
  6341. resp, err := client.Do(request)
  6342. if err != nil {
  6343. fmt.Println(err.Error())
  6344. return err.Error(), ""
  6345. }
  6346. respBytes, err := ioutil.ReadAll(resp.Body)
  6347. if err != nil {
  6348. fmt.Println(err.Error())
  6349. return err.Error(), ""
  6350. }
  6351. str := string(respBytes)
  6352. fmt.Println(str)
  6353. return str, string(bytesData)
  6354. }
  6355. func Gdyb3504(struct3504 models.Struct3504, secret_key string) (string, string) {
  6356. // 生成签名
  6357. nonce := GetRandomString(32)
  6358. timestamp := time.Now().Unix()
  6359. signature := setSignature(timestamp, nonce, secret_key)
  6360. // 生成输入报文
  6361. inputMessage := SetGdInputMessage(timestamp, struct3504.OrgName, struct3504.Opter, struct3504.FixmedinsCode, struct3504.InsuplcAdmdvs, struct3504.MdtrtareaAdmvs, struct3504.Cainfo)
  6362. input := make(map[string]interface{})
  6363. inputData := make(map[string]interface{})
  6364. inputMessage["infno"] = "3504" // 交易编码
  6365. inputData["med_list_codg"] = struct3504.MedListCodg // 定点医药机构目录编号
  6366. inputData["fixmedins_hilist_id"] = struct3504.FixmedinsHilistId // 定点医药机构目录编号
  6367. inputData["fixmedins_hilist_name"] = struct3504.FixmedinsHilistName // 定点医药机构目录名称
  6368. inputData["fixmedins_bchno"] = struct3504.FixmedinsBchno // 人员编号 (来自1101接口返回)
  6369. inputData["spler_name"] = struct3504.SplerName // 人员编号 (来自1101接口返回)
  6370. inputData["spler_pmtno"] = "" // 人员编号 (来自1101接口返回)
  6371. inputData["manu_date"] = struct3504.ManuDate // 人员编号 (来自1101接口返回)
  6372. inputData["expy_end"] = struct3504.ExpyEnd // 人员编号 (来自1101接口返回)
  6373. inputData["finl_trns_pric"] = struct3504.FinlTrnsPric // 人员编号 (来自1101接口返回)
  6374. inputData["purc_retn_cnt"] = struct3504.PurcRetnCnt // 人员编号 (来自1101接口返回)
  6375. inputData["purc_invo_codg"] = struct3504.PurcInvoCodg // 人员编号 (来自1101接口返回)
  6376. inputData["purc_invo_no"] = struct3504.PurcInvoNo // 人员编号 (来自1101接口返回)
  6377. inputData["rx_flag"] = struct3504.RxFlag // 人员编号 (来自1101接口返回)
  6378. inputData["purc_retn_stoin_time"] = struct3504.PurcRetnStoinTime // 人员编号 (来自1101接口返回)
  6379. inputData["purc_retn_opter_name"] = struct3504.PurcRetnOpterName // 人员编号 (来自1101接口返回)
  6380. inputData["medins_prod_purc_no"] = "" // 人员编号 (来自1101接口返回)
  6381. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  6382. input["purcinfo"] = inputData
  6383. inputMessage["input"] = input //交易输入
  6384. bytesData, err := json.Marshal(inputMessage)
  6385. fmt.Println(string(bytesData))
  6386. if err != nil {
  6387. fmt.Println(err.Error())
  6388. return err.Error(), ""
  6389. }
  6390. reader := bytes.NewReader(bytesData)
  6391. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6392. gdyb_url := beego.AppConfig.String("gdyb_url")
  6393. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6394. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6395. url := gdyb_url + "3504"
  6396. request, err := http.NewRequest("POST", url, reader)
  6397. if err != nil {
  6398. fmt.Println(err.Error())
  6399. return err.Error(), ""
  6400. }
  6401. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6402. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6403. request.Header.Set("x-tif-signature", signature)
  6404. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6405. request.Header.Set("x-tif-nonce", nonce)
  6406. client := http.Client{}
  6407. resp, err := client.Do(request)
  6408. if err != nil {
  6409. fmt.Println(err.Error())
  6410. return err.Error(), ""
  6411. }
  6412. respBytes, err := ioutil.ReadAll(resp.Body)
  6413. if err != nil {
  6414. fmt.Println(err.Error())
  6415. return err.Error(), ""
  6416. }
  6417. str := string(respBytes)
  6418. fmt.Println(str)
  6419. return str, string(bytesData)
  6420. }
  6421. func Gdyb3505(struct3505 models.Struct3505, secret_key string) (string, string) {
  6422. // 生成签名
  6423. nonce := GetRandomString(32)
  6424. timestamp := time.Now().Unix()
  6425. signature := setSignature(timestamp, nonce, secret_key)
  6426. // 生成输入报文
  6427. inputMessage := SetGdInputMessage(timestamp, struct3505.OrgName, struct3505.Opter, struct3505.Code, struct3505.InsuplcAdmdvs, struct3505.MdtrtareaAdmvs, struct3505.Cainfo)
  6428. input := make(map[string]interface{})
  6429. inputData := make(map[string]interface{})
  6430. inputMessage["infno"] = "3505" // 交易编码
  6431. inputData["med_list_codg"] = struct3505.MedListCodg // 定点医药机构目录编号
  6432. inputData["fixmedins_hilist_id"] = struct3505.FixmedinsHilistId // 定点医药机构目录编号
  6433. inputData["fixmedins_hilist_name"] = struct3505.FixmedinsHilistName // 定点医药机构目录名称
  6434. inputData["fixmedins_bchno"] = struct3505.FixmedinsBchno // 人员编号 (来自1101接口返回)
  6435. inputData["prsc_dr_cert_type"] = struct3505.PrscDrCertType // 人员编号 (来自1101接口返回)
  6436. inputData["prsc_dr_certno"] = struct3505.PrscDrCertno // 人员编号 (来自1101接口返回)
  6437. inputData["prsc_dr_name"] = struct3505.PrscDrName // 人员编号 (来自1101接口返回)
  6438. inputData["phar_cert_type"] = struct3505.PharCertType // 人员编号 (来自1101接口返回)
  6439. inputData["phar_certno"] = struct3505.PharCertno // 人员编号 (来自1101接口返回)
  6440. inputData["phar_name"] = struct3505.PharName // 人员编号 (来自1101接口返回)
  6441. inputData["phar_prac_cert_no"] = struct3505.PharPracCertNo // 人员编号 (来自1101接口返回)
  6442. inputData["hi_feesetl_type"] = struct3505.HiFeesetlType // 人员编号 (来自1101接口返回)
  6443. inputData["setl_id"] = struct3505.SetlId // 人员编号 (来自1101接口返回)
  6444. inputData["mdtrt_sn"] = struct3505.MdtrtSn // 人员编号 (来自1101接口返回)
  6445. inputData["psn_no"] = struct3505.PsnNo // 人员编号 (来自1101接口返回)
  6446. inputData["psn_cert_type"] = struct3505.PsnCertType // 人员编号 (来自1101接口返回)
  6447. inputData["certno"] = struct3505.CertNo // 人员编号 (来自1101接口返回)
  6448. inputData["psn_name"] = struct3505.PsnName // 人员编号 (来自1101接口返回)
  6449. inputData["manu_lotnum"] = struct3505.ManuLotnum // 人员编号 (来自1101接口返回)
  6450. inputData["manu_date"] = struct3505.ManuDate // 人员编号 (来自1101接口返回)
  6451. inputData["expy_end"] = struct3505.ExpyEnd // 人员编号 (来自1101接口返回)
  6452. inputData["rx_flag"] = struct3505.RxFlag // 人员编号 (来自1101接口返回)
  6453. inputData["trdn_flag"] = struct3505.TrdnFlag // 人员编号 (来自1101接口返回)
  6454. inputData["finl_trns_pric"] = struct3505.FinlTrnsPric // 人员编号 (来自1101接口返回)
  6455. inputData["rxno"] = struct3505.Rxno // 人员编号 (来自1101接口返回)
  6456. inputData["rx_circ_flag"] = struct3505.RxCircFlag // 人员编号 (来自1101接口返回)
  6457. inputData["rtal_docno"] = struct3505.RtalDocno // 人员编号 (来自1101接口返回)
  6458. inputData["stoout_no"] = struct3505.StooutNo // 人员编号 (来自1101接口返回)
  6459. inputData["MDTRT_SETL_TYPE"] = struct3505.MdtrtSetlType // 人员编号 (来自1101接口返回)
  6460. inputData["bchno"] = struct3505.Bchno // 人员编号 (来自1101接口返回)
  6461. inputData["drug_trac_codg"] = struct3505.DrugTracCodg // 人员编号 (来自1101接口返回)
  6462. inputData["drug_prod_barc"] = struct3505.DrugProdBarc // 人员编号 (来自1101接口返回)
  6463. inputData["shelf_posi"] = struct3505.ShelfPosi // 人员编号 (来自1101接口返回)
  6464. inputData["sel_retn_cnt"] = struct3505.SelRetnCnt // 人员编号 (来自1101接口返回)
  6465. inputData["sel_retn_time"] = struct3505.SelRetnTime // 人员编号 (来自1101接口返回)
  6466. inputData["sel_retn_opter_name"] = struct3505.SelRetnOpterName // 人员编号 (来自1101接口返回)
  6467. inputData["memo"] = struct3505.Memo // 人员编号 (来自1101接口返回)
  6468. //input["selinfo"] = inputData
  6469. feedetail := make([]map[string]interface{}, 0)
  6470. codes := strings.Split(struct3505.DrugTracCodg, ",")
  6471. for _, item := range codes {
  6472. if len(item) > 0 {
  6473. druginputData := make(map[string]interface{})
  6474. druginputData["drug_trac_codg"] = item
  6475. feedetail = append(feedetail, druginputData)
  6476. }
  6477. }
  6478. inputData["drugtracinfo"] = feedetail
  6479. input["selinfo"] = inputData
  6480. inputMessage["input"] = input //交易输入
  6481. bytesData, err := json.Marshal(inputMessage)
  6482. fmt.Println(string(bytesData))
  6483. if err != nil {
  6484. fmt.Println(err.Error())
  6485. return err.Error(), ""
  6486. }
  6487. reader := bytes.NewReader(bytesData)
  6488. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6489. gdyb_url := beego.AppConfig.String("gdyb_url")
  6490. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6491. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6492. url := gdyb_url + "3505"
  6493. request, err := http.NewRequest("POST", url, reader)
  6494. if err != nil {
  6495. fmt.Println(err.Error())
  6496. return err.Error(), ""
  6497. }
  6498. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6499. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6500. request.Header.Set("x-tif-signature", signature)
  6501. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6502. request.Header.Set("x-tif-nonce", nonce)
  6503. client := http.Client{}
  6504. resp, err := client.Do(request)
  6505. if err != nil {
  6506. fmt.Println(err.Error())
  6507. return err.Error(), ""
  6508. }
  6509. respBytes, err := ioutil.ReadAll(resp.Body)
  6510. if err != nil {
  6511. fmt.Println(err.Error())
  6512. return err.Error(), ""
  6513. }
  6514. str := string(respBytes)
  6515. fmt.Println(str)
  6516. return str, ""
  6517. }
  6518. func Gdyb3506(struct3506 models.Struct3506, secret_key string) (string, string) {
  6519. // 生成签名
  6520. nonce := GetRandomString(32)
  6521. timestamp := time.Now().Unix()
  6522. signature := setSignature(timestamp, nonce, secret_key)
  6523. // 生成输入报文
  6524. inputMessage := SetGdInputMessage(timestamp, struct3506.OrgName, struct3506.Opter, struct3506.FixmedinsCode, struct3506.InsuplcAdmdvs, struct3506.MdtrtareaAdmvs, struct3506.Cainfo)
  6525. input := make(map[string]interface{})
  6526. inputData := make(map[string]interface{})
  6527. inputMessage["infno"] = "3506" // 交易编码
  6528. inputData["med_list_codg"] = struct3506.MedListCodg // 定点医药机构目录编号
  6529. inputData["fixmedins_hilist_id"] = struct3506.FixmedinsHilistId // 定点医药机构目录编号
  6530. inputData["fixmedins_hilist_name"] = struct3506.FixmedinsHilistName // 定点医药机构目录名称
  6531. inputData["fixmedins_bchno"] = struct3506.FixmedinsBchno // 人员编号 (来自1101接口返回)
  6532. inputData["setl_id"] = struct3506.SetlId // 人员编号 (来自1101接口返回)
  6533. inputData["psn_no"] = struct3506.PsnNo // 人员编号 (来自1101接口返回)
  6534. inputData["psn_cert_type"] = struct3506.PsnCertType // 人员编号 (来自1101接口返回)
  6535. inputData["certno"] = struct3506.Certno // 人员编号 (来自1101接口返回)
  6536. inputData["psn_name"] = struct3506.PsnName // 人员编号 (来自1101接口返回)
  6537. inputData["manu_lotnum"] = struct3506.ManuLotnum // 人员编号 (来自1101接口返回)
  6538. inputData["manu_date"] = struct3506.ManuDate // 人员编号 (来自1101接口返回)
  6539. inputData["expy_end"] = struct3506.ExpyEnd // 人员编号 (来自1101接口返回)
  6540. inputData["rx_flag"] = struct3506.RxFlag // 人员编号 (来自1101接口返回)
  6541. inputData["trdn_flag"] = struct3506.TrdnFlag // 人员编号 (来自1101接口返回)
  6542. inputData["finl_trns_pric"] = struct3506.FinlTrnsPric // 人员编号 (来自1101接口返回)
  6543. inputData["sel_retn_cnt"] = struct3506.SelRetnCnt // 人员编号 (来自1101接口返回)
  6544. inputData["sel_retn_time"] = struct3506.SelRetnTime // 人员编号 (来自1101接口返回)
  6545. inputData["sel_retn_opter_name"] = struct3506.SelRetnOpterName // 人员编号 (来自1101接口返回)
  6546. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  6547. inputData["medins_prod_sel_no"] = "" // 人员编号 (来自1101接口返回)
  6548. input["selinfo"] = inputData
  6549. inputMessage["input"] = input //交易输入
  6550. bytesData, err := json.Marshal(inputMessage)
  6551. fmt.Println(string(bytesData))
  6552. if err != nil {
  6553. fmt.Println(err.Error())
  6554. return err.Error(), ""
  6555. }
  6556. reader := bytes.NewReader(bytesData)
  6557. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6558. gdyb_url := beego.AppConfig.String("gdyb_url")
  6559. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6560. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6561. url := gdyb_url + "3506"
  6562. request, err := http.NewRequest("POST", url, reader)
  6563. if err != nil {
  6564. fmt.Println(err.Error())
  6565. return err.Error(), ""
  6566. }
  6567. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6568. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6569. request.Header.Set("x-tif-signature", signature)
  6570. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6571. request.Header.Set("x-tif-nonce", nonce)
  6572. client := http.Client{}
  6573. resp, err := client.Do(request)
  6574. if err != nil {
  6575. fmt.Println(err.Error())
  6576. return err.Error(), ""
  6577. }
  6578. respBytes, err := ioutil.ReadAll(resp.Body)
  6579. if err != nil {
  6580. fmt.Println(err.Error())
  6581. return err.Error(), ""
  6582. }
  6583. str := string(respBytes)
  6584. fmt.Println(str)
  6585. return str, string(bytesData)
  6586. }
  6587. func Gdyb3507(struct3507 models.Struct3507, secret_key string) (string, string) {
  6588. // 生成签名
  6589. nonce := GetRandomString(32)
  6590. timestamp := time.Now().Unix()
  6591. signature := setSignature(timestamp, nonce, secret_key)
  6592. // 生成输入报文
  6593. inputMessage := SetGdInputMessage(timestamp, struct3507.OrgName, struct3507.Opter, struct3507.FixmedinsCode, struct3507.InsuplcAdmdvs, struct3507.MdtrtareaAdmvs, struct3507.Cainfo)
  6594. input := make(map[string]interface{})
  6595. inputData := make(map[string]interface{})
  6596. inputMessage["infno"] = "3507" // 交易编码
  6597. inputData["fixmedins_bchno"] = struct3507.FixmedinsCode // 人员编号 (来自1101接口返回)
  6598. inputData["inv_data_type"] = struct3507.InvDataType // 人员编号 (来自1101接口返回)
  6599. input["data"] = inputData
  6600. inputMessage["input"] = input //交易输入
  6601. bytesData, err := json.Marshal(inputMessage)
  6602. fmt.Println(string(bytesData))
  6603. if err != nil {
  6604. fmt.Println(err.Error())
  6605. return err.Error(), ""
  6606. }
  6607. reader := bytes.NewReader(bytesData)
  6608. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6609. gdyb_url := beego.AppConfig.String("gdyb_url")
  6610. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6611. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6612. url := gdyb_url + "3507"
  6613. request, err := http.NewRequest("POST", url, reader)
  6614. if err != nil {
  6615. fmt.Println(err.Error())
  6616. return err.Error(), ""
  6617. }
  6618. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6619. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6620. request.Header.Set("x-tif-signature", signature)
  6621. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6622. request.Header.Set("x-tif-nonce", nonce)
  6623. client := http.Client{}
  6624. resp, err := client.Do(request)
  6625. if err != nil {
  6626. fmt.Println(err.Error())
  6627. return err.Error(), ""
  6628. }
  6629. respBytes, err := ioutil.ReadAll(resp.Body)
  6630. if err != nil {
  6631. fmt.Println(err.Error())
  6632. return err.Error(), ""
  6633. }
  6634. str := string(respBytes)
  6635. fmt.Println(str)
  6636. return str, string(bytesData)
  6637. }
  6638. func Gdyb3508(struct3508 models.Struct3508, secret_key string) (string, string) {
  6639. // 生成签名
  6640. nonce := GetRandomString(32)
  6641. timestamp := time.Now().Unix()
  6642. signature := setSignature(timestamp, nonce, secret_key)
  6643. // 生成输入报文
  6644. inputMessage := SetGdInputMessage(timestamp, struct3508.OrgName, struct3508.Opter, struct3508.FixmedinsCode, struct3508.InsuplcAdmdvs, struct3508.MdtrtareaAdmvs, struct3508.Cainfo)
  6645. input := make(map[string]interface{})
  6646. inputData := make(map[string]interface{})
  6647. inputMessage["infno"] = "3508"
  6648. inputData["fixmedins_code"] = struct3508.FixmedinsCode
  6649. inputData["medins_list_codg"] = struct3508.MedListCodg
  6650. inputData["fixmedins_bchno"] = ""
  6651. inputData["begndate"] = struct3508.Begndate
  6652. inputData["enddate"] = struct3508.Enddate
  6653. inputData["medins_prod_inv_no"] = ""
  6654. inputData["medins_list_name"] = ""
  6655. inputData["rx_flag"] = ""
  6656. inputData["list_sp_item_flag"] = ""
  6657. inputData["trdn_flag"] = ""
  6658. inputData["invdate"] = ""
  6659. inputData["manu_lotnum"] = ""
  6660. inputData["manu_date"] = ""
  6661. inputData["expy_end"] = ""
  6662. inputData["memo"] = ""
  6663. inputData["vali_flag"] = ""
  6664. inputData["rid"] = ""
  6665. inputData["crter_id"] = ""
  6666. inputData["crter_name"] = ""
  6667. inputData["crte_optins_no"] = ""
  6668. inputData["opter_id"] = ""
  6669. inputData["opter_name"] = ""
  6670. inputData["optins_no"] = ""
  6671. inputData["poolarea_no"] = ""
  6672. inputData["fixmedins_bchno"] = ""
  6673. inputData["inv_data_type"] = ""
  6674. input["data"] = inputData
  6675. inputMessage["input"] = input //交易输入
  6676. bytesData, err := json.Marshal(inputMessage)
  6677. fmt.Println(string(bytesData))
  6678. if err != nil {
  6679. fmt.Println(err.Error())
  6680. return err.Error(), ""
  6681. }
  6682. reader := bytes.NewReader(bytesData)
  6683. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6684. gdyb_url := beego.AppConfig.String("gdyb_url")
  6685. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6686. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6687. url := gdyb_url + "3508"
  6688. request, err := http.NewRequest("POST", url, reader)
  6689. if err != nil {
  6690. fmt.Println(err.Error())
  6691. return err.Error(), ""
  6692. }
  6693. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6694. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6695. request.Header.Set("x-tif-signature", signature)
  6696. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6697. request.Header.Set("x-tif-nonce", nonce)
  6698. client := http.Client{}
  6699. resp, err := client.Do(request)
  6700. if err != nil {
  6701. fmt.Println(err.Error())
  6702. return err.Error(), ""
  6703. }
  6704. respBytes, err := ioutil.ReadAll(resp.Body)
  6705. if err != nil {
  6706. fmt.Println(err.Error())
  6707. return err.Error(), ""
  6708. }
  6709. str := string(respBytes)
  6710. fmt.Println(str)
  6711. return str, string(bytesData)
  6712. }
  6713. func Gdyb3509(struct3509 models.Struct3509, secret_key string) (string, string) {
  6714. // 生成签名
  6715. nonce := GetRandomString(32)
  6716. timestamp := time.Now().Unix()
  6717. signature := setSignature(timestamp, nonce, secret_key)
  6718. // 生成输入报文
  6719. inputMessage := SetGdInputMessage(timestamp, struct3509.OrgName, struct3509.Opter, struct3509.FixmedinsCode, struct3509.InsuplcAdmdvs, struct3509.MdtrtareaAdmvs, struct3509.Cainfo)
  6720. input := make(map[string]interface{})
  6721. inputData := make(map[string]interface{})
  6722. inputMessage["infno"] = "3509"
  6723. inputData["fixmedins_code"] = struct3509.FixmedinsCode
  6724. //inputData["med_list_codg"] = struct3509.MedinsListCodg
  6725. inputData["medins_list_codg"] = struct3509.MedListCodg
  6726. inputData["fixmedins_bchno"] = ""
  6727. inputData["begndate"] = struct3509.Begndate
  6728. inputData["enddate"] = struct3509.Enddate
  6729. inputData["medins_prod_inv_no"] = ""
  6730. inputData["medins_list_name"] = ""
  6731. inputData["rx_flag"] = ""
  6732. inputData["list_sp_item_flag"] = ""
  6733. inputData["trdn_flag"] = ""
  6734. inputData["invdate"] = ""
  6735. inputData["manu_lotnum"] = ""
  6736. inputData["manu_date"] = ""
  6737. inputData["expy_end"] = ""
  6738. inputData["memo"] = ""
  6739. inputData["vali_flag"] = ""
  6740. inputData["rid"] = ""
  6741. inputData["crter_id"] = ""
  6742. inputData["crter_name"] = ""
  6743. inputData["crte_optins_no"] = ""
  6744. inputData["opter_id"] = ""
  6745. inputData["opter_name"] = ""
  6746. inputData["optins_no"] = ""
  6747. inputData["poolarea_no"] = ""
  6748. inputData["fixmedins_bchno"] = ""
  6749. inputData["inv_data_type"] = ""
  6750. input["data"] = inputData
  6751. inputMessage["input"] = input //交易输入
  6752. bytesData, err := json.Marshal(inputMessage)
  6753. fmt.Println(string(bytesData))
  6754. if err != nil {
  6755. fmt.Println(err.Error())
  6756. return err.Error(), ""
  6757. }
  6758. reader := bytes.NewReader(bytesData)
  6759. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6760. gdyb_url := beego.AppConfig.String("gdyb_url")
  6761. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6762. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6763. url := gdyb_url + "3509"
  6764. request, err := http.NewRequest("POST", url, reader)
  6765. if err != nil {
  6766. fmt.Println(err.Error())
  6767. return err.Error(), ""
  6768. }
  6769. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6770. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6771. request.Header.Set("x-tif-signature", signature)
  6772. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6773. request.Header.Set("x-tif-nonce", nonce)
  6774. client := http.Client{}
  6775. resp, err := client.Do(request)
  6776. if err != nil {
  6777. fmt.Println(err.Error())
  6778. return err.Error(), ""
  6779. }
  6780. respBytes, err := ioutil.ReadAll(resp.Body)
  6781. if err != nil {
  6782. fmt.Println(err.Error())
  6783. return err.Error(), ""
  6784. }
  6785. str := string(respBytes)
  6786. fmt.Println(str)
  6787. return str, string(bytesData)
  6788. }
  6789. func Gdyb3510(struct3510 models.Struct3510, secret_key string) (string, string) {
  6790. // 生成签名
  6791. nonce := GetRandomString(32)
  6792. timestamp := time.Now().Unix()
  6793. signature := setSignature(timestamp, nonce, secret_key)
  6794. // 生成输入报文
  6795. inputMessage := SetGdInputMessage(timestamp, struct3510.OrgName, struct3510.Opter, struct3510.FixmedinsCode, struct3510.InsuplcAdmdvs, struct3510.MdtrtareaAdmvs, struct3510.Cainfo)
  6796. input := make(map[string]interface{})
  6797. inputData := make(map[string]interface{})
  6798. inputMessage["infno"] = "3510"
  6799. inputData["fixmedins_code"] = struct3510.FixmedinsCode
  6800. //inputData["medins_list_codg"] = struct3510.MedinsListCodg
  6801. inputData["medins_list_codg"] = struct3510.MedListCodg
  6802. inputData["fixmedins_bchno"] = ""
  6803. inputData["begndate"] = struct3510.Begndate
  6804. inputData["enddate"] = struct3510.Enddate
  6805. inputData["medins_prod_inv_no"] = ""
  6806. inputData["medins_list_name"] = ""
  6807. inputData["rx_flag"] = ""
  6808. inputData["list_sp_item_flag"] = ""
  6809. inputData["trdn_flag"] = ""
  6810. inputData["invdate"] = ""
  6811. inputData["manu_lotnum"] = ""
  6812. inputData["manu_date"] = ""
  6813. inputData["expy_end"] = ""
  6814. inputData["memo"] = ""
  6815. inputData["vali_flag"] = ""
  6816. inputData["rid"] = ""
  6817. inputData["crter_id"] = ""
  6818. inputData["crter_name"] = ""
  6819. inputData["crte_optins_no"] = ""
  6820. inputData["opter_id"] = ""
  6821. inputData["opter_name"] = ""
  6822. inputData["optins_no"] = ""
  6823. inputData["poolarea_no"] = ""
  6824. inputData["fixmedins_bchno"] = ""
  6825. inputData["inv_data_type"] = ""
  6826. input["data"] = inputData
  6827. inputMessage["input"] = input //交易输入
  6828. bytesData, err := json.Marshal(inputMessage)
  6829. fmt.Println(string(bytesData))
  6830. if err != nil {
  6831. fmt.Println(err.Error())
  6832. return err.Error(), ""
  6833. }
  6834. reader := bytes.NewReader(bytesData)
  6835. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6836. gdyb_url := beego.AppConfig.String("gdyb_url")
  6837. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6838. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6839. url := gdyb_url + "3510"
  6840. request, err := http.NewRequest("POST", url, reader)
  6841. if err != nil {
  6842. fmt.Println(err.Error())
  6843. return err.Error(), ""
  6844. }
  6845. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6846. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6847. request.Header.Set("x-tif-signature", signature)
  6848. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6849. request.Header.Set("x-tif-nonce", nonce)
  6850. client := http.Client{}
  6851. resp, err := client.Do(request)
  6852. if err != nil {
  6853. fmt.Println(err.Error())
  6854. return err.Error(), ""
  6855. }
  6856. respBytes, err := ioutil.ReadAll(resp.Body)
  6857. if err != nil {
  6858. fmt.Println(err.Error())
  6859. return err.Error(), ""
  6860. }
  6861. str := string(respBytes)
  6862. fmt.Println(str)
  6863. return str, string(bytesData)
  6864. }
  6865. func Gdyb3511(struct3511 models.Struct3511, secret_key string) (string, string) {
  6866. // 生成签名
  6867. nonce := GetRandomString(32)
  6868. timestamp := time.Now().Unix()
  6869. signature := setSignature(timestamp, nonce, secret_key)
  6870. // 生成输入报文
  6871. inputMessage := SetGdInputMessage(timestamp, struct3511.OrgName, struct3511.Opter, struct3511.FixmedinsCode, struct3511.InsuplcAdmdvs, struct3511.MdtrtareaAdmvs, struct3511.Cainfo)
  6872. input := make(map[string]interface{})
  6873. inputData := make(map[string]interface{})
  6874. inputMessage["infno"] = "3511"
  6875. inputData["fixmedins_code"] = struct3511.FixmedinsCode
  6876. //inputData["medins_list_codg"] = struct3511.MedinsListCodg
  6877. inputData["medins_list_codg"] = struct3511.MedListCodg
  6878. inputData["fixmedins_bchno"] = ""
  6879. inputData["begndate"] = struct3511.Begndate
  6880. inputData["enddate"] = struct3511.Enddate
  6881. inputData["medins_prod_inv_no"] = ""
  6882. inputData["medins_list_name"] = ""
  6883. inputData["rx_flag"] = ""
  6884. inputData["list_sp_item_flag"] = ""
  6885. inputData["trdn_flag"] = ""
  6886. inputData["invdate"] = ""
  6887. inputData["manu_lotnum"] = ""
  6888. inputData["manu_date"] = ""
  6889. inputData["expy_end"] = ""
  6890. inputData["memo"] = ""
  6891. inputData["vali_flag"] = ""
  6892. inputData["rid"] = ""
  6893. inputData["crter_id"] = ""
  6894. inputData["crter_name"] = ""
  6895. inputData["crte_optins_no"] = ""
  6896. inputData["opter_id"] = ""
  6897. inputData["opter_name"] = ""
  6898. inputData["optins_no"] = ""
  6899. inputData["poolarea_no"] = ""
  6900. inputData["fixmedins_bchno"] = ""
  6901. inputData["inv_data_type"] = ""
  6902. input["data"] = inputData
  6903. inputMessage["input"] = input //交易输入
  6904. bytesData, err := json.Marshal(inputMessage)
  6905. fmt.Println(string(bytesData))
  6906. if err != nil {
  6907. fmt.Println(err.Error())
  6908. return err.Error(), ""
  6909. }
  6910. reader := bytes.NewReader(bytesData)
  6911. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6912. gdyb_url := beego.AppConfig.String("gdyb_url")
  6913. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6914. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6915. url := gdyb_url + "3511"
  6916. request, err := http.NewRequest("POST", url, reader)
  6917. if err != nil {
  6918. fmt.Println(err.Error())
  6919. return err.Error(), ""
  6920. }
  6921. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6922. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6923. request.Header.Set("x-tif-signature", signature)
  6924. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  6925. request.Header.Set("x-tif-nonce", nonce)
  6926. client := http.Client{}
  6927. resp, err := client.Do(request)
  6928. if err != nil {
  6929. fmt.Println(err.Error())
  6930. return err.Error(), ""
  6931. }
  6932. respBytes, err := ioutil.ReadAll(resp.Body)
  6933. if err != nil {
  6934. fmt.Println(err.Error())
  6935. return err.Error(), ""
  6936. }
  6937. str := string(respBytes)
  6938. fmt.Println(str)
  6939. return str, string(bytesData)
  6940. }
  6941. func Gdyb3512(struct3512 models.Struct3512, secret_key string) (string, string) {
  6942. // 生成签名
  6943. nonce := GetRandomString(32)
  6944. timestamp := time.Now().Unix()
  6945. signature := setSignature(timestamp, nonce, secret_key)
  6946. // 生成输入报文
  6947. inputMessage := SetGdInputMessage(timestamp, struct3512.OrgName, struct3512.Opter, struct3512.FixmedinsCode, struct3512.InsuplcAdmdvs, struct3512.MdtrtareaAdmvs, struct3512.Cainfo)
  6948. input := make(map[string]interface{})
  6949. inputData := make(map[string]interface{})
  6950. inputMessage["infno"] = "3512"
  6951. inputData["fixmedins_code"] = struct3512.FixmedinsCode
  6952. //inputData["medins_list_codg"] = struct3512.MedinsListCodg
  6953. inputData["medins_list_codg"] = struct3512.MedListCodg
  6954. inputData["fixmedins_bchno"] = ""
  6955. inputData["begndate"] = struct3512.Begndate
  6956. inputData["enddate"] = struct3512.Enddate
  6957. inputData["medins_prod_inv_no"] = ""
  6958. inputData["medins_list_name"] = ""
  6959. inputData["rx_flag"] = ""
  6960. inputData["list_sp_item_flag"] = ""
  6961. inputData["trdn_flag"] = ""
  6962. inputData["invdate"] = ""
  6963. inputData["manu_lotnum"] = ""
  6964. inputData["manu_date"] = ""
  6965. inputData["expy_end"] = ""
  6966. inputData["memo"] = ""
  6967. inputData["vali_flag"] = ""
  6968. inputData["rid"] = ""
  6969. inputData["crter_id"] = ""
  6970. inputData["crter_name"] = ""
  6971. inputData["crte_optins_no"] = ""
  6972. inputData["opter_id"] = ""
  6973. inputData["opter_name"] = ""
  6974. inputData["optins_no"] = ""
  6975. inputData["poolarea_no"] = ""
  6976. inputData["fixmedins_bchno"] = ""
  6977. inputData["inv_data_type"] = ""
  6978. input["data"] = inputData
  6979. inputMessage["input"] = input //交易输入
  6980. bytesData, err := json.Marshal(inputMessage)
  6981. fmt.Println(string(bytesData))
  6982. if err != nil {
  6983. fmt.Println(err.Error())
  6984. return err.Error(), ""
  6985. }
  6986. reader := bytes.NewReader(bytesData)
  6987. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  6988. gdyb_url := beego.AppConfig.String("gdyb_url")
  6989. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  6990. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  6991. url := gdyb_url + "3512"
  6992. request, err := http.NewRequest("POST", url, reader)
  6993. if err != nil {
  6994. fmt.Println(err.Error())
  6995. return err.Error(), ""
  6996. }
  6997. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  6998. request.Header.Set("x-tif-paasid", gdyb_paasid)
  6999. request.Header.Set("x-tif-signature", signature)
  7000. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  7001. request.Header.Set("x-tif-nonce", nonce)
  7002. client := http.Client{}
  7003. resp, err := client.Do(request)
  7004. if err != nil {
  7005. fmt.Println(err.Error())
  7006. return err.Error(), ""
  7007. }
  7008. respBytes, err := ioutil.ReadAll(resp.Body)
  7009. if err != nil {
  7010. fmt.Println(err.Error())
  7011. return err.Error(), ""
  7012. }
  7013. str := string(respBytes)
  7014. fmt.Println(str)
  7015. return str, string(bytesData)
  7016. }
  7017. func Gdyb3513(struct3513 models.Struct3513, secret_key string) (string, string) {
  7018. // 生成签名
  7019. nonce := GetRandomString(32)
  7020. timestamp := time.Now().Unix()
  7021. signature := setSignature(timestamp, nonce, secret_key)
  7022. // 生成输入报文
  7023. inputMessage := SetGdInputMessage(timestamp, struct3513.OrgName, struct3513.Opter, struct3513.FixmedinsCode, struct3513.InsuplcAdmdvs, struct3513.MdtrtareaAdmvs, struct3513.Cainfo)
  7024. input := make(map[string]interface{})
  7025. inputData := make(map[string]interface{})
  7026. inputMessage["infno"] = "3513"
  7027. inputData["fixmedins_code"] = struct3513.FixmedinsCode
  7028. //inputData["medins_list_codg"] = struct3513.MedinsListCodg
  7029. inputData["medins_list_codg"] = struct3513.MedListCodg
  7030. inputData["fixmedins_bchno"] = ""
  7031. inputData["begndate"] = struct3513.Begndate
  7032. inputData["enddate"] = struct3513.Enddate
  7033. inputData["medins_prod_inv_no"] = ""
  7034. inputData["med_list_codg"] = ""
  7035. inputData["medins_list_name"] = ""
  7036. inputData["rx_flag"] = ""
  7037. inputData["list_sp_item_flag"] = ""
  7038. inputData["trdn_flag"] = ""
  7039. inputData["invdate"] = ""
  7040. inputData["manu_lotnum"] = ""
  7041. inputData["manu_date"] = ""
  7042. inputData["expy_end"] = ""
  7043. inputData["memo"] = ""
  7044. inputData["vali_flag"] = ""
  7045. inputData["rid"] = ""
  7046. inputData["crter_id"] = ""
  7047. inputData["crter_name"] = ""
  7048. inputData["crte_optins_no"] = ""
  7049. inputData["opter_id"] = ""
  7050. inputData["opter_name"] = ""
  7051. inputData["optins_no"] = ""
  7052. inputData["poolarea_no"] = ""
  7053. inputData["fixmedins_bchno"] = ""
  7054. inputData["inv_data_type"] = ""
  7055. input["data"] = inputData
  7056. inputMessage["input"] = input //交易输入
  7057. bytesData, err := json.Marshal(inputMessage)
  7058. fmt.Println(string(bytesData))
  7059. if err != nil {
  7060. fmt.Println(err.Error())
  7061. return err.Error(), ""
  7062. }
  7063. reader := bytes.NewReader(bytesData)
  7064. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7065. gdyb_url := beego.AppConfig.String("gdyb_url")
  7066. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7067. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7068. url := gdyb_url + "3513"
  7069. request, err := http.NewRequest("POST", url, reader)
  7070. if err != nil {
  7071. fmt.Println(err.Error())
  7072. return err.Error(), ""
  7073. }
  7074. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  7075. request.Header.Set("x-tif-paasid", gdyb_paasid)
  7076. request.Header.Set("x-tif-signature", signature)
  7077. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  7078. request.Header.Set("x-tif-nonce", nonce)
  7079. client := http.Client{}
  7080. resp, err := client.Do(request)
  7081. if err != nil {
  7082. fmt.Println(err.Error())
  7083. return err.Error(), ""
  7084. }
  7085. respBytes, err := ioutil.ReadAll(resp.Body)
  7086. if err != nil {
  7087. fmt.Println(err.Error())
  7088. return err.Error(), ""
  7089. }
  7090. str := string(respBytes)
  7091. fmt.Println(str)
  7092. return str, string(bytesData)
  7093. }
  7094. // 生成基础报文
  7095. func SetGdInputMessage(timestamp int64, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, cainfo string) map[string]interface{} {
  7096. // 生成签名
  7097. tempTime := time.Unix(timestamp, 0)
  7098. //timeFormat := tempTime.Format("20060102150405")
  7099. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  7100. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  7101. month := time.Unix(1557042972, 0).Format("1")
  7102. year := time.Now().Format("2006")
  7103. month = time.Now().Format("01")
  7104. day := time.Now().Format("02")
  7105. hour := time.Now().Format("15")
  7106. min := time.Now().Format("04")
  7107. sec := time.Now().Format("05")
  7108. msec := time.Now().Format("000")
  7109. // 生成输入报文
  7110. inputMessage := make(map[string]interface{})
  7111. inputMessage["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  7112. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  7113. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  7114. inputMessage["recer_sys_code"] = "MBS_LOCAL" // 接收方系统代码
  7115. inputMessage["dev_no"] = "1" // 设备编号
  7116. inputMessage["dev_safe_info"] = "1" // 设备安全信息
  7117. inputMessage["cainfo"] = cainfo // 数字签名信息
  7118. inputMessage["signtype"] = "SM3" // 签名类型
  7119. inputMessage["infver"] = "1.0.0" // 接收方系统代码
  7120. inputMessage["opter_type"] = "1" // 经办人类别
  7121. inputMessage["opter"] = doctor // 经办人
  7122. inputMessage["opter_name"] = doctor // 经办人姓名
  7123. inputMessage["inf_time"] = timeFormatOne // 交易时间
  7124. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  7125. inputMessage["fixmedins_name"] = org_name
  7126. inputMessage["fixmedins_soft_fcty"] = "深圳市领透科技有限公司" //定点医药机构名称
  7127. //定点医药机构名称
  7128. inputMessage["sign_no"] = "" //交易签到流水号
  7129. return inputMessage
  7130. }
  7131. func Gdyb3101(pd models.PatientDtos, fed models.FsiEncounterDtos, fdds []*models.FsiDiagnoseDtos, fods []*models.FsiOrderDtos, fopds []*models.FsiOperationDtosData, params models.PublicParams, trig_scen string) (string, string) {
  7132. nonce := GetRandomString(32)
  7133. timestamp := time.Now().Unix()
  7134. signature := setSignature(timestamp, nonce, params.SecretKey)
  7135. // 生成输入报文
  7136. inputMessage := SetGdInputMessage(timestamp, params.FixmedinsName, params.OpterName, params.FixmedinsCode, params.InsuplcAdmdvs, params.MdtrtareaAdmvs, params.Cainfo)
  7137. //inputMessage := SetJSInputMessage(timestamp, params.FixmedinsName, params.OpterName, params.FixmedinsCode, params.InsuplcAdmdvs, params.MdtrtareaAdmvs, params.Cainfo)
  7138. input := make(map[string]interface{})
  7139. inputData := make(map[string]interface{})
  7140. patientDtosinputData := make(map[string]interface{})
  7141. fisEncounterDtosData := make(map[string]interface{})
  7142. fsiDiagnoseDtosDatas := make([]map[string]interface{}, 0)
  7143. fsiOrderDtosDatas := make([]map[string]interface{}, 0)
  7144. fsiOperationDtosData := make(map[string]interface{})
  7145. fsiOperationDtosDatas := make([]map[string]interface{}, 0)
  7146. //就诊信息
  7147. fisEncounterDtosData["mdtrt_id"] = fed.MdtrtID
  7148. fisEncounterDtosData["medins_id"] = fed.MedinsID
  7149. fisEncounterDtosData["medins_name"] = fed.MedinsName
  7150. fisEncounterDtosData["medins_admdvs"] = fed.MedinsAdmdvs
  7151. fisEncounterDtosData["medins_type"] = fed.MedinsType
  7152. fisEncounterDtosData["medins_lv"] = fed.MedinsLv
  7153. fisEncounterDtosData["wardarea_codg"] = fed.WardareaCodg
  7154. fisEncounterDtosData["wardno"] = fed.Wardno
  7155. fisEncounterDtosData["bedno"] = fed.Bedno
  7156. fisEncounterDtosData["adm_date"] = fed.AdmDate
  7157. fisEncounterDtosData["dscg_date"] = fed.DscgDate
  7158. fisEncounterDtosData["dscg_main_dise_codg"] = fed.DscgMainDiseCodg
  7159. fisEncounterDtosData["dscg_main_dise_name"] = fed.DscgMainDiseName
  7160. for _, fdd := range fdds {
  7161. fsiDiagnoseDtosData := make(map[string]interface{})
  7162. //诊断集合
  7163. fsiDiagnoseDtosData["dise_id"] = fdd.DiseID
  7164. fsiDiagnoseDtosData["inout_dise_type"] = fdd.InoutDiseType
  7165. fsiDiagnoseDtosData["maindise_flag"] = fdd.MaindiseFlag
  7166. fsiDiagnoseDtosData["dias_srt_no"] = fdd.DiasSrtNo
  7167. fsiDiagnoseDtosData["dise_codg"] = fdd.DiseCodg
  7168. fsiDiagnoseDtosData["dise_name"] = fdd.DiseName
  7169. fsiDiagnoseDtosData["dise_date"] = fdd.DiseDate
  7170. fsiDiagnoseDtosDatas = append(fsiDiagnoseDtosDatas, fsiDiagnoseDtosData)
  7171. }
  7172. fisEncounterDtosData["fsi_diagnose_dtos"] = fsiDiagnoseDtosDatas
  7173. fisEncounterDtosData["dr_codg"] = fed.DrCodg
  7174. fisEncounterDtosData["adm_dept_codg"] = fed.AdmDeptCodg
  7175. fisEncounterDtosData["adm_dept_name"] = fed.AdmDeptName
  7176. fisEncounterDtosData["dscg_dept_codg"] = fed.DscgDeptCodg
  7177. fisEncounterDtosData["dscg_dept_name"] = fed.DscgDeptName
  7178. fisEncounterDtosData["med_mdtrt_type"] = fed.MedMdtrtType
  7179. fisEncounterDtosData["med_type"] = fed.MedType
  7180. for _, fod := range fods {
  7181. fsiOrderDtosData := make(map[string]interface{})
  7182. //医嘱集合
  7183. fsiOrderDtosData["rx_id"] = fod.RxID
  7184. fsiOrderDtosData["rxno"] = fod.Rxno
  7185. fsiOrderDtosData["grpno"] = fod.Grpno
  7186. fsiOrderDtosData["long_drord_flag"] = fod.LongDrordFlag
  7187. fsiOrderDtosData["hilist_type"] = fod.HilistType
  7188. fsiOrderDtosData["chrg_type"] = fod.ChrgType
  7189. fsiOrderDtosData["drord_bhvr"] = fod.DrordBhvr
  7190. fsiOrderDtosData["hilist_code"] = fod.HilistCode
  7191. fsiOrderDtosData["hilist_name"] = fod.HosplistName
  7192. fsiOrderDtosData["hilist_dosform"] = fod.HilistDosform
  7193. fsiOrderDtosData["hilist_lv"] = fod.HilistLv
  7194. fsiOrderDtosData["hilist_pric"] = fod.HilistPric
  7195. fsiOrderDtosData["lv1_hosp_item_pric"] = fod.Lv1HospItemPric
  7196. fsiOrderDtosData["lv2_hosp_item_pric"] = fod.Lv2HospItemPric
  7197. fsiOrderDtosData["lv3_hosp_item_pric"] = fod.Lv3HospItemPric
  7198. fsiOrderDtosData["hilist_memo"] = fod.HilistMemo
  7199. fsiOrderDtosData["hosplist_code"] = fod.HosplistCode
  7200. fsiOrderDtosData["hosplist_name"] = fod.HosplistName
  7201. fsiOrderDtosData["hosplist_dosform"] = fod.HosplistDosform
  7202. fsiOrderDtosData["cnt"] = fod.Cnt
  7203. fsiOrderDtosData["pric"] = fod.Pric
  7204. fsiOrderDtosData["sumamt"] = fod.Sumamt
  7205. fsiOrderDtosData["ownpay_amt"] = fod.OwnpayAmt
  7206. fsiOrderDtosData["selfpay_amt"] = fod.SelfpayAmt
  7207. fsiOrderDtosData["spec"] = fod.Spec
  7208. fsiOrderDtosData["spec_unt"] = fod.SpecUnt
  7209. fsiOrderDtosData["drord_begn_date"] = fod.DrordBegnDate
  7210. fsiOrderDtosData["drord_stop_date"] = fod.DrordStopDate
  7211. fsiOrderDtosData["drord_dept_codg"] = fod.DrordDeptCodg
  7212. fsiOrderDtosData["drord_dept_name"] = fod.DrordDeptName
  7213. fsiOrderDtosData["drord_dr_codg"] = fod.DrordDrCodg
  7214. fsiOrderDtosData["drord_dr_name"] = fod.DrordDrName
  7215. fsiOrderDtosData["drord_dr_profttl"] = fod.DrordDrProfttl
  7216. fsiOrderDtosData["curr_drord_flag"] = fod.CurrDrordFlag
  7217. fsiOrderDtosDatas = append(fsiOrderDtosDatas, fsiOrderDtosData)
  7218. }
  7219. fisEncounterDtosData["fsi_order_dtos"] = fsiOrderDtosDatas
  7220. fisEncounterDtosData["matn_stas"] = fed.MatnStas
  7221. fisEncounterDtosData["medfee_sumamt"] = fed.MedfeeSumamt
  7222. fisEncounterDtosData["ownpay_amt"] = fed.OwnpayAmt
  7223. fisEncounterDtosData["selfpay_amt"] = fed.SelfpayAmt
  7224. fisEncounterDtosData["acct_payamt"] = fed.AcctPayamt
  7225. fisEncounterDtosData["ma_amt"] = fed.MaAmt
  7226. fisEncounterDtosData["hifp_payamt"] = fed.HifpPayamt
  7227. fisEncounterDtosData["setl_totlnum"] = fed.SetlTotlnum
  7228. fisEncounterDtosData["insutype"] = fed.Insutype
  7229. fisEncounterDtosData["reim_flag"] = fed.ReimFlag
  7230. fisEncounterDtosData["out_setl_flag"] = fed.OutSetlFlag
  7231. //手术操作
  7232. for _, fopd := range fopds {
  7233. fsiOperationDtosData["setl_list_oprn_id"] = fopd.Setl_list_oprn_id
  7234. fsiOperationDtosData["oprn_code"] = fopd.Oprn_code
  7235. fsiOperationDtosData["oprn_name"] = fopd.Oprn_name
  7236. fsiOperationDtosData["main_oprn_flag"] = fopd.Main_oprn_flag
  7237. fsiOperationDtosData["oprn_date"] = fopd.Oprn_date
  7238. fsiOperationDtosData["anst_way"] = fopd.Anst_way
  7239. fsiOperationDtosData["oper_dr_name"] = fopd.Oper_dr_name
  7240. fsiOperationDtosData["oper_dr_code"] = fopd.Oper_dr_code
  7241. fsiOperationDtosData["anst_dr_name"] = fopd.Anst_dr_name
  7242. fsiOperationDtosData["anst_dr_code"] = fopd.Anst_dr_code
  7243. fsiOperationDtosDatas = append(fsiOperationDtosDatas, fsiOperationDtosData)
  7244. }
  7245. fisEncounterDtosData["fsi_operation_dtos"] = fsiOperationDtosDatas
  7246. patientDtosinputData["patn_id"] = pd.PatnID
  7247. patientDtosinputData["patn_name"] = pd.PatnName
  7248. patientDtosinputData["gend"] = pd.Gend
  7249. patientDtosinputData["brdy"] = pd.Brdy
  7250. patientDtosinputData["poolarea"] = pd.Poolarea
  7251. patientDtosinputData["curr_mdtrt_id"] = pd.CurrMdtrtID
  7252. patientDtosinputData["fsi_his_data_dto"] = ""
  7253. patientDtosinputData["fsi_encounter_dtos"] = fisEncounterDtosData
  7254. inputData["syscode"] = "LinkDialysis"
  7255. inputData["trig_scen"] = trig_scen
  7256. inputData["rule_ids"] = ""
  7257. inputData["task_id"] = ""
  7258. inputData["patient_dtos"] = patientDtosinputData
  7259. input["data"] = inputData
  7260. inputMessage["infno"] = "3101"
  7261. inputMessage["input"] = input //交易输入
  7262. bytesData, err := json.Marshal(inputMessage)
  7263. fmt.Println(string(bytesData))
  7264. if err != nil {
  7265. fmt.Println(err.Error())
  7266. return err.Error(), ""
  7267. }
  7268. reader := bytes.NewReader(bytesData)
  7269. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7270. gdyb_url := beego.AppConfig.String("gdyb_url")
  7271. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7272. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7273. url := gdyb_url + "3101"
  7274. request, err := http.NewRequest("POST", url, reader)
  7275. if err != nil {
  7276. fmt.Println(err.Error())
  7277. return err.Error(), ""
  7278. }
  7279. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  7280. request.Header.Set("x-tif-paasid", gdyb_paasid)
  7281. request.Header.Set("x-tif-signature", signature)
  7282. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  7283. request.Header.Set("x-tif-nonce", nonce)
  7284. client := http.Client{}
  7285. resp, err := client.Do(request)
  7286. if err != nil {
  7287. fmt.Println(err.Error())
  7288. return err.Error(), ""
  7289. }
  7290. respBytes, err := ioutil.ReadAll(resp.Body)
  7291. if err != nil {
  7292. fmt.Println(err.Error())
  7293. return err.Error(), ""
  7294. }
  7295. str := string(respBytes)
  7296. fmt.Println(str)
  7297. return str, string(bytesData)
  7298. }
  7299. func Gdyb3102(pd models.PatientDtos, fed models.FsiEncounterDtos, fdds []*models.FsiDiagnoseDtos, fods []*models.FsiOrderDtos, fopds []*models.FsiOperationDtosData, params models.PublicParams, trig_scen string) (string, string) {
  7300. nonce := GetRandomString(32)
  7301. timestamp := time.Now().Unix()
  7302. signature := setSignature(timestamp, nonce, params.SecretKey)
  7303. // 生成输入报文
  7304. inputMessage := SetGdInputMessage(timestamp, params.FixmedinsName, params.OpterName, params.FixmedinsCode, params.InsuplcAdmdvs, params.MdtrtareaAdmvs, params.Cainfo)
  7305. input := make(map[string]interface{})
  7306. inputData := make(map[string]interface{})
  7307. patientDtosinputData := make(map[string]interface{})
  7308. fisEncounterDtosData := make(map[string]interface{})
  7309. fsiDiagnoseDtosDatas := make([]map[string]interface{}, 0)
  7310. fsiOrderDtosDatas := make([]map[string]interface{}, 0)
  7311. fsiOperationDtosData := make(map[string]interface{})
  7312. fsiOperationDtosDatas := make([]map[string]interface{}, 0)
  7313. //就诊信息
  7314. fisEncounterDtosData["mdtrt_id"] = fed.MdtrtID
  7315. fisEncounterDtosData["medins_id"] = fed.MedinsID
  7316. fisEncounterDtosData["medins_name"] = fed.MedinsName
  7317. fisEncounterDtosData["medins_admdvs"] = fed.MedinsAdmdvs
  7318. fisEncounterDtosData["medins_type"] = fed.MedinsType
  7319. fisEncounterDtosData["medins_lv"] = fed.MedinsLv
  7320. fisEncounterDtosData["wardarea_codg"] = fed.WardareaCodg
  7321. fisEncounterDtosData["wardno"] = fed.Wardno
  7322. fisEncounterDtosData["bedno"] = fed.Bedno
  7323. fisEncounterDtosData["adm_date"] = fed.AdmDate
  7324. fisEncounterDtosData["dscg_date"] = fed.DscgDate
  7325. fisEncounterDtosData["dscg_main_dise_codg"] = fed.DscgMainDiseCodg
  7326. fisEncounterDtosData["dscg_main_dise_name"] = fed.DscgMainDiseName
  7327. for _, fdd := range fdds {
  7328. fsiDiagnoseDtosData := make(map[string]interface{})
  7329. //诊断集合
  7330. fsiDiagnoseDtosData["dise_id"] = fdd.DiseID
  7331. fsiDiagnoseDtosData["inout_dise_type"] = fdd.InoutDiseType
  7332. fsiDiagnoseDtosData["maindise_flag"] = fdd.MaindiseFlag
  7333. fsiDiagnoseDtosData["dias_srt_no"] = fdd.DiasSrtNo
  7334. fsiDiagnoseDtosData["dise_codg"] = fdd.DiseCodg
  7335. fsiDiagnoseDtosData["dise_name"] = fdd.DiseName
  7336. fsiDiagnoseDtosData["dise_date"] = fdd.DiseDate
  7337. fsiDiagnoseDtosDatas = append(fsiDiagnoseDtosDatas, fsiDiagnoseDtosData)
  7338. }
  7339. fisEncounterDtosData["fsi_diagnose_dtos"] = fsiDiagnoseDtosDatas
  7340. fisEncounterDtosData["dr_codg"] = fed.DrCodg
  7341. fisEncounterDtosData["adm_dept_codg"] = fed.AdmDeptCodg
  7342. fisEncounterDtosData["adm_dept_name"] = fed.AdmDeptName
  7343. fisEncounterDtosData["dscg_dept_codg"] = fed.DscgDeptCodg
  7344. fisEncounterDtosData["dscg_dept_name"] = fed.DscgDeptName
  7345. fisEncounterDtosData["med_mdtrt_type"] = fed.MedMdtrtType
  7346. fisEncounterDtosData["med_type"] = fed.MedType
  7347. for _, fod := range fods {
  7348. fsiOrderDtosData := make(map[string]interface{})
  7349. //医嘱集合
  7350. fsiOrderDtosData["rx_id"] = fod.RxID
  7351. fsiOrderDtosData["rxno"] = fod.Rxno
  7352. fsiOrderDtosData["grpno"] = fod.Grpno
  7353. fsiOrderDtosData["long_drord_flag"] = fod.LongDrordFlag
  7354. fsiOrderDtosData["hilist_type"] = fod.HilistType
  7355. fsiOrderDtosData["chrg_type"] = fod.ChrgType
  7356. fsiOrderDtosData["drord_bhvr"] = fod.DrordBhvr
  7357. fsiOrderDtosData["hilist_code"] = fod.HosplistCode
  7358. fsiOrderDtosData["hilist_name"] = fod.HosplistName
  7359. fsiOrderDtosData["hilist_dosform"] = fod.HilistDosform
  7360. fsiOrderDtosData["hilist_lv"] = fod.HilistLv
  7361. fsiOrderDtosData["hilist_pric"] = fod.HilistPric
  7362. fsiOrderDtosData["lv1_hosp_item_pric"] = fod.Lv1HospItemPric
  7363. fsiOrderDtosData["lv2_hosp_item_pric"] = fod.Lv2HospItemPric
  7364. fsiOrderDtosData["lv3_hosp_item_pric"] = fod.Lv3HospItemPric
  7365. fsiOrderDtosData["hilist_memo"] = fod.HilistMemo
  7366. fsiOrderDtosData["hosplist_code"] = fod.HosplistCode
  7367. fsiOrderDtosData["hosplist_name"] = fod.HosplistName
  7368. fsiOrderDtosData["hosplist_dosform"] = fod.HosplistDosform
  7369. fsiOrderDtosData["cnt"] = fod.Cnt
  7370. fsiOrderDtosData["pric"] = fod.Pric
  7371. fsiOrderDtosData["sumamt"] = fod.Sumamt
  7372. fsiOrderDtosData["ownpay_amt"] = fod.OwnpayAmt
  7373. fsiOrderDtosData["selfpay_amt"] = fod.SelfpayAmt
  7374. fsiOrderDtosData["spec"] = fod.Spec
  7375. fsiOrderDtosData["spec_unt"] = fod.SpecUnt
  7376. fsiOrderDtosData["drord_begn_date"] = fod.DrordBegnDate
  7377. fsiOrderDtosData["drord_stop_date"] = fod.DrordStopDate
  7378. fsiOrderDtosData["drord_dept_codg"] = fod.DrordDeptCodg
  7379. fsiOrderDtosData["drord_dept_name"] = fod.DrordDeptName
  7380. fsiOrderDtosData["drord_dr_codg"] = fod.DrordDrCodg
  7381. fsiOrderDtosData["drord_dr_name"] = fod.DrordDrName
  7382. fsiOrderDtosData["drord_dr_profttl"] = fod.DrordDrProfttl
  7383. fsiOrderDtosData["curr_drord_flag"] = fod.CurrDrordFlag
  7384. fsiOrderDtosDatas = append(fsiOrderDtosDatas, fsiOrderDtosData)
  7385. }
  7386. fisEncounterDtosData["fsi_order_dtos"] = fsiOrderDtosDatas
  7387. fisEncounterDtosData["matn_stas"] = fed.MatnStas
  7388. fisEncounterDtosData["medfee_sumamt"] = fed.MedfeeSumamt
  7389. fisEncounterDtosData["ownpay_amt"] = fed.OwnpayAmt
  7390. fisEncounterDtosData["selfpay_amt"] = fed.SelfpayAmt
  7391. fisEncounterDtosData["acct_payamt"] = fed.AcctPayamt
  7392. fisEncounterDtosData["ma_amt"] = fed.MaAmt
  7393. fisEncounterDtosData["hifp_payamt"] = fed.HifpPayamt
  7394. fisEncounterDtosData["setl_totlnum"] = fed.SetlTotlnum
  7395. fisEncounterDtosData["insutype"] = fed.Insutype
  7396. fisEncounterDtosData["reim_flag"] = fed.ReimFlag
  7397. fisEncounterDtosData["out_setl_flag"] = fed.OutSetlFlag
  7398. //手术操作
  7399. for _, fopd := range fopds {
  7400. fsiOperationDtosData["setl_list_oprn_id"] = fopd.Setl_list_oprn_id
  7401. fsiOperationDtosData["oprn_code"] = fopd.Oprn_code
  7402. fsiOperationDtosData["oprn_name"] = fopd.Oprn_name
  7403. fsiOperationDtosData["main_oprn_flag"] = fopd.Main_oprn_flag
  7404. fsiOperationDtosData["oprn_date"] = fopd.Oprn_date
  7405. fsiOperationDtosData["anst_way"] = fopd.Anst_way
  7406. fsiOperationDtosData["oper_dr_name"] = fopd.Oper_dr_name
  7407. fsiOperationDtosData["oper_dr_code"] = fopd.Oper_dr_code
  7408. fsiOperationDtosData["anst_dr_name"] = fopd.Anst_dr_name
  7409. fsiOperationDtosData["anst_dr_code"] = fopd.Anst_dr_code
  7410. fsiOperationDtosDatas = append(fsiOperationDtosDatas, fsiOperationDtosData)
  7411. }
  7412. fisEncounterDtosData["fsi_operation_dtos"] = fsiOperationDtosDatas
  7413. patientDtosinputData["patn_id"] = pd.PatnID
  7414. patientDtosinputData["patn_name"] = pd.PatnName
  7415. patientDtosinputData["gend"] = pd.Gend
  7416. patientDtosinputData["brdy"] = pd.Brdy
  7417. patientDtosinputData["poolarea"] = pd.Poolarea
  7418. patientDtosinputData["curr_mdtrt_id"] = pd.CurrMdtrtID
  7419. patientDtosinputData["fsi_his_data_dto"] = ""
  7420. patientDtosinputData["fsi_encounter_dtos"] = fisEncounterDtosData
  7421. inputData["syscode"] = "LinkDialysis"
  7422. inputData["trig_scen"] = trig_scen
  7423. inputData["rule_ids"] = ""
  7424. inputData["task_id"] = ""
  7425. inputData["patient_dtos"] = patientDtosinputData
  7426. input["data"] = inputData
  7427. inputMessage["infno"] = "3102"
  7428. inputMessage["input"] = input //交易输入
  7429. bytesData, err := json.Marshal(inputMessage)
  7430. fmt.Println(string(bytesData))
  7431. if err != nil {
  7432. fmt.Println(err.Error())
  7433. return err.Error(), ""
  7434. }
  7435. reader := bytes.NewReader(bytesData)
  7436. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7437. gdyb_url := beego.AppConfig.String("gdyb_url")
  7438. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7439. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7440. url := gdyb_url + "3102"
  7441. request, err := http.NewRequest("POST", url, reader)
  7442. if err != nil {
  7443. fmt.Println(err.Error())
  7444. return err.Error(), ""
  7445. }
  7446. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  7447. request.Header.Set("x-tif-paasid", gdyb_paasid)
  7448. request.Header.Set("x-tif-signature", signature)
  7449. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  7450. request.Header.Set("x-tif-nonce", nonce)
  7451. client := http.Client{}
  7452. resp, err := client.Do(request)
  7453. if err != nil {
  7454. fmt.Println(err.Error())
  7455. return err.Error(), ""
  7456. }
  7457. respBytes, err := ioutil.ReadAll(resp.Body)
  7458. if err != nil {
  7459. fmt.Println(err.Error())
  7460. return err.Error(), ""
  7461. }
  7462. str := string(respBytes)
  7463. fmt.Println(str)
  7464. return str, string(bytesData)
  7465. }
  7466. // 分页函数
  7467. func paginate(data []map[string]interface{}, pageSize int) [][]map[string]interface{} {
  7468. var pages [][]map[string]interface{}
  7469. totalItems := len(data)
  7470. for i := 0; i < totalItems; i += pageSize {
  7471. end := i + pageSize
  7472. if end > totalItems {
  7473. end = totalItems
  7474. }
  7475. pages = append(pages, data[i:end])
  7476. }
  7477. return pages
  7478. }
  7479. func Gzyb3501(struct3501 models.Struct3501, secret_key string) (string, string) {
  7480. // 生成签名
  7481. nonce := GetRandomString(32)
  7482. timestamp := time.Now().Unix()
  7483. signature := setSignature(timestamp, nonce, secret_key)
  7484. // 生成输入报文
  7485. //inputMessage := SetInputMessage(timestamp, struct3501.OrgName, struct3501.Opter, struct3501.FixmedinsHilistId, struct3501.InsuplcAdmdvs, struct3501.MdtrtareaAdmvs, struct3501.Cainfo,"")
  7486. sign := GetSignInInfo(struct3501.FixmedinsCode)
  7487. inputMessage := SetGZInputMessage(nonce, timestamp, struct3501.OrgName, struct3501.Opter, struct3501.FixmedinsCode, struct3501.InsuplcAdmdvs, struct3501.MdtrtareaAdmvs, sign)
  7488. input := make(map[string]interface{})
  7489. inputData := make(map[string]interface{})
  7490. inputMessage["infno"] = "3501" // 交易编码
  7491. inputData["med_list_codg"] = struct3501.MedListCodg // 定点医药机构目录编号
  7492. inputData["fixmedins_hilist_id"] = struct3501.FixmedinsHilistId // 定点医药机构目录编号
  7493. inputData["fixmedins_hilist_name"] = struct3501.OrgName // 定点医药机构目录名称
  7494. inputData["rx_flag"] = struct3501.RxFlag //
  7495. inputData["invdate"] = struct3501.Invdate // 人员编号 (来自1101接口返回)
  7496. inputData["inv_cnt"] = struct3501.InvCnt // 人员编号 (来自1101接口返回)
  7497. inputData["manu_lotnum"] = struct3501.ManuLotnum // 人员编号 (来自1101接口返回)
  7498. inputData["fixmedins_bchno"] = struct3501.FixmedinsBchno // 人员编号 (来自1101接口返回)
  7499. inputData["manu_date"] = struct3501.ManuDate // 人员编号 (来自1101接口返回)
  7500. inputData["expy_end"] = struct3501.ExpyEnd // 人员编号 (来自1101接口返回)
  7501. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  7502. input["invinfo"] = inputData
  7503. inputMessage["input"] = input //交易输入
  7504. bytesData, err := json.Marshal(inputMessage)
  7505. fmt.Println(string(bytesData))
  7506. if err != nil {
  7507. fmt.Println(err.Error())
  7508. return err.Error(), ""
  7509. }
  7510. reader := bytes.NewReader(bytesData)
  7511. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7512. gdyb_url := beego.AppConfig.String("gdyb_url")
  7513. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7514. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7515. url := gdyb_url + "3501"
  7516. request, err := http.NewRequest("POST", url, reader)
  7517. if err != nil {
  7518. fmt.Println(err.Error())
  7519. return err.Error(), ""
  7520. }
  7521. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  7522. request.Header.Set("x-tif-paasid", gdyb_paasid)
  7523. request.Header.Set("x-tif-signature", signature)
  7524. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  7525. request.Header.Set("x-tif-nonce", nonce)
  7526. client := http.Client{}
  7527. resp, err := client.Do(request)
  7528. if err != nil {
  7529. fmt.Println(err.Error())
  7530. return err.Error(), ""
  7531. }
  7532. respBytes, err := ioutil.ReadAll(resp.Body)
  7533. if err != nil {
  7534. fmt.Println(err.Error())
  7535. return err.Error(), ""
  7536. }
  7537. str := string(respBytes)
  7538. fmt.Println(str)
  7539. return str, string(bytesData)
  7540. }
  7541. func Gzyb3502(struct3502 models.Struct3502, secret_key string) (string, string) {
  7542. // 生成签名
  7543. nonce := GetRandomString(32)
  7544. timestamp := time.Now().Unix()
  7545. signature := setSignature(timestamp, nonce, secret_key)
  7546. sign := GetSignInInfo(struct3502.FixmedinsCode)
  7547. inputMessage := SetGZInputMessage(nonce, timestamp, struct3502.OrgName, struct3502.Opter, struct3502.FixmedinsCode, struct3502.InsuplcAdmdvs, struct3502.MdtrtareaAdmvs, sign)
  7548. // 生成输入报文
  7549. //inputMessage := SetGdInputMessage(timestamp, struct3502.OrgName, struct3502.Opter, struct3502.FixmedinsCode, struct3502.InsuplcAdmdvs, struct3502.MdtrtareaAdmvs, struct3502.Cainfo,sign)
  7550. input := make(map[string]interface{})
  7551. inputData := make(map[string]interface{})
  7552. inputMessage["infno"] = "3502" // 交易编码
  7553. inputData["med_list_codg"] = struct3502.MedListCodg // 定点医药机构目录编号
  7554. inputData["inv_chg_type"] = struct3502.InvChgType // 定点医药机构目录编号
  7555. inputData["fixmedins_hilist_id"] = struct3502.FixmedinsHilistId // 定点医药机构目录编号
  7556. inputData["fixmedins_hilist_name"] = struct3502.FixmedinsHilistName // 定点医药机构目录名称
  7557. inputData["fixmedins_bchno"] = struct3502.FixmedinsBchno // 人员编号 (来自1101接口返回)
  7558. inputData["pric"] = struct3502.Pric // 人员编号 (来自1101接口返回)
  7559. inputData["cnt"] = struct3502.Cnt // 人员编号 (来自1101接口返回)
  7560. inputData["rx_flag"] = struct3502.RxFlag //
  7561. inputData["inv_chg_time"] = struct3502.InvChgTime // 人员编号 (来自1101接口返回)
  7562. inputData["inv_chg_opter_name"] = "" // 人员编号 (来自1101接口返回)
  7563. inputData["memo"] = struct3502.Memo // 人员编号 (来自1101接口返回)
  7564. inputData["trdn_flag"] = "" // 人员编号 (来自1101接口返回)
  7565. feedetail := make([]map[string]interface{}, 0)
  7566. codes := strings.Split(struct3502.DrugTracCodg, ",")
  7567. for _, item := range codes {
  7568. druginputData := make(map[string]interface{})
  7569. druginputData["drug_trac_codg"] = item
  7570. feedetail = append(feedetail, druginputData)
  7571. }
  7572. inputData["drugtracinfo"] = feedetail
  7573. input["invinfo"] = inputData
  7574. inputMessage["input"] = input //交易输入
  7575. bytesData, err := json.Marshal(inputMessage)
  7576. fmt.Println(string(bytesData))
  7577. if err != nil {
  7578. fmt.Println(err.Error())
  7579. return err.Error(), ""
  7580. }
  7581. reader := bytes.NewReader(bytesData)
  7582. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7583. //gdyb_url := beego.AppConfig.String("gdyb_url")
  7584. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7585. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7586. url := "http://hosp-gz.gd.hsip.gov.cn/ebus/gdyb_api/prd/hsa/hgs/" + "3502"
  7587. request, err := http.NewRequest("POST", url, reader)
  7588. if err != nil {
  7589. fmt.Println(err.Error())
  7590. return err.Error(), ""
  7591. }
  7592. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  7593. request.Header.Set("x-tif-paasid", gdyb_paasid)
  7594. request.Header.Set("x-tif-signature", signature)
  7595. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  7596. request.Header.Set("x-tif-nonce", nonce)
  7597. client := http.Client{}
  7598. resp, err := client.Do(request)
  7599. if err != nil {
  7600. fmt.Println(err.Error())
  7601. return err.Error(), ""
  7602. }
  7603. respBytes, err := ioutil.ReadAll(resp.Body)
  7604. if err != nil {
  7605. fmt.Println(err.Error())
  7606. return err.Error(), ""
  7607. }
  7608. str := string(respBytes)
  7609. fmt.Println(str)
  7610. return str, string(bytesData)
  7611. }
  7612. func Gzyb3503(struct3503 models.Struct3503, secret_key string) (string, string) {
  7613. // 生成签名
  7614. nonce := GetRandomString(32)
  7615. timestamp := time.Now().Unix()
  7616. signature := setSignature(timestamp, nonce, secret_key)
  7617. // 生成输入报文
  7618. sign := GetSignInInfo(struct3503.FixmedinsCode)
  7619. inputMessage := SetGZInputMessage(nonce, timestamp, struct3503.OrgName, struct3503.Opter, struct3503.FixmedinsCode, struct3503.InsuplcAdmdvs, struct3503.MdtrtareaAdmvs, sign)
  7620. input := make(map[string]interface{})
  7621. inputMessage["infno"] = "3503"
  7622. item := struct3503
  7623. feedetailInfo := make(map[string]interface{})
  7624. feedetailInfo["med_list_codg"] = item.MedListCodg
  7625. feedetailInfo["fixmedins_hilist_id"] = item.FixmedinsHilistId
  7626. feedetailInfo["fixmedins_hilist_name"] = item.FixmedinsHilistName
  7627. feedetailInfo["dynt_no"] = ""
  7628. feedetailInfo["fixmedins_bchno"] = item.FixmedinsBchno // 人员编号 (来自1101接口返回)
  7629. feedetailInfo["spler_name"] = item.SplerName // 人员编号 (来自1101接口返回)
  7630. feedetailInfo["spler_pmtno"] = "" // 人员编号 (来自1101接口返回)
  7631. feedetailInfo["manu_lotnum"] = item.ManuLotnum // 人员编号 (来自1101接口返回)
  7632. feedetailInfo["prodentp_name"] = item.ProdentpName // 人员编号 (来自1101接口返回)
  7633. feedetailInfo["aprvno"] = item.Aprvno // 人员编号 (来自1101接口返回)
  7634. feedetailInfo["manu_date"] = item.ManuDate // 人员编号 (来自1101接口返回)
  7635. feedetailInfo["expy_end"] = item.ExpyEnd // 人员编号 (来自1101接口返回)
  7636. feedetailInfo["finl_trns_pric"] = item.FinlTrnsPric // 人员编号 (来自1101接口返回)
  7637. feedetailInfo["purc_retn_cnt"] = item.PurcRetnCnt // 人员编号 (来自1101接口返回)
  7638. feedetailInfo["purc_invo_codg"] = item.PurcInvoCodg // 人员编号 (来自1101接口返回)
  7639. feedetailInfo["purc_invo_no"] = item.PurcInvoNo // 人员编号 (来自1101接口返回)
  7640. feedetailInfo["rx_flag"] = item.RxFlag // 人员编号 (来自1101接口返回)
  7641. feedetailInfo["purc_retn_stoin_time"] = item.PurcRetnStoinTime // 人员编号 (来自1101接口返回)
  7642. feedetailInfo["purc_retn_opter_name"] = item.PurcRetnOpterName // 人员编号 (来自1101接口返回)
  7643. feedetailInfo["prod_geay_flag"] = "" // 人员编号 (来自1101接口返回)
  7644. feedetailInfo["memo"] = "" // 人员编号 (来自1101接口返回)
  7645. input["purcinfo"] = feedetailInfo
  7646. inputMessage["input"] = input //交易输入
  7647. bytesData, err := json.Marshal(inputMessage)
  7648. fmt.Println(string(bytesData))
  7649. if err != nil {
  7650. fmt.Println(err.Error())
  7651. return err.Error(), ""
  7652. }
  7653. reader := bytes.NewReader(bytesData)
  7654. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7655. gdyb_url := beego.AppConfig.String("gdyb_url")
  7656. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7657. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7658. url := gdyb_url + "3503"
  7659. request, err := http.NewRequest("POST", url, reader)
  7660. if err != nil {
  7661. fmt.Println(err.Error())
  7662. return err.Error(), ""
  7663. }
  7664. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  7665. request.Header.Set("x-tif-paasid", gdyb_paasid)
  7666. request.Header.Set("x-tif-signature", signature)
  7667. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  7668. request.Header.Set("x-tif-nonce", nonce)
  7669. client := http.Client{}
  7670. resp, err := client.Do(request)
  7671. if err != nil {
  7672. fmt.Println(err.Error())
  7673. return err.Error(), ""
  7674. }
  7675. respBytes, err := ioutil.ReadAll(resp.Body)
  7676. if err != nil {
  7677. fmt.Println(err.Error())
  7678. return err.Error(), ""
  7679. }
  7680. str := string(respBytes)
  7681. fmt.Println(str)
  7682. return str, string(bytesData)
  7683. }
  7684. func Gzyb3504(struct3504 models.Struct3504, secret_key string) (string, string) {
  7685. // 生成签名
  7686. nonce := GetRandomString(32)
  7687. timestamp := time.Now().Unix()
  7688. signature := setSignature(timestamp, nonce, secret_key)
  7689. // 生成输入报文
  7690. //inputMessage := SetGdInputMessage(timestamp, struct3504.OrgName, struct3504.Opter, struct3504.FixmedinsCode, struct3504.InsuplcAdmdvs, struct3504.MdtrtareaAdmvs, struct3504.Cainfo)
  7691. sign := GetSignInInfo(struct3504.FixmedinsCode)
  7692. inputMessage := SetGZInputMessage(nonce, timestamp, struct3504.OrgName, struct3504.Opter, struct3504.FixmedinsCode, struct3504.InsuplcAdmdvs, struct3504.MdtrtareaAdmvs, sign)
  7693. input := make(map[string]interface{})
  7694. inputData := make(map[string]interface{})
  7695. inputMessage["infno"] = "3504" // 交易编码
  7696. inputData["med_list_codg"] = struct3504.MedListCodg // 定点医药机构目录编号
  7697. inputData["fixmedins_hilist_id"] = struct3504.FixmedinsHilistId // 定点医药机构目录编号
  7698. inputData["fixmedins_hilist_name"] = struct3504.FixmedinsHilistName // 定点医药机构目录名称
  7699. inputData["fixmedins_bchno"] = struct3504.FixmedinsBchno // 人员编号 (来自1101接口返回)
  7700. inputData["spler_name"] = struct3504.SplerName // 人员编号 (来自1101接口返回)
  7701. inputData["spler_pmtno"] = "" // 人员编号 (来自1101接口返回)
  7702. inputData["manu_date"] = struct3504.ManuDate // 人员编号 (来自1101接口返回)
  7703. inputData["expy_end"] = struct3504.ExpyEnd // 人员编号 (来自1101接口返回)
  7704. inputData["finl_trns_pric"] = struct3504.FinlTrnsPric // 人员编号 (来自1101接口返回)
  7705. inputData["purc_retn_cnt"] = struct3504.PurcRetnCnt // 人员编号 (来自1101接口返回)
  7706. inputData["purc_invo_codg"] = struct3504.PurcInvoCodg // 人员编号 (来自1101接口返回)
  7707. inputData["purc_invo_no"] = struct3504.PurcInvoNo // 人员编号 (来自1101接口返回)
  7708. inputData["rx_flag"] = struct3504.RxFlag
  7709. inputData["purc_retn_stoin_time"] = struct3504.PurcRetnStoin
  7710. inputData["purc_retn_opter_name"] = struct3504.PurcRetnStoin
  7711. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  7712. inputData["medins_prod_purc_no"] = "" // 人员编号 (来自1101接口返回)
  7713. input["purcinfo"] = inputData
  7714. inputMessage["input"] = input //交易输入
  7715. bytesData, err := json.Marshal(inputMessage)
  7716. fmt.Println(string(bytesData))
  7717. if err != nil {
  7718. fmt.Println(err.Error())
  7719. return err.Error(), ""
  7720. }
  7721. reader := bytes.NewReader(bytesData)
  7722. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7723. gdyb_url := beego.AppConfig.String("gdyb_url")
  7724. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7725. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7726. url := gdyb_url + "3504"
  7727. request, err := http.NewRequest("POST", url, reader)
  7728. if err != nil {
  7729. fmt.Println(err.Error())
  7730. return err.Error(), ""
  7731. }
  7732. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  7733. request.Header.Set("x-tif-paasid", gdyb_paasid)
  7734. request.Header.Set("x-tif-signature", signature)
  7735. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  7736. request.Header.Set("x-tif-nonce", nonce)
  7737. client := http.Client{}
  7738. resp, err := client.Do(request)
  7739. if err != nil {
  7740. fmt.Println(err.Error())
  7741. return err.Error(), ""
  7742. }
  7743. respBytes, err := ioutil.ReadAll(resp.Body)
  7744. if err != nil {
  7745. fmt.Println(err.Error())
  7746. return err.Error(), ""
  7747. }
  7748. str := string(respBytes)
  7749. fmt.Println(str)
  7750. return str, string(bytesData)
  7751. }
  7752. func Gzyb3505(struct3505 models.Struct3505, secret_key string) (string, string) {
  7753. // 生成签名
  7754. nonce := GetRandomString(32)
  7755. timestamp := time.Now().Unix()
  7756. signature := setSignature(timestamp, nonce, secret_key)
  7757. // 生成输入报文
  7758. //inputMessage := SetGdInputMessage(timestamp, struct3505.OrgName, struct3505.Opter, struct3505.FixmedinsHilistId, struct3505.InsuplcAdmdvs, struct3505.MdtrtareaAdmvs, struct3505.Cainfo)
  7759. sign := GetSignInInfo(struct3505.FixmedinsCode)
  7760. inputMessage := SetGZInputMessage(nonce, timestamp, struct3505.OrgName, struct3505.Opter, struct3505.FixmedinsCode, struct3505.InsuplcAdmdvs, struct3505.MdtrtareaAdmvs, sign)
  7761. input := make(map[string]interface{})
  7762. inputData := make(map[string]interface{})
  7763. inputMessage["infno"] = "3505" // 交易编码
  7764. inputData["med_list_codg"] = struct3505.MedListCodg // 定点医药机构目录编号
  7765. inputData["fixmedins_hilist_id"] = struct3505.FixmedinsHilistId // 定点医药机构目录编号
  7766. inputData["fixmedins_hilist_name"] = struct3505.FixmedinsHilistName // 定点医药机构目录名称
  7767. inputData["fixmedins_bchno"] = struct3505.FixmedinsBchno // 人员编号 (来自1101接口返回)
  7768. inputData["prsc_dr_cert_type"] = struct3505.PrscDrCertType // 人员编号 (来自1101接口返回)
  7769. inputData["prsc_dr_certno"] = struct3505.PrscDrCertno // 人员编号 (来自1101接口返回)
  7770. inputData["prsc_dr_name"] = struct3505.PrscDrName // 人员编号 (来自1101接口返回)
  7771. inputData["phar_cert_type"] = struct3505.PharCertType // 人员编号 (来自1101接口返回)
  7772. inputData["phar_certno"] = struct3505.PharCertno // 人员编号 (来自1101接口返回)
  7773. inputData["phar_name"] = struct3505.PharName // 人员编号 (来自1101接口返回)
  7774. inputData["phar_prac_cert_no"] = struct3505.PharPracCertNo // 人员编号 (来自1101接口返回)
  7775. inputData["hi_feesetl_type"] = struct3505.HiFeesetlType // 人员编号 (来自1101接口返回)
  7776. inputData["setl_id"] = struct3505.SetlId // 人员编号 (来自1101接口返回)
  7777. inputData["mdtrt_sn"] = struct3505.MdtrtSn // 人员编号 (来自1101接口返回)
  7778. inputData["psn_no"] = struct3505.PsnNo // 人员编号 (来自1101接口返回)
  7779. inputData["psn_cert_type"] = struct3505.PsnCertType // 人员编号 (来自1101接口返回)
  7780. inputData["certno"] = struct3505.CertNo // 人员编号 (来自1101接口返回)
  7781. inputData["psn_name"] = struct3505.PsnName // 人员编号 (来自1101接口返回)
  7782. inputData["manu_lotnum"] = struct3505.ManuLotnum // 人员编号 (来自1101接口返回)
  7783. inputData["manu_date"] = struct3505.ManuDate // 人员编号 (来自1101接口返回)
  7784. inputData["expy_end"] = struct3505.ExpyEnd // 人员编号 (来自1101接口返回)
  7785. inputData["rx_flag"] = struct3505.RxFlag // 人员编号 (来自1101接口返回)
  7786. inputData["trdn_flag"] = struct3505.TrdnFlag // 人员编号 (来自1101接口返回)
  7787. inputData["finl_trns_pric"] = struct3505.FinlTrnsPric // 人员编号 (来自1101接口返回)
  7788. inputData["rxno"] = struct3505.Rxno // 人员编号 (来自1101接口返回)
  7789. inputData["rx_circ_flag"] = struct3505.RxCircFlag // 人员编号 (来自1101接口返回)
  7790. inputData["rtal_docno"] = struct3505.RtalDocno // 人员编号 (来自1101接口返回)
  7791. inputData["stoout_no"] = struct3505.StooutNo // 人员编号 (来自1101接口返回)
  7792. inputData["MDTRT_SETL_TYPE"] = struct3505.MdtrtSetlType // 人员编号 (来自1101接口返回)
  7793. inputData["bchno"] = struct3505.Bchno // 人员编号 (来自1101接口返回)
  7794. codes := strings.Split(struct3505.DrugTracCodg, ",")
  7795. inputData["drug_trac_codg"] = codes[0] // 人员编号 (来自1101接口返回)
  7796. inputData["drug_prod_barc"] = struct3505.DrugProdBarc // 人员编号 (来自1101接口返回)
  7797. inputData["shelf_posi"] = struct3505.ShelfPosi // 人员编号 (来自1101接口返回)
  7798. inputData["sel_retn_cnt"] = struct3505.SelRetnCnt // 人员编号 (来自1101接口返回)
  7799. inputData["sel_retn_time"] = struct3505.SelRetnTime // 人员编号 (来自1101接口返回)
  7800. inputData["sel_retn_opter_name"] = struct3505.SelRetnOpterName // 人员编号 (来自1101接口返回)
  7801. inputData["memo"] = struct3505.Memo // 人员编号 (来自1101接口返回)
  7802. //drug_trac_cod .g
  7803. feedetail := make([]map[string]interface{}, 0)
  7804. //codes = strings.Split(struct3505.DrugTracCodg, ",")
  7805. for _, item := range codes {
  7806. if len(item) > 0{
  7807. druginputData := make(map[string]interface{})
  7808. druginputData["drug_trac_codg"] = item
  7809. feedetail = append(feedetail, druginputData)
  7810. }
  7811. }
  7812. inputData["drugtracinfo"] = feedetail
  7813. input["selinfo"] = inputData
  7814. inputMessage["input"] = input //交易输入
  7815. input["selinfo"] = inputData
  7816. inputMessage["input"] = input //交易输入
  7817. bytesData, err := json.Marshal(inputMessage)
  7818. fmt.Println(string(bytesData))
  7819. if err != nil {
  7820. fmt.Println(err.Error())
  7821. return err.Error(), ""
  7822. }
  7823. reader := bytes.NewReader(bytesData)
  7824. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7825. //gdyb_url := ""
  7826. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7827. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7828. //url := "" + "3505"
  7829. url := "http://hosp-gz.gd.hsip.gov.cn/ebus/gdyb_api/prd/hsa/hgs/" + "3505"
  7830. fmt.Println(gdyb_paasid)
  7831. fmt.Println(url)
  7832. request, err := http.NewRequest("POST", url, reader)
  7833. if err != nil {
  7834. fmt.Println(err.Error())
  7835. return err.Error(), ""
  7836. }
  7837. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  7838. request.Header.Set("x-tif-paasid", gdyb_paasid)
  7839. request.Header.Set("x-tif-signature", signature)
  7840. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  7841. request.Header.Set("x-tif-nonce", nonce)
  7842. client := http.Client{}
  7843. resp, err := client.Do(request)
  7844. if err != nil {
  7845. fmt.Println(err.Error())
  7846. return err.Error(), ""
  7847. }
  7848. respBytes, err := ioutil.ReadAll(resp.Body)
  7849. if err != nil {
  7850. fmt.Println(err.Error())
  7851. return err.Error(), ""
  7852. }
  7853. str := string(respBytes)
  7854. fmt.Println(str)
  7855. return str, string(bytesData)
  7856. }
  7857. func Gzyb3506(struct3506 models.Struct3506, secret_key string) (string, string) {
  7858. // 生成签名
  7859. nonce := GetRandomString(32)
  7860. timestamp := time.Now().Unix()
  7861. signature := setSignature(timestamp, nonce, secret_key)
  7862. // 生成输入报文
  7863. //inputMessage := SetGdInputMessage(timestamp, struct3506.OrgName, struct3506.Opter, struct3506.FixmedinsCode, struct3506.InsuplcAdmdvs, struct3506.MdtrtareaAdmvs, struct3506.Cainfo)
  7864. sign := GetSignInInfo(struct3506.FixmedinsCode)
  7865. inputMessage := SetGZInputMessage(nonce, timestamp, struct3506.OrgName, struct3506.Opter, struct3506.FixmedinsCode, struct3506.InsuplcAdmdvs, struct3506.MdtrtareaAdmvs, sign)
  7866. input := make(map[string]interface{})
  7867. inputData := make(map[string]interface{})
  7868. inputMessage["infno"] = "3506" // 交易编码
  7869. inputData["med_list_codg"] = struct3506.MedListCodg // 定点医药机构目录编号
  7870. inputData["fixmedins_hilist_id"] = struct3506.FixmedinsHilistId // 定点医药机构目录编号
  7871. inputData["fixmedins_hilist_name"] = struct3506.OrgName // 定点医药机构目录名称
  7872. inputData["fixmedins_bchno"] = struct3506.FixmedinsBchno // 人员编号 (来自1101接口返回)
  7873. inputData["setl_id"] = struct3506.SetlId // 人员编号 (来自1101接口返回)
  7874. inputData["psn_no"] = struct3506.PsnNo // 人员编号 (来自1101接口返回)
  7875. inputData["psn_cert_type"] = struct3506.PsnCertType // 人员编号 (来自1101接口返回)
  7876. inputData["certno"] = struct3506.Certno // 人员编号 (来自1101接口返回)
  7877. inputData["psn_name"] = struct3506.PsnName // 人员编号 (来自1101接口返回)
  7878. inputData["manu_lotnum"] = struct3506.ManuLotnum // 人员编号 (来自1101接口返回)
  7879. inputData["manu_date"] = struct3506.ManuDate // 人员编号 (来自1101接口返回)
  7880. inputData["expy_end"] = struct3506.ExpyEnd // 人员编号 (来自1101接口返回)
  7881. inputData["rx_flag"] = struct3506.RxFlag // 人员编号 (来自1101接口返回)
  7882. inputData["trdn_flag"] = struct3506.TrdnFlag // 人员编号 (来自1101接口返回)
  7883. inputData["finl_trns_pric"] = struct3506.FinlTrnsPric // 人员编号 (来自1101接口返回)
  7884. inputData["sel_retn_cnt"] = struct3506.SelRetnCnt // 人员编号 (来自1101接口返回)
  7885. inputData["sel_retn_time"] = struct3506.SelRetnTime // 人员编号 (来自1101接口返回)
  7886. inputData["sel_retn_opter_name"] = struct3506.SelRetnOpterName // 人员编号 (来自1101接口返回)
  7887. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  7888. inputData["medins_prod_sel_no"] = "" // 人员编号 (来自1101接口返回)
  7889. input["selinfo"] = inputData
  7890. inputMessage["input"] = input //交易输入
  7891. bytesData, err := json.Marshal(inputMessage)
  7892. fmt.Println(string(bytesData))
  7893. if err != nil {
  7894. fmt.Println(err.Error())
  7895. return err.Error(), ""
  7896. }
  7897. reader := bytes.NewReader(bytesData)
  7898. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7899. gdyb_url := beego.AppConfig.String("gdyb_url")
  7900. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7901. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7902. url := gdyb_url + "3506"
  7903. request, err := http.NewRequest("POST", url, reader)
  7904. if err != nil {
  7905. fmt.Println(err.Error())
  7906. return err.Error(), ""
  7907. }
  7908. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  7909. request.Header.Set("x-tif-paasid", gdyb_paasid)
  7910. request.Header.Set("x-tif-signature", signature)
  7911. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  7912. request.Header.Set("x-tif-nonce", nonce)
  7913. client := http.Client{}
  7914. resp, err := client.Do(request)
  7915. if err != nil {
  7916. fmt.Println(err.Error())
  7917. return err.Error(), ""
  7918. }
  7919. respBytes, err := ioutil.ReadAll(resp.Body)
  7920. if err != nil {
  7921. fmt.Println(err.Error())
  7922. return err.Error(), ""
  7923. }
  7924. str := string(respBytes)
  7925. fmt.Println(str)
  7926. return str, string(bytesData)
  7927. }
  7928. func Gzyb3507(struct3507 models.Struct3507, secret_key string) (string, string) {
  7929. // 生成签名
  7930. nonce := GetRandomString(32)
  7931. timestamp := time.Now().Unix()
  7932. signature := setSignature(timestamp, nonce, secret_key)
  7933. // 生成输入报文
  7934. //inputMessage := SetGdInputMessage(timestamp, struct3507.OrgName, struct3507.Opter, struct3507.FixmedinsCode, struct3507.InsuplcAdmdvs, struct3507.MdtrtareaAdmvs, struct3507.Cainfo)
  7935. sign := GetSignInInfo(struct3507.FixmedinsCode)
  7936. inputMessage := SetGZInputMessage(nonce, timestamp, struct3507.OrgName, struct3507.Opter, struct3507.FixmedinsCode, struct3507.InsuplcAdmdvs, struct3507.MdtrtareaAdmvs, sign)
  7937. input := make(map[string]interface{})
  7938. inputData := make(map[string]interface{})
  7939. inputMessage["infno"] = "3507" // 交易编码
  7940. inputData["fixmedins_bchno"] = struct3507.FixmedinsCode // 人员编号 (来自1101接口返回)
  7941. inputData["inv_data_type"] = struct3507.InvDataType // 人员编号 (来自1101接口返回)
  7942. input["data"] = inputData
  7943. inputMessage["input"] = input //交易输入
  7944. bytesData, err := json.Marshal(inputMessage)
  7945. fmt.Println(string(bytesData))
  7946. if err != nil {
  7947. fmt.Println(err.Error())
  7948. return err.Error(), ""
  7949. }
  7950. reader := bytes.NewReader(bytesData)
  7951. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  7952. gdyb_url := beego.AppConfig.String("gdyb_url")
  7953. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  7954. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  7955. url := gdyb_url + "3507"
  7956. request, err := http.NewRequest("POST", url, reader)
  7957. if err != nil {
  7958. fmt.Println(err.Error())
  7959. return err.Error(), ""
  7960. }
  7961. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  7962. request.Header.Set("x-tif-paasid", gdyb_paasid)
  7963. request.Header.Set("x-tif-signature", signature)
  7964. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  7965. request.Header.Set("x-tif-nonce", nonce)
  7966. client := http.Client{}
  7967. resp, err := client.Do(request)
  7968. if err != nil {
  7969. fmt.Println(err.Error())
  7970. return err.Error(), ""
  7971. }
  7972. respBytes, err := ioutil.ReadAll(resp.Body)
  7973. if err != nil {
  7974. fmt.Println(err.Error())
  7975. return err.Error(), ""
  7976. }
  7977. str := string(respBytes)
  7978. fmt.Println(str)
  7979. return str, string(bytesData)
  7980. }
  7981. func Gzyb3508(struct3508 models.Struct3508, secret_key string) (string, string) {
  7982. // 生成签名
  7983. nonce := GetRandomString(32)
  7984. timestamp := time.Now().Unix()
  7985. signature := setSignature(timestamp, nonce, secret_key)
  7986. // 生成输入报文
  7987. //inputMessage := SetGdInputMessage(timestamp, struct3508.OrgName, struct3508.Opter, struct3508.FixmedinsCode, struct3508.InsuplcAdmdvs, struct3508.MdtrtareaAdmvs, struct3508.Cainfo)
  7988. sign := GetSignInInfo(struct3508.FixmedinsCode)
  7989. inputMessage := SetGZInputMessage(nonce, timestamp, struct3508.OrgName, struct3508.Opter, struct3508.FixmedinsCode, struct3508.InsuplcAdmdvs, struct3508.MdtrtareaAdmvs, sign)
  7990. input := make(map[string]interface{})
  7991. inputData := make(map[string]interface{})
  7992. inputMessage["infno"] = "3508"
  7993. inputData["fixmedins_code"] = struct3508.FixmedinsCode
  7994. inputData["medins_list_codg"] = struct3508.MedListCodg
  7995. inputData["fixmedins_bchno"] = ""
  7996. inputData["begndate"] = struct3508.Begndate
  7997. inputData["enddate"] = struct3508.Enddate
  7998. inputData["medins_prod_inv_no"] = ""
  7999. inputData["medins_list_name"] = ""
  8000. inputData["rx_flag"] = ""
  8001. inputData["list_sp_item_flag"] = ""
  8002. inputData["trdn_flag"] = ""
  8003. inputData["invdate"] = ""
  8004. inputData["manu_lotnum"] = ""
  8005. inputData["manu_date"] = ""
  8006. inputData["expy_end"] = ""
  8007. inputData["memo"] = ""
  8008. inputData["vali_flag"] = ""
  8009. inputData["rid"] = ""
  8010. inputData["crter_id"] = ""
  8011. inputData["crter_name"] = ""
  8012. inputData["crte_optins_no"] = ""
  8013. inputData["opter_id"] = ""
  8014. inputData["opter_name"] = ""
  8015. inputData["optins_no"] = ""
  8016. inputData["poolarea_no"] = ""
  8017. inputData["fixmedins_bchno"] = ""
  8018. inputData["inv_data_type"] = ""
  8019. input["data"] = inputData
  8020. inputMessage["input"] = input //交易输入
  8021. bytesData, err := json.Marshal(inputMessage)
  8022. fmt.Println(string(bytesData))
  8023. if err != nil {
  8024. fmt.Println(err.Error())
  8025. return err.Error(), ""
  8026. }
  8027. reader := bytes.NewReader(bytesData)
  8028. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  8029. gdyb_url := beego.AppConfig.String("gdyb_url")
  8030. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  8031. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  8032. url := gdyb_url + "3508"
  8033. request, err := http.NewRequest("POST", url, reader)
  8034. if err != nil {
  8035. fmt.Println(err.Error())
  8036. return err.Error(), ""
  8037. }
  8038. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  8039. request.Header.Set("x-tif-paasid", gdyb_paasid)
  8040. request.Header.Set("x-tif-signature", signature)
  8041. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  8042. request.Header.Set("x-tif-nonce", nonce)
  8043. client := http.Client{}
  8044. resp, err := client.Do(request)
  8045. if err != nil {
  8046. fmt.Println(err.Error())
  8047. return err.Error(), ""
  8048. }
  8049. respBytes, err := ioutil.ReadAll(resp.Body)
  8050. if err != nil {
  8051. fmt.Println(err.Error())
  8052. return err.Error(), ""
  8053. }
  8054. str := string(respBytes)
  8055. fmt.Println(str)
  8056. return str, string(bytesData)
  8057. }
  8058. func Gzyb3509(struct3509 models.Struct3509, secret_key string) (string, string) {
  8059. // 生成签名
  8060. nonce := GetRandomString(32)
  8061. timestamp := time.Now().Unix()
  8062. signature := setSignature(timestamp, nonce, secret_key)
  8063. // 生成输入报文
  8064. //inputMessage := SetGdInputMessage(timestamp, struct3509.OrgName, struct3509.Opter, struct3509.FixmedinsCode, struct3509.InsuplcAdmdvs, struct3509.MdtrtareaAdmvs, struct3509.Cainfo)
  8065. sign := GetSignInInfo(struct3509.FixmedinsCode)
  8066. inputMessage := SetGZInputMessage(nonce, timestamp, struct3509.OrgName, struct3509.Opter, struct3509.FixmedinsCode, struct3509.InsuplcAdmdvs, struct3509.MdtrtareaAdmvs, sign)
  8067. input := make(map[string]interface{})
  8068. inputData := make(map[string]interface{})
  8069. inputMessage["infno"] = "3509"
  8070. inputData["fixmedins_code"] = struct3509.FixmedinsCode
  8071. //inputData["med_list_codg"] = struct3509.MedinsListCodg
  8072. inputData["medins_list_codg"] = struct3509.MedListCodg
  8073. inputData["fixmedins_bchno"] = ""
  8074. inputData["begndate"] = struct3509.Begndate
  8075. inputData["enddate"] = struct3509.Enddate
  8076. inputData["medins_prod_inv_no"] = ""
  8077. inputData["medins_list_name"] = ""
  8078. inputData["rx_flag"] = ""
  8079. inputData["list_sp_item_flag"] = ""
  8080. inputData["trdn_flag"] = ""
  8081. inputData["invdate"] = ""
  8082. inputData["manu_lotnum"] = ""
  8083. inputData["manu_date"] = ""
  8084. inputData["expy_end"] = ""
  8085. inputData["memo"] = ""
  8086. inputData["vali_flag"] = ""
  8087. inputData["rid"] = ""
  8088. inputData["crter_id"] = ""
  8089. inputData["crter_name"] = ""
  8090. inputData["crte_optins_no"] = ""
  8091. inputData["opter_id"] = ""
  8092. inputData["opter_name"] = ""
  8093. inputData["optins_no"] = ""
  8094. inputData["poolarea_no"] = ""
  8095. inputData["fixmedins_bchno"] = ""
  8096. inputData["inv_data_type"] = ""
  8097. input["data"] = inputData
  8098. inputMessage["input"] = input //交易输入
  8099. bytesData, err := json.Marshal(inputMessage)
  8100. fmt.Println(string(bytesData))
  8101. if err != nil {
  8102. fmt.Println(err.Error())
  8103. return err.Error(), ""
  8104. }
  8105. reader := bytes.NewReader(bytesData)
  8106. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  8107. gdyb_url := beego.AppConfig.String("gdyb_url")
  8108. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  8109. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  8110. url := gdyb_url + "3509"
  8111. request, err := http.NewRequest("POST", url, reader)
  8112. if err != nil {
  8113. fmt.Println(err.Error())
  8114. return err.Error(), ""
  8115. }
  8116. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  8117. request.Header.Set("x-tif-paasid", gdyb_paasid)
  8118. request.Header.Set("x-tif-signature", signature)
  8119. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  8120. request.Header.Set("x-tif-nonce", nonce)
  8121. client := http.Client{}
  8122. resp, err := client.Do(request)
  8123. if err != nil {
  8124. fmt.Println(err.Error())
  8125. return err.Error(), ""
  8126. }
  8127. respBytes, err := ioutil.ReadAll(resp.Body)
  8128. if err != nil {
  8129. fmt.Println(err.Error())
  8130. return err.Error(), ""
  8131. }
  8132. str := string(respBytes)
  8133. fmt.Println(str)
  8134. return str, string(bytesData)
  8135. }
  8136. func Gzyb3510(struct3510 models.Struct3510, secret_key string) (string, string) {
  8137. // 生成签名
  8138. nonce := GetRandomString(32)
  8139. timestamp := time.Now().Unix()
  8140. signature := setSignature(timestamp, nonce, secret_key)
  8141. // 生成输入报文
  8142. //inputMessage := SetGdInputMessage(timestamp, struct3510.OrgName, struct3510.Opter, struct3510.FixmedinsCode, struct3510.InsuplcAdmdvs, struct3510.MdtrtareaAdmvs, struct3510.Cainfo)
  8143. sign := GetSignInInfo(struct3510.FixmedinsCode)
  8144. inputMessage := SetGZInputMessage(nonce, timestamp, struct3510.OrgName, struct3510.Opter, struct3510.FixmedinsCode, struct3510.InsuplcAdmdvs, struct3510.MdtrtareaAdmvs, sign)
  8145. input := make(map[string]interface{})
  8146. inputData := make(map[string]interface{})
  8147. inputMessage["infno"] = "3510"
  8148. inputData["fixmedins_code"] = struct3510.FixmedinsCode
  8149. //inputData["medins_list_codg"] = struct3510.MedinsListCodg
  8150. inputData["medins_list_codg"] = struct3510.MedListCodg
  8151. inputData["fixmedins_bchno"] = ""
  8152. inputData["begndate"] = struct3510.Begndate
  8153. inputData["enddate"] = struct3510.Enddate
  8154. inputData["medins_prod_inv_no"] = ""
  8155. inputData["medins_list_name"] = ""
  8156. inputData["rx_flag"] = ""
  8157. inputData["list_sp_item_flag"] = ""
  8158. inputData["trdn_flag"] = ""
  8159. inputData["invdate"] = ""
  8160. inputData["manu_lotnum"] = ""
  8161. inputData["manu_date"] = ""
  8162. inputData["expy_end"] = ""
  8163. inputData["memo"] = ""
  8164. inputData["vali_flag"] = ""
  8165. inputData["rid"] = ""
  8166. inputData["crter_id"] = ""
  8167. inputData["crter_name"] = ""
  8168. inputData["crte_optins_no"] = ""
  8169. inputData["opter_id"] = ""
  8170. inputData["opter_name"] = ""
  8171. inputData["optins_no"] = ""
  8172. inputData["poolarea_no"] = ""
  8173. inputData["fixmedins_bchno"] = ""
  8174. inputData["inv_data_type"] = ""
  8175. input["data"] = inputData
  8176. inputMessage["input"] = input //交易输入
  8177. bytesData, err := json.Marshal(inputMessage)
  8178. fmt.Println(string(bytesData))
  8179. if err != nil {
  8180. fmt.Println(err.Error())
  8181. return err.Error(), ""
  8182. }
  8183. reader := bytes.NewReader(bytesData)
  8184. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  8185. gdyb_url := beego.AppConfig.String("gdyb_url")
  8186. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  8187. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  8188. url := gdyb_url + "3510"
  8189. request, err := http.NewRequest("POST", url, reader)
  8190. if err != nil {
  8191. fmt.Println(err.Error())
  8192. return err.Error(), ""
  8193. }
  8194. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  8195. request.Header.Set("x-tif-paasid", gdyb_paasid)
  8196. request.Header.Set("x-tif-signature", signature)
  8197. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  8198. request.Header.Set("x-tif-nonce", nonce)
  8199. client := http.Client{}
  8200. resp, err := client.Do(request)
  8201. if err != nil {
  8202. fmt.Println(err.Error())
  8203. return err.Error(), ""
  8204. }
  8205. respBytes, err := ioutil.ReadAll(resp.Body)
  8206. if err != nil {
  8207. fmt.Println(err.Error())
  8208. return err.Error(), ""
  8209. }
  8210. str := string(respBytes)
  8211. fmt.Println(str)
  8212. return str, string(bytesData)
  8213. }
  8214. func Gzyb3511(struct3511 models.Struct3511, secret_key string) (string, string) {
  8215. // 生成签名
  8216. nonce := GetRandomString(32)
  8217. timestamp := time.Now().Unix()
  8218. signature := setSignature(timestamp, nonce, secret_key)
  8219. // 生成输入报文
  8220. //inputMessage := SetGdInputMessage(timestamp, struct3511.OrgName, struct3511.Opter, struct3511.FixmedinsCode, struct3511.InsuplcAdmdvs, struct3511.MdtrtareaAdmvs, struct3511.Cainfo)
  8221. sign := GetSignInInfo(struct3511.FixmedinsCode)
  8222. inputMessage := SetGZInputMessage(nonce, timestamp, struct3511.OrgName, struct3511.Opter, struct3511.FixmedinsCode, struct3511.InsuplcAdmdvs, struct3511.MdtrtareaAdmvs, sign)
  8223. input := make(map[string]interface{})
  8224. inputData := make(map[string]interface{})
  8225. inputMessage["infno"] = "3511"
  8226. inputData["fixmedins_code"] = struct3511.FixmedinsCode
  8227. //inputData["medins_list_codg"] = struct3511.MedinsListCodg
  8228. inputData["medins_list_codg"] = struct3511.MedListCodg
  8229. inputData["fixmedins_bchno"] = ""
  8230. inputData["begndate"] = struct3511.Begndate
  8231. inputData["enddate"] = struct3511.Enddate
  8232. inputData["medins_prod_inv_no"] = ""
  8233. inputData["medins_list_name"] = ""
  8234. inputData["rx_flag"] = ""
  8235. inputData["list_sp_item_flag"] = ""
  8236. inputData["trdn_flag"] = ""
  8237. inputData["invdate"] = ""
  8238. inputData["manu_lotnum"] = ""
  8239. inputData["manu_date"] = ""
  8240. inputData["expy_end"] = ""
  8241. inputData["memo"] = ""
  8242. inputData["vali_flag"] = ""
  8243. inputData["rid"] = ""
  8244. inputData["crter_id"] = ""
  8245. inputData["crter_name"] = ""
  8246. inputData["crte_optins_no"] = ""
  8247. inputData["opter_id"] = ""
  8248. inputData["opter_name"] = ""
  8249. inputData["optins_no"] = ""
  8250. inputData["poolarea_no"] = ""
  8251. inputData["fixmedins_bchno"] = ""
  8252. inputData["inv_data_type"] = ""
  8253. input["data"] = inputData
  8254. inputMessage["input"] = input //交易输入
  8255. bytesData, err := json.Marshal(inputMessage)
  8256. fmt.Println(string(bytesData))
  8257. if err != nil {
  8258. fmt.Println(err.Error())
  8259. return err.Error(), ""
  8260. }
  8261. reader := bytes.NewReader(bytesData)
  8262. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  8263. gdyb_url := beego.AppConfig.String("gdyb_url")
  8264. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  8265. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  8266. url := gdyb_url + "3511"
  8267. request, err := http.NewRequest("POST", url, reader)
  8268. if err != nil {
  8269. fmt.Println(err.Error())
  8270. return err.Error(), ""
  8271. }
  8272. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  8273. request.Header.Set("x-tif-paasid", gdyb_paasid)
  8274. request.Header.Set("x-tif-signature", signature)
  8275. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  8276. request.Header.Set("x-tif-nonce", nonce)
  8277. client := http.Client{}
  8278. resp, err := client.Do(request)
  8279. if err != nil {
  8280. fmt.Println(err.Error())
  8281. return err.Error(), ""
  8282. }
  8283. respBytes, err := ioutil.ReadAll(resp.Body)
  8284. if err != nil {
  8285. fmt.Println(err.Error())
  8286. return err.Error(), ""
  8287. }
  8288. str := string(respBytes)
  8289. fmt.Println(str)
  8290. return str, string(bytesData)
  8291. }
  8292. func Gzyb3512(struct3512 models.Struct3512, secret_key string) (string, string) {
  8293. // 生成签名
  8294. nonce := GetRandomString(32)
  8295. timestamp := time.Now().Unix()
  8296. signature := setSignature(timestamp, nonce, secret_key)
  8297. // 生成输入报文
  8298. //inputMessage := SetGdInputMessage(timestamp, struct3512.OrgName, struct3512.Opter, struct3512.FixmedinsCode, struct3512.InsuplcAdmdvs, struct3512.MdtrtareaAdmvs, struct3512.Cainfo)
  8299. sign := GetSignInInfo(struct3512.FixmedinsCode)
  8300. inputMessage := SetGZInputMessage(nonce, timestamp, struct3512.OrgName, struct3512.Opter, struct3512.FixmedinsCode, struct3512.InsuplcAdmdvs, struct3512.MdtrtareaAdmvs, sign)
  8301. input := make(map[string]interface{})
  8302. inputData := make(map[string]interface{})
  8303. inputMessage["infno"] = "3512"
  8304. inputData["fixmedins_code"] = struct3512.FixmedinsCode
  8305. //inputData["medins_list_codg"] = struct3512.MedinsListCodg
  8306. inputData["medins_list_codg"] = struct3512.MedListCodg
  8307. inputData["fixmedins_bchno"] = ""
  8308. inputData["begndate"] = struct3512.Begndate
  8309. inputData["enddate"] = struct3512.Enddate
  8310. inputData["medins_prod_inv_no"] = ""
  8311. inputData["medins_list_name"] = ""
  8312. inputData["rx_flag"] = ""
  8313. inputData["list_sp_item_flag"] = ""
  8314. inputData["trdn_flag"] = ""
  8315. inputData["invdate"] = ""
  8316. inputData["manu_lotnum"] = ""
  8317. inputData["manu_date"] = ""
  8318. inputData["expy_end"] = ""
  8319. inputData["memo"] = ""
  8320. inputData["vali_flag"] = ""
  8321. inputData["rid"] = ""
  8322. inputData["crter_id"] = ""
  8323. inputData["crter_name"] = ""
  8324. inputData["crte_optins_no"] = ""
  8325. inputData["opter_id"] = ""
  8326. inputData["opter_name"] = ""
  8327. inputData["optins_no"] = ""
  8328. inputData["poolarea_no"] = ""
  8329. inputData["fixmedins_bchno"] = ""
  8330. inputData["inv_data_type"] = ""
  8331. input["data"] = inputData
  8332. inputMessage["input"] = input //交易输入
  8333. bytesData, err := json.Marshal(inputMessage)
  8334. fmt.Println(string(bytesData))
  8335. if err != nil {
  8336. fmt.Println(err.Error())
  8337. return err.Error(), ""
  8338. }
  8339. reader := bytes.NewReader(bytesData)
  8340. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  8341. gdyb_url := beego.AppConfig.String("gdyb_url")
  8342. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  8343. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  8344. url := gdyb_url + "3512"
  8345. request, err := http.NewRequest("POST", url, reader)
  8346. if err != nil {
  8347. fmt.Println(err.Error())
  8348. return err.Error(), ""
  8349. }
  8350. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  8351. request.Header.Set("x-tif-paasid", gdyb_paasid)
  8352. request.Header.Set("x-tif-signature", signature)
  8353. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  8354. request.Header.Set("x-tif-nonce", nonce)
  8355. client := http.Client{}
  8356. resp, err := client.Do(request)
  8357. if err != nil {
  8358. fmt.Println(err.Error())
  8359. return err.Error(), ""
  8360. }
  8361. respBytes, err := ioutil.ReadAll(resp.Body)
  8362. if err != nil {
  8363. fmt.Println(err.Error())
  8364. return err.Error(), ""
  8365. }
  8366. str := string(respBytes)
  8367. fmt.Println(str)
  8368. return str, string(bytesData)
  8369. }
  8370. func Gzyb3513(struct3513 models.Struct3513, secret_key string) (string, string) {
  8371. // 生成签名
  8372. nonce := GetRandomString(32)
  8373. timestamp := time.Now().Unix()
  8374. signature := setSignature(timestamp, nonce, secret_key)
  8375. // 生成输入报文
  8376. //inputMessage := SetGdInputMessage(timestamp, struct3513.OrgName, struct3513.Opter, struct3513.FixmedinsCode, struct3513.InsuplcAdmdvs, struct3513.MdtrtareaAdmvs, struct3513.Cainfo)
  8377. sign := GetSignInInfo(struct3513.FixmedinsCode)
  8378. inputMessage := SetGZInputMessage(nonce, timestamp, struct3513.OrgName, struct3513.Opter, struct3513.FixmedinsCode, struct3513.InsuplcAdmdvs, struct3513.MdtrtareaAdmvs, sign)
  8379. input := make(map[string]interface{})
  8380. inputData := make(map[string]interface{})
  8381. inputMessage["infno"] = "3513"
  8382. inputData["fixmedins_code"] = struct3513.FixmedinsCode
  8383. //inputData["medins_list_codg"] = struct3513.MedinsListCodg
  8384. inputData["medins_list_codg"] = struct3513.MedListCodg
  8385. inputData["fixmedins_bchno"] = ""
  8386. inputData["begndate"] = struct3513.Begndate
  8387. inputData["enddate"] = struct3513.Enddate
  8388. inputData["medins_prod_inv_no"] = ""
  8389. inputData["med_list_codg"] = ""
  8390. inputData["medins_list_name"] = ""
  8391. inputData["rx_flag"] = ""
  8392. inputData["list_sp_item_flag"] = ""
  8393. inputData["trdn_flag"] = ""
  8394. inputData["invdate"] = ""
  8395. inputData["manu_lotnum"] = ""
  8396. inputData["manu_date"] = ""
  8397. inputData["expy_end"] = ""
  8398. inputData["memo"] = ""
  8399. inputData["vali_flag"] = ""
  8400. inputData["rid"] = ""
  8401. inputData["crter_id"] = ""
  8402. inputData["crter_name"] = ""
  8403. inputData["crte_optins_no"] = ""
  8404. inputData["opter_id"] = ""
  8405. inputData["opter_name"] = ""
  8406. inputData["optins_no"] = ""
  8407. inputData["poolarea_no"] = ""
  8408. inputData["fixmedins_bchno"] = ""
  8409. inputData["inv_data_type"] = ""
  8410. input["data"] = inputData
  8411. inputMessage["input"] = input //交易输入
  8412. bytesData, err := json.Marshal(inputMessage)
  8413. fmt.Println(string(bytesData))
  8414. if err != nil {
  8415. fmt.Println(err.Error())
  8416. return err.Error(), ""
  8417. }
  8418. reader := bytes.NewReader(bytesData)
  8419. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  8420. gdyb_url := beego.AppConfig.String("gdyb_url")
  8421. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  8422. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  8423. url := gdyb_url + "3513"
  8424. request, err := http.NewRequest("POST", url, reader)
  8425. if err != nil {
  8426. fmt.Println(err.Error())
  8427. return err.Error(), ""
  8428. }
  8429. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  8430. request.Header.Set("x-tif-paasid", gdyb_paasid)
  8431. request.Header.Set("x-tif-signature", signature)
  8432. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  8433. request.Header.Set("x-tif-nonce", nonce)
  8434. client := http.Client{}
  8435. resp, err := client.Do(request)
  8436. if err != nil {
  8437. fmt.Println(err.Error())
  8438. return err.Error(), ""
  8439. }
  8440. respBytes, err := ioutil.ReadAll(resp.Body)
  8441. if err != nil {
  8442. fmt.Println(err.Error())
  8443. return err.Error(), ""
  8444. }
  8445. str := string(respBytes)
  8446. fmt.Println(str)
  8447. return str, string(bytesData)
  8448. }
  8449. // 生成基础报文
  8450. func SetGZInputMessage(nonce string, timestamp int64, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, sign string) map[string]interface{} {
  8451. // 生成签名
  8452. tempTime := time.Unix(timestamp, 0)
  8453. //timeFormat := tempTime.Format("20060102150405")
  8454. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  8455. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  8456. month := time.Unix(1557042972, 0).Format("1")
  8457. year := time.Now().Format("2006")
  8458. month = time.Now().Format("01")
  8459. day := time.Now().Format("02")
  8460. hour := time.Now().Format("15")
  8461. min := time.Now().Format("04")
  8462. sec := time.Now().Format("05")
  8463. msec := time.Now().Format("000")
  8464. // 生成输入报文
  8465. inputMessage := make(map[string]interface{})
  8466. inputMessage["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  8467. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  8468. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  8469. inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  8470. inputMessage["dev_no"] = "" // 设备编号
  8471. inputMessage["dev_safe_info"] = "" // 设备安全信息
  8472. inputMessage["cainfo"] = "" // 数字签名信息
  8473. inputMessage["signtype"] = "SM3" // 签名类型
  8474. inputMessage["infver"] = "V1.0" // 接收方系统代码
  8475. inputMessage["opter_type"] = "1" // 经办人类别
  8476. inputMessage["opter"] = doctor // 经办人
  8477. inputMessage["opter_name"] = doctor // 经办人姓名
  8478. inputMessage["inf_time"] = timeFormatOne // 交易时间
  8479. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  8480. inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  8481. inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号
  8482. //inputMessage["sign_no"] = "GZYBCS4101A20220202"
  8483. return inputMessage
  8484. }