gdyb_service.go 310KB

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