123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983 |
- package zh
-
- import (
- "bytes"
- "encoding/json"
- "fmt"
- "gdyb/controllers"
- "gdyb/enums"
- "gdyb/models"
- "gdyb/service"
- "gdyb/utils"
- "github.com/astaxie/beego"
- "github.com/axgle/mahonia"
- "github.com/jinzhu/gorm"
- "io/ioutil"
- "math"
- "math/rand"
- "net/http"
- "os"
- "regexp"
- "strconv"
- "strings"
- "syscall"
- "time"
- "unsafe"
- "github.com/gorilla/websocket"
- "net/url"
-
- )
-
- type ZHHisApiController struct {
- controllers.BaseAuthAPIController
- }
- type ResultSix struct {
- Cainfo interface{} `json:"cainfo"`
- ErrMsg string `json:"err_msg"`
- InfRefmsgid string `json:"inf_refmsgid"`
- Infcode int64 `json:"infcode"`
- Output struct {
- } `json:"output"`
- RefmsgTime string `json:"refmsg_time"`
- RespondTime string `json:"respond_time"`
- Signtype interface{} `json:"signtype"`
- WarnMsg interface{} `json:"warn_msg"`
- }
-
- type ResultTwo struct {
- ErrMsg string `json:"err_msg"`
- InfRefmsgid string `json:"inf_refmsgid"`
- Infcode int64 `json:"infcode"`
- Output struct {
- Baseinfo struct {
- Age float64 `json:"age"`
- Certno string `json:"certno"`
- Gend string `json:"gend"`
- //Brdy string `json:"brdy"`
- Naty string `json:"naty"`
- PsnCertType string `json:"psn_cert_type"`
- PsnName string `json:"psn_name"`
- PsnNo string `json:"psn_no"`
- } `json:"baseinfo"`
- Idetinfo []interface{} `json:"idetinfo"`
- Iinfo []struct {
- Balc float64 `json:"balc"`
- CvlservFlag string `json:"cvlserv_flag"`
- EmpName string `json:"emp_name"`
- InsuplcAdmdvs string `json:"insuplc_admdvs"`
- Insutype string `json:"insutype"`
- PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
- //PausInsuDate string `json:"paus_insu_date"`
- //PsnInsuDate string `json:"psn_insu_date"`
- PsnInsuStas string `json:"psn_insu_stas"`
- PsnType string `json:"psn_type"`
- } `json:"insuinfo"`
- } `json:"output"`
- RefmsgTime string `json:"refmsg_time"`
- RespondTime string `json:"respond_time"`
- Signtype interface{} `json:"signtype"`
- WarnInfo interface{} `json:"warn_info"`
- }
-
- type ResultTwohb struct {
- ErrMsg string `json:"err_msg"`
- InfRefmsgid string `json:"inf_refmsgid"`
- Infcode int64 `json:"infcode"`
- Output struct {
- Baseinfo struct {
- Age float64 `json:"age"`
- Certno string `json:"certno"`
- Gend string `json:"gend"`
- //Brdy string `json:"brdy"`
- Naty string `json:"naty"`
- PsnCertType string `json:"psn_cert_type"`
- PsnName string `json:"psn_name"`
- PsnNo string `json:"psn_no"`
- ExpContent ExpContent `json:"exp_content"`
- } `json:"baseinfo"`
- Idetinfo []interface{} `json:"idetinfo"`
- Iinfo []struct {
- Balc float64 `json:"balc"`
- CvlservFlag string `json:"cvlserv_flag"`
- EmpName string `json:"emp_name"`
- InsuplcAdmdvs string `json:"insuplc_admdvs"`
- Insutype string `json:"insutype"`
- PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
- //PausInsuDate string `json:"paus_insu_date"`
- //PsnInsuDate string `json:"psn_insu_date"`
- PsnInsuStas string `json:"psn_insu_stas"`
- PsnType string `json:"psn_type"`
- } `json:"insuinfo"`
- } `json:"output"`
- RefmsgTime string `json:"refmsg_time"`
- RespondTime string `json:"respond_time"`
- Signtype interface{} `json:"signtype"`
- WarnInfo interface{} `json:"warn_info"`
- }
-
- type ExpContent struct {
- MdtrtCertType string `json:"mdtrt_cert_type"`
- MdtrtCertNo string `json:"mdtrt_cert_no"`
- }
-
- type AHResultTwo struct {
- ErrMsg string `json:"err_msg"`
- InfRefmsgid string `json:"inf_refmsgid"`
- Infcode int64 `json:"infcode"`
- Output struct {
- Baseinfo struct {
- Age float64 `json:"age"`
- Certno string `json:"certno"`
- Gend string `json:"gend"`
- Naty string `json:"naty"`
- //Brdy string `json:"brdy"`
- PsnCertType string `json:"psn_cert_type"`
- PsnName string `json:"psn_name"`
- PsnNo string `json:"psn_no"`
- } `json:"baseinfo"`
- Idetinfo []interface{} `json:"idetinfo"`
- Iinfo []struct {
- Balc float64 `json:"balc"`
- CvlservFlag string `json:"cvlserv_flag"`
- EmpName string `json:"emp_name"`
- InsuplcAdmdvs string `json:"insuplc_admdvs"`
- Insutype string `json:"insutype"`
- PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
- PsnInsuStas string `json:"psn_insu_stas"`
- PsnType string `json:"psn_type"`
- } `json:"insuinfo"`
- } `json:"output"`
- RefmsgTime string `json:"refmsg_time"`
- RespondTime string `json:"respond_time"`
- Signtype interface{} `json:"signtype"`
- WarnInfo interface{} `json:"warn_info"`
- }
-
-
- type ResultTwo10265 struct {
- ErrMsg string `json:"err_msg"`
- InfRefmsgid string `json:"inf_refmsgid"`
- Infcode string `json:"infcode"`
- Output struct {
- Baseinfo struct {
- Age float64 `json:"age"`
- Certno string `json:"certno"`
- Gend string `json:"gend"`
-
- //Brdy string `json:"brdy"`
-
- Naty string `json:"naty"`
- PsnCertType string `json:"psn_cert_type"`
- PsnName string `json:"psn_name"`
- PsnNo string `json:"psn_no"`
- } `json:"baseinfo"`
- Idetinfo []interface{} `json:"idetinfo"`
- Iinfo []struct {
- Balc float64 `json:"balc"`
- CvlservFlag string `json:"cvlserv_flag"`
- EmpName string `json:"emp_name"`
- InsuplcAdmdvs string `json:"insuplc_admdvs"`
- Insutype string `json:"insutype"`
- PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
- PsnInsuStas string `json:"psn_insu_stas"`
- PsnType string `json:"psn_type"`
- } `json:"insuinfo"`
- } `json:"output"`
- RefmsgTime string `json:"refmsg_time"`
- RespondTime string `json:"respond_time"`
- Signtype interface{} `json:"signtype"`
- WarnInfo interface{} `json:"warn_info"`
- }
-
- type ResultThree struct {
- Cainfo interface{} `json:"cainfo"`
- ErrMsg string `json:"err_msg"`
- InfRefmsgid string `json:"inf_refmsgid"`
- Infcode int64 `json:"infcode"`
- Output struct {
- Result struct {
- MdtrtID string `json:"mdtrt_id"`
- } `json:"result"`
- } `json:"output"`
- RefmsgTime string `json:"refmsg_time"`
- RespondTime string `json:"respond_time"`
- Signtype interface{} `json:"signtype"`
- WarnMsg interface{} `json:"warn_msg"`
- }
- type ResultThree10265 struct {
- Cainfo interface{} `json:"cainfo"`
- ErrMsg string `json:"err_msg"`
- InfRefmsgid string `json:"inf_refmsgid"`
- Infcode string `json:"infcode"`
- Output struct {
- Result struct {
- MdtrtID string `json:"mdtrt_id"`
- } `json:"result"`
- } `json:"output"`
- RefmsgTime string `json:"refmsg_time"`
- RespondTime string `json:"respond_time"`
- Signtype interface{} `json:"signtype"`
- WarnMsg interface{} `json:"warn_msg"`
- }
-
- type ResultFour struct {
- Cainfo string `json:"cainfo"`
- ErrMsg string `json:"err_msg"`
- InfRefmsgid string `json:"inf_refmsgid"`
- Infcode int64 `json:"infcode"`
- Output struct {
- Result []struct {
- BasMednFlag string `json:"bas_medn_flag"`
- ChldMedcFlag string `json:"chld_medc_flag"`
- ChrgitmLv string `json:"chrgitm_lv"`
- Cnt float64 `json:"cnt"`
- DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
- DrtReimFlag string `json:"drt_reim_flag"`
- FeedetlSn string `json:"feedetl_sn"`
- FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
- HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
- InscpScpAmt float64 `json:"inscp_scp_amt"`
- ListSpItemFlag string `json:"list_sp_item_flag"`
- LmtUsedFlag string `json:"lmt_used_flag"`
- MedChrgitmType string `json:"med_chrgitm_type"`
- Memo string `json:"memo"`
- OverlmtAmt float64 `json:"overlmt_amt"`
- PreselfpayAmt float64 `json:"preselfpay_amt"`
- Pric float64 `json:"pric"`
- PricUplmtAmt float64 `json:"pric_uplmt_amt"`
- SelfpayProp float64 `json:"selfpay_prop"`
- } `json:"result"`
- } `json:"output"`
- RefmsgTime string `json:"refmsg_time"`
- RespondTime string `json:"respond_time"`
- Signtype string `json:"signtype"`
- WarnMsg string `json:"warn_msg"`
- }
- type ResultFour10265 struct {
- Cainfo string `json:"cainfo"`
- ErrMsg string `json:"err_msg"`
- InfRefmsgid string `json:"inf_refmsgid"`
- Infcode string `json:"infcode"`
- Output struct {
- Result []struct {
- BasMednFlag string `json:"bas_medn_flag"`
- ChldMedcFlag string `json:"chld_medc_flag"`
- ChrgitmLv string `json:"chrgitm_lv"`
- Cnt float64 `json:"cnt"`
- DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
- DrtReimFlag string `json:"drt_reim_flag"`
- FeedetlSn string `json:"feedetl_sn"`
- FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
- HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
- InscpScpAmt float64 `json:"inscp_scp_amt"`
- ListSpItemFlag string `json:"list_sp_item_flag"`
- LmtUsedFlag string `json:"lmt_used_flag"`
- MedChrgitmType string `json:"med_chrgitm_type"`
- Memo string `json:"memo"`
- OverlmtAmt float64 `json:"overlmt_amt"`
- PreselfpayAmt float64 `json:"preselfpay_amt"`
- Pric float64 `json:"pric"`
- PricUplmtAmt float64 `json:"pric_uplmt_amt"`
- SelfpayProp float64 `json:"selfpay_prop"`
- } `json:"result"`
- } `json:"output"`
- RefmsgTime string `json:"refmsg_time"`
- RespondTime string `json:"respond_time"`
- Signtype string `json:"signtype"`
- WarnMsg string `json:"warn_msg"`
- }
-
- type ResultFive struct {
- Balc float64 `json:"balc"`
- CvlservFlag string `json:"cvlserv_flag"`
- EmpName string `json:"emp_name"`
- InsuplcAdmdvs string `json:"insuplc_admdvs"`
- Insutype string `json:"insutype"`
- PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
- PausInsuDate string `json:"paus_insu_date"`
- PsnInsuDate string `json:"psn_insu_date"`
- PsnInsuStas string `json:"psn_insu_stas"`
- PsnType string `json:"psn_type"`
- }
- type ResultSevenTwo struct {
- Cainfo string `json:"cainfo"`
- ErrMsg string `json:"err_msg"`
- InfRefmsgid string `json:"inf_refmsgid"`
- Infcode int64 `json:"infcode"`
- Output struct {
- Setldetail []interface{} `json:"setldetail"`
- Setlinfo struct {
- AcctMulaidPay float64 `json:"acct_mulaid_pay"`
- AcctPay float64 `json:"acct_pay"`
- ActPayDedc float64 `json:"act_pay_dedc"`
- Age string `json:"age"`
- Balc float64 `json:"balc"`
- //Brdy string `json:"brdy"`
- Certno string `json:"certno"`
- ClrOptins string `json:"clr_optins"`
- ClrType string `json:"clr_type"`
- ClrWay string `json:"clr_way"`
- CvlservFlag string `json:"cvlserv_flag"`
- CvlservPay float64 `json:"cvlserv_pay"`
- FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
- FundPaySumamt float64 `json:"fund_pay_sumamt"`
- Gend string `json:"gend"`
- HifesPay float64 `json:"hifes_pay"`
- HifmiPay float64 `json:"hifmi_pay"`
- HifpPay float64 `json:"hifp_pay"`
- HospPartAmt float64 `json:"hosp_part_amt"`
- InscpScpAmt float64 `json:"inscp_scp_amt"`
- Insutype string `json:"insutype"`
- MafPay float64 `json:"maf_pay"`
- MdtrtCertType string `json:"mdtrt_cert_type"`
- HifobPay float64 `json:"hifob_pay"`
-
- MdtrtID string `json:"mdtrt_id"`
- MedType string `json:"med_type"`
- MedfeeSumamt float64 `json:"medfee_sumamt"`
- MedinsSetlID string `json:"medins_setl_id"`
- Naty string `json:"naty"`
- OthPay float64 `json:"oth_pay"`
- OverlmtSelfpay float64 `json:"overlmt_selfpay"`
- PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
- PreselfpayAmt float64 `json:"preselfpay_amt"`
- PsnCashPay float64 `json:"psn_cash_pay"`
- PsnCertType string `json:"psn_cert_type"`
- PsnName string `json:"psn_name"`
- PsnNo string `json:"psn_no"`
- PsnPartAmt float64 `json:"psn_part_amt"`
- PsnType string `json:"psn_type"`
- SetlID string `json:"setl_id"`
- SetlTime string `json:"setl_time"`
- } `json:"setlinfo"`
- } `json:"output"`
- RefmsgTime string `json:"refmsg_time"`
- RespondTime string `json:"respond_time"`
- Signtype interface{} `json:"signtype"`
- WarnMsg interface{} `json:"warn_msg"`
- }
-
- type ResultSeven struct {
- Cainfo string `json:"cainfo"`
- ErrMsg string `json:"err_msg"`
- InfRefmsgid string `json:"inf_refmsgid"`
- Infcode int64 `json:"infcode"`
- Output struct {
- Setldetail []interface{} `json:"setldetail"`
- Setlinfo struct {
- AcctMulaidPay float64 `json:"acct_mulaid_pay"`
- AcctPay float64 `json:"acct_pay"`
- ActPayDedc float64 `json:"act_pay_dedc"`
- Age float64 `json:"age"`
- Balc float64 `json:"balc"`
- //Brdy string `json:"brdy"`
- Certno string `json:"certno"`
- ClrOptins string `json:"clr_optins"`
- ClrType string `json:"clr_type"`
- ClrWay string `json:"clr_way"`
- CvlservFlag string `json:"cvlserv_flag"`
- CvlservPay float64 `json:"cvlserv_pay"`
- FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
- FundPaySumamt float64 `json:"fund_pay_sumamt"`
- Gend string `json:"gend"`
- HifesPay float64 `json:"hifes_pay"`
- HifmiPay float64 `json:"hifmi_pay"`
- HifpPay float64 `json:"hifp_pay"`
- HospPartAmt float64 `json:"hosp_part_amt"`
- InscpScpAmt float64 `json:"inscp_scp_amt"`
- Insutype string `json:"insutype"`
- MafPay float64 `json:"maf_pay"`
- MdtrtCertType string `json:"mdtrt_cert_type"`
- HifobPay float64 `json:"hifob_pay"`
-
- MdtrtID string `json:"mdtrt_id"`
- MedType string `json:"med_type"`
- MedfeeSumamt float64 `json:"medfee_sumamt"`
- MedinsSetlID string `json:"medins_setl_id"`
- Naty string `json:"naty"`
- OthPay float64 `json:"oth_pay"`
- OverlmtSelfpay float64 `json:"overlmt_selfpay"`
- PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
- PreselfpayAmt float64 `json:"preselfpay_amt"`
- PsnCashPay float64 `json:"psn_cash_pay"`
- PsnCertType string `json:"psn_cert_type"`
- PsnName string `json:"psn_name"`
- PsnNo string `json:"psn_no"`
- PsnPartAmt float64 `json:"psn_part_amt"`
- PsnType string `json:"psn_type"`
- SetlID string `json:"setl_id"`
- SetlTime string `json:"setl_time"`
- } `json:"setlinfo"`
- } `json:"output"`
- RefmsgTime string `json:"refmsg_time"`
- RespondTime string `json:"respond_time"`
- Signtype interface{} `json:"signtype"`
- WarnMsg interface{} `json:"warn_msg"`
- }
- type ResultSeven10265 struct {
- Cainfo string `json:"cainfo"`
- ErrMsg string `json:"err_msg"`
- InfRefmsgid string `json:"inf_refmsgid"`
- Infcode string `json:"infcode"`
- Output struct {
- Setldetail []interface{} `json:"setldetail"`
- Setlinfo struct {
- AcctMulaidPay float64 `json:"acct_mulaid_pay"`
- AcctPay float64 `json:"acct_pay"`
- ActPayDedc float64 `json:"act_pay_dedc"`
- Age float64 `json:"age"`
- Balc float64 `json:"balc"`
- //Brdy string `json:"brdy"`
- Certno string `json:"certno"`
- ClrOptins string `json:"clr_optins"`
- ClrType string `json:"clr_type"`
- ClrWay string `json:"clr_way"`
- CvlservFlag string `json:"cvlserv_flag"`
- CvlservPay float64 `json:"cvlserv_pay"`
- FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
- FundPaySumamt float64 `json:"fund_pay_sumamt"`
- Gend string `json:"gend"`
- HifesPay float64 `json:"hifes_pay"`
- HifmiPay float64 `json:"hifmi_pay"`
- HifpPay float64 `json:"hifp_pay"`
- HospPartAmt float64 `json:"hosp_part_amt"`
- InscpScpAmt float64 `json:"inscp_scp_amt"`
- Insutype string `json:"insutype"`
- MafPay float64 `json:"maf_pay"`
- MdtrtCertType string `json:"mdtrt_cert_type"`
- HifobPay float64 `json:"hifob_pay"`
-
- MdtrtID string `json:"mdtrt_id"`
- MedType string `json:"med_type"`
- MedfeeSumamt float64 `json:"medfee_sumamt"`
- MedinsSetlID string `json:"medins_setl_id"`
- Naty string `json:"naty"`
- OthPay float64 `json:"oth_pay"`
- OverlmtSelfpay float64 `json:"overlmt_selfpay"`
- PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
- PreselfpayAmt float64 `json:"preselfpay_amt"`
- PsnCashPay float64 `json:"psn_cash_pay"`
- PsnCertType string `json:"psn_cert_type"`
- PsnName string `json:"psn_name"`
- PsnNo string `json:"psn_no"`
- PsnPartAmt float64 `json:"psn_part_amt"`
- PsnType string `json:"psn_type"`
- SetlID string `json:"setl_id"`
- SetlTime string `json:"setl_time"`
- } `json:"setlinfo"`
- } `json:"output"`
- RefmsgTime string `json:"refmsg_time"`
- RespondTime string `json:"respond_time"`
- Signtype interface{} `json:"signtype"`
- WarnMsg interface{} `json:"warn_msg"`
- }
-
- type ResultSixteen struct {
- Cainfo string `json:"cainfo"`
- ErrMsg string `json:"err_msg"`
- InfRefmsgid string `json:"inf_refmsgid"`
- Infcode int64 `json:"infcode"`
- Output struct {
- Setldetail []interface{} `json:"setldetail"`
- Setlinfo struct {
- MdtrtID string `json:"mdtrt_id"`
- SetlID string `json:"setl_id"`
- ClrOptins string `json:"clr_optins"`
- SetlTime string `json:"setl_time"`
- MedfeeSumamt float64 `json:"medfee_sumamt"`
- FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
- OverlmtSelfpay float64 `json:"overlmt_selfpay"`
- PreselfpayAmt float64 `json:"preselfpay_amt"`
- InscpScpAmt float64 `json:"inscp_scp_amt"`
- ActPayDedc float64 `json:"act_pay_dedc"`
- HifpPay float64 `json:"hifp_pay"`
- PoolPropSe float64 `json:"pool_prop_selfpay"`
- Lfpay float64 `json:"selfpay"`
- CvlservPay float64 `json:"cvlserv_pay"`
- HifesPay float64 `json:"hifes_pay"`
- HifmiPay float64 `json:"hifmi_pay"`
- HifobPay float64 `json:"hifob_pay"`
- MafPay float64 `json:"maf_pay"`
- OthPay float64 `json:"oth_pay"`
- FundPaySumamt float64 `json:"fund_pay_sumamt"`
- PsnPartAmt float64 `json:"psn_part_amt"`
- AcctPay float64 `json:"acct_pay"`
- Balc float64 `json:"balc"`
- AcctMulaidPay float64 `json:"acct_mulaid_pay"`
- HospPartAmt float64 `json:"hosp_part_amt"`
- MedinsSetlID string `json:"medins_setl_id"`
- PdnCashPay string `json:"pdn_cash_pay"`
- } `json:"setlinfo"`
- } `json:"output"`
- RefmsgTime string `json:"refmsg_time"`
- RespondTime string `json:"respond_time"`
- Signtype interface{} `json:"signtype"`
- WarnMsg interface{} `json:"warn_msg"`
- }
- type ResultSixteen10265 struct {
- Cainfo string `json:"cainfo"`
- ErrMsg string `json:"err_msg"`
- InfRefmsgid string `json:"inf_refmsgid"`
- Infcode string `json:"infcode"`
- Output struct {
- Setldetail []interface{} `json:"setldetail"`
- Setlinfo struct {
- MdtrtID string `json:"mdtrt_id"`
- SetlID string `json:"setl_id"`
- ClrOptins string `json:"clr_optins"`
- SetlTime string `json:"setl_time"`
- MedfeeSumamt float64 `json:"medfee_sumamt"`
- FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
- OverlmtSelfpay float64 `json:"overlmt_selfpay"`
- PreselfpayAmt float64 `json:"preselfpay_amt"`
- InscpScpAmt float64 `json:"inscp_scp_amt"`
- ActPayDedc float64 `json:"act_pay_dedc"`
- HifpPay float64 `json:"hifp_pay"`
- PoolPropSe float64 `json:"pool_prop_selfpay"`
- Lfpay float64 `json:"selfpay"`
- CvlservPay float64 `json:"cvlserv_pay"`
- HifesPay float64 `json:"hifes_pay"`
- HifmiPay float64 `json:"hifmi_pay"`
- HifobPay float64 `json:"hifob_pay"`
- MafPay float64 `json:"maf_pay"`
- OthPay float64 `json:"oth_pay"`
- FundPaySumamt float64 `json:"fund_pay_sumamt"`
- PsnPartAmt float64 `json:"psn_part_amt"`
- AcctPay float64 `json:"acct_pay"`
- Balc float64 `json:"balc"`
- AcctMulaidPay float64 `json:"acct_mulaid_pay"`
- HospPartAmt float64 `json:"hosp_part_amt"`
- MedinsSetlID string `json:"medins_setl_id"`
- PdnCashPay string `json:"pdn_cash_pay"`
- } `json:"setlinfo"`
- } `json:"output"`
- RefmsgTime string `json:"refmsg_time"`
- RespondTime string `json:"respond_time"`
- Signtype interface{} `json:"signtype"`
- WarnMsg interface{} `json:"warn_msg"`
- }
-
- type Custom struct {
- DetItemFeeSumamt string
- Cut string
- FeedetlSn string
- Price string
- MedListCodg string
- Type int64
- AdviceId int64
- ProjectId int64
- ItemId int64
- }
-
- type ResultEmpty struct {
- Cainfo interface{} `json:"cainfo"`
- ErrMsg string `json:"err_msg"`
- InfRefmsgid string `json:"inf_refmsgid"`
- Infcode int64 `json:"infcode"`
- Output struct {
- } `json:"output"`
- RefmsgTime string `json:"refmsg_time"`
- RespondTime string `json:"respond_time"`
- Signtype interface{} `json:"signtype"`
- WarnMsg interface{} `json:"warn_msg"`
- }
- type ResultEmpty10265 struct {
- Cainfo interface{} `json:"cainfo"`
- ErrMsg string `json:"err_msg"`
- InfRefmsgid string `json:"inf_refmsgid"`
- Infcode string `json:"infcode"`
- Output struct {
- } `json:"output"`
- RefmsgTime string `json:"refmsg_time"`
- RespondTime string `json:"respond_time"`
- Signtype interface{} `json:"signtype"`
- WarnMsg interface{} `json:"warn_msg"`
- }
-
- type CustomResult struct {
- BasMednFlag string `json:"bas_medn_flag"`
- ChldMedcFlag string `json:"chld_medc_flag"`
- ChrgitmLv string `json:"chrgitm_lv"`
- Cnt float64 `json:"cnt"`
- DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
- DrtReimFlag string `json:"drt_reim_flag"`
- FeedetlSn string `json:"feedetl_sn"`
- FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
- HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
- InscpScpAmt float64 `json:"inscp_scp_amt"`
- ListSpItemFlag string `json:"list_sp_item_flag"`
- LmtUsedFlag string `json:"lmt_used_flag"`
- MedChrgitmType string `json:"med_chrgitm_type"`
- Memo string `json:"memo"`
- OverlmtAmt float64 `json:"overlmt_amt"`
- PreselfpayAmt float64 `json:"preselfpay_amt"`
- Pric float64 `json:"pric"`
- PricUplmtAmt float64 `json:"pric_uplmt_amt"`
- SelfpayProp float64 `json:"selfpay_prop"`
- }
-
- func ZHHisManagerApiRegistRouters() {
- beego.Router("/zh/api/inhopitalcheck/get", &ZHHisApiController{}, "get:GetZHInHospitalCheck")
- beego.Router("/zh/api/outhopitalcheck/get", &ZHHisApiController{}, "get:GetZHOutHospitalCheck")
- beego.Router("/zh/api/uploadinfo/get", &ZHHisApiController{}, "get:GetUploadInfo")
- beego.Router("/zh/api/presettle/get", &ZHHisApiController{}, "get:GetPreSettleInfo")
- beego.Router("/zh/api/settle/get", &ZHHisApiController{}, "get:GetSettleInfo")
- beego.Router("/zh/api/inthopitaluncheck/get", &ZHHisApiController{}, "get:GetZHInHospitalUnCheck")
- beego.Router("/zh/api/outhopitaluncheck/get", &ZHHisApiController{}, "get:GetZHOutHospitalUnCheck")
- beego.Router("/zh/api/refund", &ZHHisApiController{}, "get:ZHRefund")
- beego.Router("/zh/api/refunddetail", &ZHHisApiController{}, "get:ZHRefundDetail")
- beego.Router("/zh/api/patient/info", &ZHHisApiController{}, "get:GetZHPatientInfo")
- beego.Router("/zh/api/readcard", &ZHHisApiController{}, "get:ReadCard")
-
- beego.Router("/zh/api/clearsettle", &ZHHisApiController{}, "get:ClearSettle")
- beego.Router("/zh/api/readelecard", &ZHHisApiController{}, "get:ReadEleCard")
-
- beego.Router("/zh/api/deviceinit", &ZHHisApiController{}, "get:ReadEleCardfordevice")
-
-
- //beego.Router("/zh/api/readelecard", &ZHHisApiController{}, "get:ReadEleCard")
- beego.Router("/zh/api/lingbao/upload", &ZHHisApiController{}, "get:UploadLingBao")
- beego.Router("/zh/api/lingbao/refund", &ZHHisApiController{}, "get:RefundLingBao")
- beego.Router("/zh/api/lingbao/get", &ZHHisApiController{}, "get:GetLingBao")
-
- beego.Router("/api/token/get", &ZHHisApiController{}, "post:GetToken")
- beego.Router("/api/ele/info", &ZHHisApiController{}, "post:GetEleInfo")
-
- beego.Router("/api/4102", &ZHHisApiController{}, "get:Get4102")
- beego.Router("/api/4103", &ZHHisApiController{}, "get:Get4103")
- //beego.Router("/api/4104", &ZHHisApiController{}, "get:Get4104")
-
- beego.Router("/api/cardstatus", &ZHHisApiController{}, "get:GetCardStatus")
-
- //beego.Router("/api/2403", &ZHHisApiController{}, "get:Get2403")
- beego.Router("/api/5201", &ZHHisApiController{}, "get:Get5201")
-
- }
- func (c *ZHHisApiController) Get5201() {
-
- }
-
- // func (c *ZHHisApiController) Get2403(){
- // id, _ := c.GetInt64("order_id")
- // order,_ := service.GetHisOrderByID(id)
- // hosp,_ := service.GetInHospitalRecordByNumber(order.MdtrtId)
- //
- //
- // med_type := "21"
- // id_card_type := hosp.IdCardType
- //
- //
- //
- // diagnosis_ids_arr := strings.Split(hosp.Diagnosis, "-")
- // adminInfo := c.GetAdminUserInfo()
- // var patient service.Patients
- // if id == 0 {
- // patient, _ = service.GetPatientByIDCard(order.Certno, adminInfo.CurrentOrgId)
- // } else {
- // patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
- // }
- // diagnosisConfig, _ := service.FindDiagnoseByIds(diagnosis_ids_arr)
- //
- // doctorInfo, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, hosp.Doctor)
- // //deviceNumber, _ := service.GetDeviceNumberByID(adm_bed, adminInfo.CurrentOrgId)
- // departmentInfo, _ := service.GetDepartMentDetail(hosp.Departments)
- //
- //
- //
- //
- // var struct2401 service.Struct2401
- // struct2401.Insutype = "390"
- // psn_info, _ := service.GetPsnByPatientId(patient.ID)
- // if id_card_type == 1 {
- // struct2401.MdtrtCertType = "03"
- // bas := strings.Split(psn_info.CardInfo, "|")
- // cardNumber := bas[2]
- // struct2401.MdtrtCertNo = cardNumber
- // struct2401.PsnNo = order.PsnNo
- // } else if id_card_type == 4 {
- // struct2401.MdtrtCertType = "01"
- // struct2401.MdtrtCertNo = psn_info.VerifyNumber
- // struct2401.PsnNo = psn_info.PsnNo
- // } else {
- // struct2401.MdtrtCertType = "02"
- // struct2401.MdtrtCertNo = hosp.Certno
- // struct2401.PsnNo = hosp.PsnNo
- // }
- //
- // struct2401.IptNo = "2023061415103410808113442"
- // struct2401.AtddrNo = doctorInfo.DoctorNumber
- // struct2401.ChfpdrName = doctorInfo.UserName
- // struct2401.AdmDiagDscr = diagnosisConfig[0].ClassName
- // struct2401.AdmDeptCodg = strconv.FormatInt(int64(departmentInfo.ID), 10)
- // struct2401.AdmDeptName = departmentInfo.Name
- // struct2401.AdmBed = ""
- // struct2401.AdmBed = "待定"
- //
- // struct2401.DscgMaindiagName = diagnosisConfig[0].ClassName
- // struct2401.DscgMaindiagCode = diagnosisConfig[0].CountryCode
- // struct2401.Begntime = "2023"
- // struct2401.DiseCodg = sickConfig.CountryCode
- // struct2401.DiseName = sickConfig.ClassName
- //
- // }
- func (c *ZHHisApiController) GetCardStatus() {
- //patient_id, _ := c.GetInt64("patient_id")
- //record_date, _ := c.GetInt64("record_date")
- //psn, _ := service.GetPsnByPatientIdtWO(patient_id,record_date)
- //if len(psn.VerifyNumber) > 0{
- // c.ServeSuccessJSON(map[string]interface{}{
- // "msg": "读卡成功",
- // })
- //} else{
- // c.ServeSuccessJSON(map[string]interface{}{
- // "msg": "",
- // })
- //}
- }
-
- func (c *ZHHisApiController) GetEleInfo() {
- body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
- var respJSON map[string]interface{}
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- return
- }
- token := respJSON["token"].(string)
- respJSON = respJSON["result"].(map[string]interface{})
- result_byte, _ := json.Marshal(respJSON)
- result := string(result_byte)
-
- fmt.Println("token")
- fmt.Println(token)
- fmt.Println("result")
- fmt.Println(result)
-
- var res ResultTwo
- var res10265 ResultTwo10265 //1101结果
- if err := json.Unmarshal([]byte(result), &res10265); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- res.ErrMsg = res10265.ErrMsg
- infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
- res.Infcode = infocode
- res.Output = res10265.Output
- res.InfRefmsgid = res10265.InfRefmsgid
-
- if res.Infcode == 0 {
- patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
- if err == gorm.ErrRecordNotFound {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
- return
- } else if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- } else {
- Iinfos, _ := json.Marshal(res.Output.Iinfo)
- Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
- infoStr := string(Iinfos)
- idetinfoStr := string(Idetinfos)
- psn := &models.HisPsn{
- PsnNo: res.Output.Baseinfo.PsnNo,
- Age: res.Output.Baseinfo.Age,
- PatientId: patient.ID,
- Certno: res.Output.Baseinfo.Certno,
- Gend: res.Output.Baseinfo.Gend,
- Naty: res.Output.Baseinfo.Naty,
- PsnCertType: res.Output.Baseinfo.PsnCertType,
- PsnName: res.Output.Baseinfo.PsnName,
- Idetinfo: idetinfoStr,
- Insuinfo: infoStr,
- UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
- CardInfo: "",
- VerifyNumber: token,
- }
- service.CreateHisPsn(psn)
- c.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- "number": token,
- })
- }
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
- return
- }
- }
- func (c *ZHHisApiController) GetToken() {
- body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
- var respJSON map[string]interface{}
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- return
- }
- token := respJSON["token"].(string)
- id_card_no := respJSON["id_card_no"].(string)
- fmt.Println("token")
- fmt.Println(token)
- fmt.Println("result")
- fmt.Println(id_card_no)
-
- miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
- patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
- var api string
- api = "http://172.16.13.254:9532/" + "api/eleinfo?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&org_name=" + miConfig.OrgName +
- "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&token=" + token + "&user_name=" + patient.Name + "&id_card_no=" + patient.IdCardNo
- resp, requestErr := http.Get(api)
- if requestErr != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- body, ioErr := ioutil.ReadAll(resp.Body)
- if ioErr != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "读卡成功",
- })
-
- }
-
- func (c *ZHHisApiController) UploadLingBao() {
- id, _ := c.GetInt64("id")
- record_time := c.GetString("record_time")
- in_hospital_id, _ := c.GetInt64("in_hospital_id")
- settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
- admin_user_id, _ := c.GetInt64("admin_user_id")
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordDateTime := theTime.Unix()
- adminUser := c.GetAdminUserInfo()
- var prescriptions []*models.HisPrescription
- data := make(map[string]interface{})
- if settle_accounts_type == 1 { //日结
- prescriptions, _ = service.GetZHHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
-
- } else { //月结
- start_time_str := c.GetString("start_time")
- end_time_str := c.GetString("end_time")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordStartTime := theStartTime.Unix()
- theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordEndTime := theEndTime.Unix()
- prescriptions, _ = service.GetZHMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
-
- }
- roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
- record, _ := service.GetInHospitalRecord(in_hospital_id)
- if record.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
-
- timestamp := time.Now().Unix()
- tempTime := time.Unix(timestamp, 0)
- timeFormat := tempTime.Format("20060102150405")
- chrgBchno := rand.Intn(100000) + 10000
- chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(record.PatientId, 10)
- miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
- patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
- department, _ := service.GetDepartMentDetail(record.Departments)
- strconv.FormatInt(record.PatientId, 10)
-
- doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, record.Doctor)
-
- //client := &http.Client{}
- data["psn_no"] = record.PsnNo
- data["mdtrt_id"] = record.Number
- data["chrg_bchno"] = chrg_bchno
- data["org_name"] = miConfig.OrgName
- data["doctor"] = roles.UserName
- data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
- data["dept"] = strconv.FormatInt(department.ID, 10)
- data["fixmedins_code"] = miConfig.Code
- if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
- data["dept_code"] = "15"
- } else {
- data["dept_code"] = department.Number
- }
- if miConfig.Code == "H15049901371" {
- if record.MedType == 14 {
- if record.InsutypeType == "390" {
-
- data["med_type"] = "9933"
-
- } else if record.InsutypeType == "310" {
-
- data["med_type"] = "990502"
-
- }
-
- } else if record.MedType == 11 {
-
- data["med_type"] = strconv.FormatInt(record.MedType, 10)
-
- }
-
- } else {
- if record.MedType == 1112 {
- data["med_type"] = strconv.FormatInt(11, 10)
- } else {
- data["med_type"] = strconv.FormatInt(record.MedType, 10)
- }
-
- }
- data["insuplc_admdvs"] = record.InsuplcAdmdvs
- data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
- data["secret_key"] = miConfig.SecretKey
- var ids []int64
-
- fmt.Println(data)
-
- for _, item := range prescriptions {
- ids = append(ids, item.ID)
- }
- config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
- if config.IsOpen == 1 { //对接了医保,走医保流程
-
- var pagesize int = 100
- var start int = 1
- var stop int
- var pagecount int
- var curpage int
- var isSuccess bool = true
-
- var customs []*models.NewCustom
-
- for _, item := range prescriptions {
- tm := time.Unix(item.PreTime, 0)
- if item.Type == 1 { //药品
- for _, subItem := range item.HisDoctorAdviceInfo {
- if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 && subItem.BaseDrugLib.IsUser != 1 {
- //var randNum int
- //randNum = rand.Intn(10000) + 1000
- cus := &models.NewCustom{
- DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber),
- Cut: fmt.Sprintf("%.4f", subItem.PrescribingNumber),
- FeedetlSn: subItem.FeedetlSn,
- Price: fmt.Sprintf("%.4f", subItem.Price),
- MedListCodg: subItem.BaseDrugLib.MedicalInsuranceNumber,
- HospApprFlag: subItem.BaseDrugLib.HospApprFlag,
- FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
- }
-
- customs = append(customs, cus)
- }
- }
- }
-
- if item.Type == 2 { //项目
- for _, subItem := range item.HisPrescriptionProject {
- //var randNum int
- //randNum = rand.Intn(10000) + 1000
- if subItem.Type == 2 {
- if len(subItem.HisProject.MedicalCode) > 0 {
- cnt, _ := strconv.ParseFloat(subItem.Count, 64)
- cus := &models.NewCustom{
- DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
- Cut: fmt.Sprintf("%.4f", cnt),
- FeedetlSn: subItem.FeedetlSn,
- Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
- MedListCodg: subItem.HisProject.MedicalCode,
- HospApprFlag: -1,
- FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
- }
- customs = append(customs, cus)
- }
- } else if subItem.Type == 3 {
- if len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 && subItem.GoodInfo.IsUser != 1 {
- cnt, _ := strconv.ParseFloat(subItem.Count, 64)
-
- cus := &models.NewCustom{
- DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
- Cut: fmt.Sprintf("%.4f", cnt),
- FeedetlSn: subItem.FeedetlSn,
- Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
- MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
- HospApprFlag: -1,
- FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
- }
- customs = append(customs, cus)
- }
- }
- }
- }
-
- }
-
- //总页数,向上取整,注意除之前要先转换类型为float64
- pagecount = int(math.Ceil(float64(len(customs)) / float64(pagesize)))
- var ress []*ResultFour
- for curpage = 1; curpage <= pagecount; curpage++ {
- if curpage == 1 {
- start = 1
- } else {
- start = (curpage-1)*pagesize + 1
- }
- stop = curpage * pagesize
- if stop > len(customs) {
- stop = len(customs)
- }
-
- var result string
- var requestLog string
- if miConfig.MdtrtareaAdmvs == "150499" {
- data := make(map[string]interface{})
- if record.MedType == 14 {
- if record.InsutypeType == "390" {
-
- data["med_type"] = "9933"
-
- } else if record.InsutypeType == "310" {
-
- data["med_type"] = "990502"
-
- }
-
- } else if record.MedType == 11 {
-
- data["med_type"] = strconv.FormatInt(record.MedType, 10)
-
- }
- data["psn_no"] = record.PsnNo
- data["number"] = record.Number
- data["customs"] = customs[start-1 : stop]
- data["chrg_bchno"] = chrg_bchno
- data["dept"] = strconv.FormatInt(department.ID, 10)
- data["dept_code"] = department.Number
- data["doctor_code"] = doctor_info.DoctorNumber
- data["doctor_name"] = doctor_info.UserName
- data["org_name"] = miConfig.OrgName
- data["opertor"] = roles.UserName
- data["fixmedins_code"] = miConfig.Code
- data["insuplc_admdvs"] = record.InsuplcAdmdvs
- data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
- data["secret_key"] = miConfig.SecretKey
-
- var req *http.Request
- bytesData, _ := json.Marshal(data)
- req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2301", bytes.NewReader(bytesData))
- client := &http.Client{}
- resp, _ := client.Do(req)
- defer resp.Body.Close()
- body, ioErr := ioutil.ReadAll(resp.Body)
- if ioErr != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- var respJSON map[string]interface{}
- if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
- result_byte, _ := json.Marshal(respJSON)
- result = string(result_byte)
- } else {
- result, requestLog = service.ZHGdyb2301(record.PsnNo, record.Number, customs[start-1:stop], chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(department.ID, 10), miConfig.Code, department.Number, strconv.FormatInt(roles.AdminUserId, 10), record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, data["med_type"].(string), doctor_info.DoctorNumber, doctor_info.UserName)
- saveLog(result, requestLog, "2301", "上传明细")
- }
-
- var dat map[string]interface{}
- if err := json.Unmarshal([]byte(result), &dat); err == nil {
- fmt.Println(dat)
- } else {
- fmt.Println(err)
- }
- userJSONBytes, _ := json.Marshal(dat)
- var res ResultFour
- var resFour10265 ResultFour10265
- if miConfig.Code == "H15049901371" {
- if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- res.WarnMsg = resFour10265.WarnMsg
- res.Output = resFour10265.Output
- res.ErrMsg = resFour10265.ErrMsg
- res.RespondTime = resFour10265.RespondTime
- res.InfRefmsgid = resFour10265.InfRefmsgid
- Infcode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
- res.Infcode = Infcode
-
- } else {
- if err := json.Unmarshal(userJSONBytes, &res); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- }
-
- if res.Infcode == 0 {
- ress = append(ress, &res)
- } else {
- isSuccess = false
- errlog := &models.HisOrderError{
- UserOrgId: adminUser.CurrentOrgId,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- Number: chrg_bchno,
- ErrMsg: "",
- Status: 1,
- PatientId: id,
- RecordTime: recordDateTime,
- Stage: 4,
- }
- service.CreateErrMsgLog(errlog)
- c.ServeSuccessJSON(map[string]interface{}{
- "failed_code": -10,
- "msg": "上传明细错误,请联系his厂商",
- })
- return
- }
- }
-
- if isSuccess == true {
- if settle_accounts_type == 1 {
- for _, subItem := range ress {
- for _, item := range subItem.Output.Result {
- temp := strings.Split(item.FeedetlSn, "-")
- var advice_id int64 = 0
- var project_id int64 = 0
- var types int64 = 0
-
- id, _ := strconv.ParseInt(temp[2], 10, 64)
- types, _ = strconv.ParseInt(temp[1], 10, 64)
-
- if temp[1] == "1" {
- advice_id = id
- project_id = 0
- } else if temp[1] == "2" {
- advice_id = 0
- project_id = id
- }
- info := &models.HisOrderInfo{
- OrderNumber: record.Number,
- FeedetlSn: item.FeedetlSn,
- UploadDate: recordDateTime,
- AdviceId: advice_id,
- DetItemFeeSumamt: item.DetItemFeeSumamt,
- Cnt: item.Cnt,
- Pric: float64(item.Pric),
- PatientId: record.PatientId,
- PricUplmtAmt: item.PricUplmtAmt,
- SelfpayProp: item.SelfpayProp,
- FulamtOwnpayAmt: item.FulamtOwnpayAmt,
- OverlmtAmt: item.OverlmtAmt,
- PreselfpayAmt: item.PreselfpayAmt,
- BasMednFlag: item.BasMednFlag,
- MedChrgitmType: item.MedChrgitmType,
- HiNegoDrugFlag: item.HiNegoDrugFlag,
- Status: 1,
- Memo: item.Memo,
- Mtime: time.Now().Unix(),
- InscpScpAmt: item.InscpScpAmt,
- DrtReimFlag: item.DrtReimFlag,
- Ctime: time.Now().Unix(),
- ListSpItemFlag: item.ListSpItemFlag,
- ChldMedcFlag: item.ChldMedcFlag,
- LmtUsedFlag: item.LmtUsedFlag,
- ChrgitmLv: item.ChrgitmLv,
- UserOrgId: adminUser.CurrentOrgId,
- HisPatientId: record.ID,
- OrderId: 0,
- ProjectId: project_id,
- Type: types,
- SettleType: settle_accounts_type,
- }
- service.CreateOrderInfo(info)
- }
- }
-
- err := service.UpDatePrescriptionOrderStatus(adminUser.CurrentOrgId, ids)
- service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, record.Number)
- service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, record.Number, recordDateTime)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "上传费用明细成功",
- })
- return
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
-
- } else {
-
- for _, subItem := range ress {
- for _, item := range subItem.Output.Result {
- temp := strings.Split(item.FeedetlSn, "-")
- var advice_id int64 = 0
- var project_id int64 = 0
- var types int64 = 0
-
- id, _ := strconv.ParseInt(temp[2], 10, 64)
- types, _ = strconv.ParseInt(temp[1], 10, 64)
-
- if temp[1] == "1" {
- advice_id = id
- project_id = 0
- } else if temp[1] == "2" {
- advice_id = 0
- project_id = id
- }
- info := &models.HisOrderInfo{
- OrderNumber: record.Number,
- FeedetlSn: item.FeedetlSn,
- UploadDate: time.Now().Unix(),
- AdviceId: advice_id,
- DetItemFeeSumamt: item.DetItemFeeSumamt,
- Cnt: item.Cnt,
- Pric: float64(item.Pric),
- PatientId: record.PatientId,
- PricUplmtAmt: item.PricUplmtAmt,
- SelfpayProp: item.SelfpayProp,
- FulamtOwnpayAmt: item.FulamtOwnpayAmt,
- OverlmtAmt: item.OverlmtAmt,
- PreselfpayAmt: item.PreselfpayAmt,
- BasMednFlag: item.BasMednFlag,
- MedChrgitmType: item.MedChrgitmType,
- HiNegoDrugFlag: item.HiNegoDrugFlag,
- Status: 1,
- Memo: item.Memo,
- Mtime: time.Now().Unix(),
- InscpScpAmt: item.InscpScpAmt,
- DrtReimFlag: item.DrtReimFlag,
- Ctime: time.Now().Unix(),
- ListSpItemFlag: item.ListSpItemFlag,
- ChldMedcFlag: item.ChldMedcFlag,
- LmtUsedFlag: item.LmtUsedFlag,
- ChrgitmLv: item.ChrgitmLv,
- UserOrgId: adminUser.CurrentOrgId,
- HisPatientId: record.ID,
- ProjectId: project_id,
- Type: types,
- SettleType: settle_accounts_type,
- }
- service.CreateOrderInfo(info)
- }
- }
- service.UpDatePrescriptionOrderStatus(adminUser.CurrentOrgId, ids)
- service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, record.Number)
- service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, record.Number, recordDateTime)
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "上传费用明细成功",
- })
-
- }
-
- }
-
- }
- }
-
- func (c *ZHHisApiController) RefundLingBao() {
-
- }
-
- func (c *ZHHisApiController) GetLingBao() {
-
- }
-
- func (c *ZHHisApiController) ReadEleCard() {
- id_card_type, _ := c.GetInt64("id_card_type")
- admin_user_id, _ := c.GetInt64("admin_user_id")
- roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
- miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
-
- var api string
- api = "http://172.16.13.254:9532/" + "nmyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
- "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
-
- fmt.Println(api)
-
- resp, requestErr := http.Get(api)
- if requestErr != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- body, ioErr := ioutil.ReadAll(resp.Body)
- if ioErr != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- var respJSON map[string]interface{}
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- var status string
- status = respJSON["data"].(map[string]interface{})["status"].(string)
- //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
- var token string
- var res ResultTwo //1101结果
- var res10265 ResultTwo10265 //1101结果
- if status == "0" { //读卡成功
- token = respJSON["data"].(map[string]interface{})["token"].(string)
- respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
- result, _ := json.Marshal(respJSON)
- if err := json.Unmarshal([]byte(result), &res10265); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- res.ErrMsg = res10265.ErrMsg
- infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
- res.Infcode = infocode
- res.Output = res10265.Output
- res.InfRefmsgid = res10265.InfRefmsgid
- if res.Infcode == 0 {
- c.ServeSuccessJSON(map[string]interface{}{
- "number": token,
- })
- }
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
- return
- }
-
- }
-
- func (c *ZHHisApiController) ClearSettle() {
-
- order_id, _ := c.GetInt64("order_id")
- admin_user_id, _ := c.GetInt64("admin_user_id")
- adminUser := c.GetAdminUserInfo()
- var order models.HisOrder
- order, _ = service.GetHisOrderByID(order_id)
- record, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
- roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
- miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
- config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
- if miConfig.MdtrtareaAdmvs == "350500" {
- record, _ := service.GetUploadRecord(order_id)
- record.Status = 0
- service.UpdateRecord(&record)
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "撤销成功",
- })
- } else {
- if config.IsOpen == 1 { //对接了医保,走医保流程
- var result string
- var requestLog string
- result, requestLog = service.Gdyb90306(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
- saveLog(result, requestLog, "90306", "撤销结算清单")
-
- var dat map[string]interface{}
- if err := json.Unmarshal([]byte(result), &dat); err == nil {
- fmt.Println(dat)
- } else {
- fmt.Println(err)
- }
-
- userJSONBytes, _ := json.Marshal(dat)
-
- var res ResultSix
- //var resSixteen ResultSixteen10265
- if miConfig.Code == "H15049901371" {
- //if err := json.Unmarshal(userJSONBytes, &resSixteen); err != nil {
- // utils.ErrorLog("解析失败:%v", err)
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- //}
- //res.Cainfo = resSixteen.Cainfo
- //res.WarnMsg = resSixteen.WarnMsg
- //res.Output = resSixteen.Output
- //res.ErrMsg = resSixteen.ErrMsg
- //res.RespondTime = resSixteen.RespondTime
- //Infcode, _ := strconv.ParseInt(resSixteen.Infcode, 10, 64)
- //res.Infcode = Infcode
-
- } else {
-
- if err := json.Unmarshal(userJSONBytes, &res); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- }
- if res.Infcode == 0 {
-
- record, _ := service.GetUploadRecord(order_id)
- record.Status = 0
- service.UpdateRecord(&record)
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "撤销成功",
- })
- } else {
- c.ServeSuccessJSON(map[string]interface{}{
- "code": -10,
- "msg": res.ErrMsg,
- })
- }
-
- }
-
- }
-
- }
-
- func (c *ZHHisApiController) GetZHPatientInfo() {
- id_card_no := c.GetString("id_card_no")
- admin_user_id, _ := c.GetInt64("admin_user_id")
- patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
- if patient.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
- role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
- miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
- config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
- if config.IsOpen == 1 {
- var result string
- var request_log string
- var result_log string
-
- if miConfig.MdtrtareaAdmvs == "150499" {
- var insuplc_admdvs string
- if len(patient.InsuplcAdmdvs) > 0 {
- insuplc_admdvs = patient.InsuplcAdmdvs
- } else {
- insuplc_admdvs = miConfig.InsuplcAdmdvs
- }
- //请求内网数据
- api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
- "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
- "&insuplc_admdvs=" + insuplc_admdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(2, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(1, 10) + "&name=" + patient.Name
-
- resp, requestErr := http.Get(api)
- if requestErr != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- body, ioErr := ioutil.ReadAll(resp.Body)
- if ioErr != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- var respJSON map[string]interface{}
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
- result_byte, _ := json.Marshal(respJSON)
- result = string(result_byte)
- saveLog(result_log, request_log, "1101", "人员基本信息获取")
-
- } else if miConfig.MdtrtareaAdmvs == "360399" {
- result, request_log = service.JxybZY1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, "", miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", 0, miConfig.Url, miConfig.AccessKey, "", patient.IdCardNo, "")
- saveLog(result_log, request_log, "1101", "人员基本信息获取")
- }else if miConfig.MdtrtareaAdmvs == "341203"{
- var insuplc_admdvs string
- if len(patient.InsuplcAdmdvs) > 0 {
- insuplc_admdvs = patient.InsuplcAdmdvs
- } else {
- insuplc_admdvs = miConfig.InsuplcAdmdvs
- }
- //请求内网数据
- api := miConfig.SecretKey + "ahyb/1101?url=" + miConfig.Url + "&cert_no=" + patient.IdCardNo +
- "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
- "&insuplc_admdvs=" + insuplc_admdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(2, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(1, 10) + "&name=" + patient.Name+"&token="+""
-
- resp, requestErr := http.Get(api)
- if requestErr != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- body, ioErr := ioutil.ReadAll(resp.Body)
- if ioErr != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- var respJSON map[string]interface{}
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- status := respJSON["data"].(map[string]interface{})["status"].(string)
- if status == "0"{
- err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
- c.ServeSuccessJSON(map[string]interface{}{
- "failed_code": -10,
- "msg": err_msg,
- })
- return
- }
- respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
- result_byte, _ := json.Marshal(respJSON)
- result = string(result_byte)
- saveLog(result_log, request_log, "1101", "人员基本信息获取")
- } else {
- result, request_log, result_log = service.ZHGdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", 1, patient.Name,admin_user_id)
- saveLog(result_log, request_log, "1101", "人员基本信息获取")
- }
- //result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
- var dat map[string]interface{}
- if err := json.Unmarshal([]byte(result), &dat); err == nil {
- fmt.Println(dat)
- } else {
- fmt.Println(err)
- }
-
- userJSONBytes, _ := json.Marshal(dat)
- var res ResultTwo
- var resTwo10265 ResultTwo10265
-
- if miConfig.Code == "H15049901371" {
- if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
- res.Infcode = Infcode
- res.ErrMsg = resTwo10265.ErrMsg
- res.Output = resTwo10265.Output
- res.InfRefmsgid = resTwo10265.InfRefmsgid
- res.RespondTime = resTwo10265.RespondTime
- res.WarnInfo = resTwo10265.WarnInfo
-
- }else if miConfig.MdtrtareaAdmvs == "441799" {
-
- //请求内网数据
- api := miConfig.Url + "gdyb/1101?cert_no=" + patient.IdCardNo +
- "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
- "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(2, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(1, 10) + "&name=" + patient.Name
-
- resp, requestErr := http.Get(api)
- if requestErr != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- body, ioErr := ioutil.ReadAll(resp.Body)
-
- if ioErr != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- var respJSON map[string]interface{}
-
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
- result_byte, _ := json.Marshal(respJSON)
- result = string(result_byte)
- saveLog(result_log, request_log, "1101", "人员基本信息获取")
-
- if err := json.Unmarshal([]byte(result), &res); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- } else if miConfig.MdtrtareaAdmvs == "450721"{
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "",
-
- })
-
-
- } else {
- if err := json.Unmarshal(userJSONBytes, &res); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- }
-
- var insutypes []string
- var insutype string
- var is390 int = 0
- var is310 int = 0
- for _, item := range res.Output.Iinfo {
- if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
- insutypes = append(insutypes, item.Insutype)
- }
- }
- if len(insutypes) == 1 {
- insutype = insutypes[0]
- } else {
- for _, i := range insutypes {
- if i == "390" {
- is390 = 1
- }
-
- if i == "310" {
- is310 = 1
- }
- }
- }
- if is390 == 1 {
- insutype = "390"
- }
- if is310 == 1 {
- insutype = "310"
- }
- if len(insutypes) == 0 {
- insutype = "310"
- }
-
- Iinfos, _ := json.Marshal(res.Output.Iinfo)
- Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
- infoStr := string(Iinfos)
- idetinfoStr := string(Idetinfos)
- psn := &models.HisPsn{
- PsnNo: res.Output.Baseinfo.PsnNo,
- Age: res.Output.Baseinfo.Age,
- PatientId: patient.ID,
- Certno: res.Output.Baseinfo.Certno,
- Gend: res.Output.Baseinfo.Gend,
- Naty: res.Output.Baseinfo.Naty,
- PsnCertType: res.Output.Baseinfo.PsnCertType,
- PsnName: res.Output.Baseinfo.PsnName,
- Idetinfo: idetinfoStr,
- Insuinfo: infoStr,
- UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
- VerifyNumber: "",
- }
- service.CreateHisPsn(psn)
-
- if res.Infcode == -1 {
- c.ServeSuccessJSON(map[string]interface{}{
- "failed_code": -10,
- "msg": res.ErrMsg,
- })
- } else {
- c.ServeSuccessJSON(map[string]interface{}{
- "failed_code": 0,
- "info": res,
- "insutype": insutype,
- })
- }
- }
- }
-
- func (c *ZHHisApiController) GetZHInHospitalCheck() {
- id, _ := c.GetInt64("id")
- record_time := c.GetString("record_time")
- name := c.GetString("name")
- phone := c.GetString("phone")
- id_card_type, _ := c.GetInt64("id_card_type")
- certificates, _ := c.GetInt64("certificates")
- id_card_no := c.GetString("id_card_no")
- doctor, _ := c.GetInt64("doctor")
- admin_user_id, _ := c.GetInt64("admin_user_id")
- department, _ := c.GetInt64("department")
- adm_bed, _ := c.GetInt64("adm_bed")
- diagnosis_ids := c.GetString("diagnosis")
- sick_type, _ := c.GetInt64("sick_type")
- start_time := c.GetString("start_time")
- insuplc_admdvs := c.GetString("insuplc_admdvs")
- balance_accounts_type, _ := c.GetInt64("balance_accounts_type")
-
- social_type, _ := c.GetInt64("social_type")
- psn_type, _ := c.GetInt64("psn_type")
-
- //reg_type, _ := c.GetInt64("p_type")
- med_type, _ := c.GetInt64("med_type")
- diagnosis_ids_arr := strings.Split(diagnosis_ids, "-")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordDateTime := theTime.Unix()
- adminInfo := c.GetAdminUserInfo()
- record, _ := service.GetLastHospitalRecord(id, adminInfo.CurrentOrgId)
- if record.ID != 0 {
- if record.InHospitalStatus == 1 && record.OutHospitalStatus != 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHospitalExistDataException)
- return
- }
- }
- var patient service.Patients
- if id == 0 {
- patient, _ = service.GetPatientByIDCard(id_card_no, adminInfo.CurrentOrgId)
- } else {
- patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
- }
- diagnosisConfig, _ := service.FindDiagnoseByIds(diagnosis_ids_arr)
- sickConfig, _ := service.FindSickById(sick_type)
- departmentInfo, _ := service.GetDepartMentDetail(department)
- miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
- role, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
-
- var result string
- var request_log string
- var result_log string
- var res2 ResultTwo
- var resTwo10265 ResultTwo10265
- psn_info, _ := service.GetPsnByPatientId(patient.ID)
-
- if miConfig.MdtrtareaAdmvs == "150499" {
- if id_card_type == 2 {
- mdtrt_cert_no := ""
-
- mdtrt_cert_no = id_card_no
-
- //请求内网数据
- api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + mdtrt_cert_no +
- "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
- "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(certificates, 10) + "&name=" + patient.Name
- resp, requestErr := http.Get(api)
- if requestErr != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- body, ioErr := ioutil.ReadAll(resp.Body)
-
- if ioErr != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- var respJSON map[string]interface{}
-
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
- result_byte, _ := json.Marshal(respJSON)
- result = string(result_byte)
-
- var dat map[string]interface{}
- if err := json.Unmarshal([]byte(result), &dat); err == nil {
- fmt.Println(dat)
- } else {
- fmt.Println(err)
- }
- userJSONBytes, _ := json.Marshal(dat)
- if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
- res2.Infcode = Infcode
- res2.ErrMsg = resTwo10265.ErrMsg
- res2.Output = resTwo10265.Output
- res2.InfRefmsgid = resTwo10265.InfRefmsgid
- res2.RespondTime = resTwo10265.RespondTime
- res2.WarnInfo = resTwo10265.WarnInfo
- } else {
- res2.Infcode = 0
- res2.Output.Baseinfo.PsnNo = psn_info.PsnNo
- res2.Output.Baseinfo.Certno = patient.IdCardNo
- }
- } else if miConfig.MdtrtareaAdmvs == "421182" {
- res2.Infcode = 0
- res2.Output.Baseinfo.PsnNo = psn_info.PsnNo
- res2.Output.Baseinfo.Certno = patient.IdCardNo
-
- } else if miConfig.MdtrtareaAdmvs == "360399" {
- //res2.Infcode = 0
- //res2.Output.Baseinfo.PsnNo = psn_info.PsnNo
- //res2.Output.Baseinfo.Certno = patient.IdCardNo
- //result, request_log = service.JxybZY1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, ca, certificates, miConfig.Url, miConfig.AccessKey, "", patient.IdCardNo, "")
- if id_card_type == 1{
- bas := strings.Split(psn_info.CardInfo, "|")
- cardNumber := bas[3]
- result, request_log = service.Jxyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, cardNumber, "1", miConfig.Url, miConfig.AccessKey, "")
- saveLog(result, request_log, "1101", "人员基本信息获取")
-
- }else{
- cardNumber := psn_info.VerifyNumber
- result, request_log = service.Jxyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, cardNumber, "1", miConfig.Url, miConfig.AccessKey, psn_info.PsnName)
- saveLog(result, request_log, "1101", "人员基本信息获取")
-
- }
-
- } else {
- result, request_log, result_log = service.ZHGdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", certificates, name,admin_user_id)
- saveLog(result_log, request_log, "1101", "人员基本信息获取")
-
- }
-
- doctorInfo, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
- deviceNumber, _ := service.GetDeviceNumberByID(adm_bed, adminInfo.CurrentOrgId)
-
- if miConfig.MdtrtareaAdmvs != "150499" && miConfig.MdtrtareaAdmvs != "421182" {
- var dat map[string]interface{}
- if err := json.Unmarshal([]byte(result), &dat); err == nil {
- fmt.Println(dat)
- } else {
- fmt.Println(err)
- }
- userJSONBytes, _ := json.Marshal(dat)
- if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- }
-
- var infoStr string
- if miConfig.MdtrtareaAdmvs == "150499" {
- if id_card_type == 2 {
- Iinfos, _ := json.Marshal(res2.Output.Iinfo)
- infoStr = string(Iinfos)
- } else {
- infoStr = psn_info.Insuinfo
- }
- } else if miConfig.MdtrtareaAdmvs == "421182" {
- infoStr = psn_info.Insuinfo
-
- } else {
- Iinfos, _ := json.Marshal(res2.Output.Iinfo)
- infoStr = string(Iinfos)
- }
-
- var rf []*ResultFive
- json.Unmarshal([]byte(infoStr), &rf)
- var insutypes []*ResultFive
- var insutype string
- var is390 int = 0
- var is310 int = 0
-
- for _, item := range rf {
- if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
- insutypes = append(insutypes, item)
- }
- }
-
- if len(insutypes) == 1 {
- insutype = insutypes[0].Insutype
- //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
- } else {
- for _, i := range insutypes {
- if i.Insutype == "390" {
- is390 = 1
- }
-
- if i.Insutype == "310" {
- is310 = 1
- }
- }
- }
- if is390 == 1 {
- insutype = "390"
- }
-
- if is310 == 1 {
- insutype = "310"
- }
-
- if len(insutypes) == 0 {
- insutype = "310"
- }
-
- if len(insutypes) == 2 {
- insutype = strconv.FormatInt(social_type, 10)
- }
- //for _, item := range rf {
- // if item.Insutype == insutype {
- // insuplc_admdvs = item.InsuplcAdmdvs
- // }
- //}
-
- if res2.Infcode == 0 {
-
- //var insutypes []string
- //
- //var insutype string
- //var is390 int = 0
- //var is310 int = 0
- //for _, item := range res2.Output.Iinfo {
- // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
- // insutypes = append(insutypes, item.Insutype)
- // }
- //}
- //if len(insutypes) == 1 {
- // insutype = insutypes[0]
- //} else {
- // for _, i := range insutypes {
- // if i == "390" {
- // is390 = 1
- // }
- //
- // if i == "310" {
- // is310 = 1
- // }
- // }
- //}
- //if is390 == 1 {
- // insutype = "390"
- //}
- //if is310 == 1 {
- // insutype = "310"
- //}
- //
- //if len(insutypes) == 0 {
- // insutype = "310"
- //}
-
- if len(insuplc_admdvs) == 0 {
- insuplc_admdvs = miConfig.InsuplcAdmdvs
- }
-
- timestamp := time.Now().Unix()
- tempTime := time.Unix(timestamp, 0)
- timeFormat := tempTime.Format("20060102150405")
- chrgBchno := rand.Intn(100000) + 10000
- ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(id, 10)
-
- timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
- var struct2401 service.Struct2401
- //insutype = "310"
- struct2401.Insutype = insutype
- psn_info, _ := service.GetPsnByPatientId(patient.ID)
-
- if id_card_type == 1 {
- struct2401.MdtrtCertType = "03"
- bas := strings.Split(psn_info.CardInfo, "|")
- cardNumber := bas[2]
- struct2401.MdtrtCertNo = cardNumber
- struct2401.PsnNo = res2.Output.Baseinfo.PsnNo
- } else if id_card_type == 4 {
- struct2401.MdtrtCertType = "01"
- struct2401.MdtrtCertNo = psn_info.VerifyNumber
- struct2401.PsnNo = psn_info.PsnNo
- } else {
- struct2401.MdtrtCertType = "02"
- struct2401.MdtrtCertNo = id_card_no
- struct2401.PsnNo = res2.Output.Baseinfo.PsnNo
- }
- if miConfig.Code == "H15049901371" {
- if med_type == 14 {
- if insutype == "390" {
-
- struct2401.MedType = "9933"
-
- } else if insutype == "310" {
-
- struct2401.MedType = "990502"
- }
- } else if med_type == 11 {
- struct2401.MedType = "21"
- }
- } else {
- if med_type == 11 {
- struct2401.MedType = "21"
- med_type = 21
- } else {
- struct2401.MedType = strconv.FormatInt(int64(med_type), 10)
- }
- }
- struct2401.IptNo = ipt_otp_no
- struct2401.AtddrNo = doctorInfo.DoctorNumber
- struct2401.ChfpdrName = doctorInfo.UserName
- struct2401.AdmDiagDscr = diagnosisConfig[0].ClassName
- struct2401.AdmDeptCodg = strconv.FormatInt(int64(departmentInfo.ID), 10)
- struct2401.AdmDeptName = departmentInfo.Name
- struct2401.AdmBed = deviceNumber.Number
- struct2401.AdmBed = "待定"
-
- struct2401.DscgMaindiagName = diagnosisConfig[0].ClassName
- struct2401.DscgMaindiagCode = diagnosisConfig[0].CountryCode
- struct2401.Begntime = start_time
- struct2401.DiseCodg = sickConfig.CountryCode
- struct2401.DiseName = sickConfig.ClassName
-
- var dises []service.DiseinfoStruct
-
- for index, item := range diagnosisConfig {
- var dise service.DiseinfoStruct
-
- if id_card_type == 4 || id_card_type == 1 {
- dise.PsnNo = psn_info.PsnNo
- } else {
- dise.PsnNo = res2.Output.Baseinfo.PsnNo
-
- }
- dise.DiagType = "1"
- if index == 0 {
- dise.MaindiagFlag = "1"
- } else {
- dise.MaindiagFlag = "2"
- }
-
- dise.DiagSrtNo = strconv.FormatInt(int64(index), 10)
- dise.DiseDorName = doctorInfo.UserName
- dise.DiagCode = item.CountryCode
- dise.DiagName = item.ClassName
- dise.DiagDept = departmentInfo.Name
- dise.DiseDorNo = doctorInfo.DoctorNumber
- dise.DiagTime = timeFormatOne
-
- dises = append(dises, dise)
- }
- struct2401.Diseinfo = dises
-
- var result string
- var request_log string
- if miConfig.MdtrtareaAdmvs == "150499" {
- data := make(map[string]interface{})
- data["org_name"] = miConfig.OrgName
- data["doctor"] = role.UserName
- data["fixmedins_code"] = miConfig.Code
- data["insuplc_admdvs"] = insuplc_admdvs
- data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
- data["secret_key"] = miConfig.SecretKey
- data["struct_2401"] = struct2401
-
- var req *http.Request
- bytesData, _ := json.Marshal(data)
- req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2401", bytes.NewReader(bytesData))
- client := &http.Client{}
- resp, _ := client.Do(req)
- defer resp.Body.Close()
- body, ioErr := ioutil.ReadAll(resp.Body)
- if ioErr != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- var respJSON map[string]interface{}
- if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
- result_byte, _ := json.Marshal(respJSON)
- result = string(result_byte)
- } else if miConfig.MdtrtareaAdmvs == "421182" {
- data := make(map[string]interface{})
- data["org_name"] = miConfig.OrgName
- data["doctor"] = role.UserName
- data["fixmedins_code"] = miConfig.Code
- data["insuplc_admdvs"] = insuplc_admdvs
- data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
- data["secret_key"] = miConfig.SecretKey
- data["struct_2401"] = struct2401
-
- var req *http.Request
- bytesData, _ := json.Marshal(data)
- req, _ = http.NewRequest("POST", miConfig.Url +"hbyb/2401", bytes.NewReader(bytesData))
- client := &http.Client{}
- resp, _ := client.Do(req)
- defer resp.Body.Close()
- body, ioErr := ioutil.ReadAll(resp.Body)
- if ioErr != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- var respJSON map[string]interface{}
- if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
- //result, _ := json.Marshal(respJSON)
- //result = string(result_byte)
- //decoder := simplifiedchinese.GBK.NewDecoder()
- result_byte, _ := json.Marshal(respJSON)
- result = string(result_byte)
- //enc := mahonia.NewEncoder("gbk")
- //result = enc.ConvertString(string(result_byte))
- fmt.Println(string(result)) // 输出:中文
- } else if miConfig.MdtrtareaAdmvs == "360399" {
- if !strings.Contains(insuplc_admdvs, "3603") {
- if id_card_type == 1 {
- bas := strings.Split(psn_info.CardInfo, "|")
- card_sn := bas[3]
- card_no := bas[1]
- struct2401.Cardsn = card_sn
- struct2401.PsnCertType = "01"
- struct2401.Certno = card_no
- struct2401.PsnType = psn_type
- struct2401.PsnName = patient.Name
- }
- }
- result, request_log = service.Jxyb2401(struct2401, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, role.UserName, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, "", miConfig.AccessKey)
- saveLog(result, request_log, "2401", "入院登记")
-
- } else {
- //住院登记调用事前
- //var hisPrescription []*models.HisPrescription
- //res3101 := Check3101ForOne(c, patient.ID, struct2401, admin_user_id, "3", record_time, hisPrescription, res2, recordDateTime)
- var res3101 Result3101
- res3101.Infcode = 0
- if res3101.Infcode == 0 {
- result, request_log = service.ZHGdyb2401(struct2401, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, role.UserName, insuplc_admdvs, miConfig.MdtrtareaAdmvs)
- saveLog(result, request_log, "2401", "入院登记")
-
- } else {
- c.ServeSuccessJSON(map[string]interface{}{
- "failed_code": -10,
- "msg": res3101.ErrMsg,
- })
- return
- }
-
- }
- var dat map[string]interface{}
- if err := json.Unmarshal([]byte(result), &dat); err == nil {
- fmt.Println(dat)
- } else {
- fmt.Println(err)
- }
- userJSONBytes, _ := json.Marshal(dat)
- var res ResultThree
- var resThree10265 ResultThree10265
-
- if miConfig.Code == "H15049901371" {
-
- if err := json.Unmarshal(userJSONBytes, &resThree10265); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- Infcode, _ := strconv.ParseInt(resThree10265.Infcode, 10, 64)
- res.Infcode = Infcode
- res.ErrMsg = resThree10265.ErrMsg
- res.Output = resThree10265.Output
- res.InfRefmsgid = resThree10265.InfRefmsgid
- res.RespondTime = resThree10265.RespondTime
-
- } else {
-
- if err := json.Unmarshal(userJSONBytes, &res); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- }
-
- if res.Infcode == 0 {
- //result2 := service.Gdyb5301Two(res2.Output.Baseinfo.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
- //fmt.Println(result2)
- Iinfos, _ := json.Marshal(res2.Output.Iinfo)
- Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
- infoStr := string(Iinfos)
- idetinfoStr := string(Idetinfos)
- inHospital := &models.HisHospitalCheckRecord{
- PatientId: id,
- Name: name,
- MedicalTreatmentType: med_type,
- RecordDate: recordDateTime,
- IdCardNo: id_card_no,
- AdminUserId: admin_user_id,
- Departments: department,
- UserOrgId: adminInfo.CurrentOrgId,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- Number: res.Output.Result.MdtrtID,
- Doctor: doctor,
- PsnNo: res2.Output.Baseinfo.PsnNo,
- PsnCertType: res2.Output.Baseinfo.PsnCertType,
- Certno: res2.Output.Baseinfo.Certno,
- PsnName: res2.Output.Baseinfo.PsnName,
- Gend: res2.Output.Baseinfo.Gend,
- Naty: res2.Output.Baseinfo.Naty,
- MedType: med_type,
- InsutypeType: insutype,
- Iinfo: infoStr,
- Idetinfo: idetinfoStr,
- IptOtpNo: ipt_otp_no,
- AdmBed: adm_bed,
- IdCardType: id_card_type,
- Diagnosis: diagnosis_ids,
- SickType: sick_type,
- MdtrtCertType: "02",
- InHosptialTime: start_time,
- OutHosptialTime: "",
- InHospitalStatus: 1,
- Certificates: certificates,
- Phone: phone,
- BalanceAccountsType: balance_accounts_type,
- PsnType: psn_type,
- InsuplcAdmdvs: insuplc_admdvs,
- }
- service.CreateHospitalRecord(inHospital)
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "办理入院成功",
- "info": inHospital,
- })
-
- } else {
- c.ServeSuccessJSON(map[string]interface{}{
- "failed_code": -10,
- "msg": res.ErrMsg,
- })
- }
-
- } else {
- c.ServeSuccessJSON(map[string]interface{}{
- "failed_code": -10,
- "msg": res2.ErrMsg,
- })
- return
- }
-
- }
- func (this *ZHHisApiController) GetZHOutHospitalCheck() {
- id, _ := this.GetInt64("id")
- patient_id, _ := this.GetInt64("patient_id")
- admin_user_id, _ := this.GetInt64("admin_user_id")
- record_time := this.GetString("record_time")
- out_time := this.GetString("out_time")
-
- adminInfo := this.GetAdminUserInfo()
- miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
- role, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
-
- //service.getpre
-
- record, _ := service.GetInHospitalRecord(id)
- if record.ID == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInHospitalNoExistDataException)
- return
- }
- infos, _ := service.FindLastPatientPrescriptionInfoTwo2(this.GetAdminUserInfo().CurrentOrgId, patient_id, strings.Split(record.InHosptialTime, " ")[0], strings.Split(out_time, " ")[0])
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordDateTime := theTime.Unix()
-
- //var patient service.Patients
- //if patient_id == 0 {
- // patient, _ = service.GetPatientByIDCard(record.IdCardNo, adminInfo.CurrentOrgId)
- //} else {
- // patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
- //}
-
- for _, item := range infos {
-
- record.Diagnosis = record.Diagnosis + "," + item.Diagnosis
- }
- diagnosis_ids_arr := strings.Split(record.Diagnosis, ",")
- fmt.Println(diagnosis_ids_arr)
- diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
-
- fmt.Println(diagnosis_ids_arr)
-
- diagnosisConfig, _ := service.FindDiagnoseByIds(diagnosis_ids_arr)
- departmentInfo, _ := service.GetDepartMentDetail(record.Departments)
- doctorInfo, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, record.Doctor)
- //deviceNumber, _ := service.GetDeviceNumberByID(record.AdmBed, adminInfo.CurrentOrgId)
- sickConfig, _ := service.FindSickById(record.SickType)
-
- var struct2402 service.Struct2402
- timestamp := time.Now().Unix()
- tempTime := time.Unix(timestamp, 0)
- //timeFormat := tempTime.Format("20060102150405")
- timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
-
- struct2402.PsnNo = record.PsnNo
- struct2402.Insutype = record.InsutypeType
- struct2402.DscgWay = "1"
- struct2402.Endtime = out_time
- struct2402.DscgDeptName = departmentInfo.Number
- struct2402.DscgDeptCodg = strconv.FormatInt(int64(departmentInfo.ID), 10)
- struct2402.MdtrtId = record.Number
-
- var dises []service.Diseinfo2402Struct
-
- for index, item := range diagnosisConfig {
- var dise service.Diseinfo2402Struct
-
- dise.PsnNo = record.PsnNo
-
- if index == 0 {
- dise.DiagType = "1"
- dise.MaindiagFlag = "1"
- } else {
- dise.DiagType = "1"
- dise.MaindiagFlag = "0"
- }
-
- dise.MdtrtId = record.Number
- dise.DiagSrtNo = strconv.FormatInt(int64(index), 10)
- dise.DiseDorName = doctorInfo.UserName
- dise.DiagCode = item.CountryCode
- dise.DiagName = item.ClassName
- dise.DiagDept = departmentInfo.Name
- dise.DiseDorNo = doctorInfo.DoctorNumber
- dise.DiagTime = timeFormatOne
-
- dises = append(dises, dise)
- }
- struct2402.Diseinfo = dises
- struct2402.DiseName = sickConfig.ClassName
- struct2402.DiseCode = sickConfig.CountryCode
-
- var result string
- var request_log string
- if miConfig.MdtrtareaAdmvs == "150499" {
- data := make(map[string]interface{})
- data["org_name"] = miConfig.OrgName
- data["doctor"] = role.UserName
- data["fixmedins_code"] = miConfig.Code
- data["insuplc_admdvs"] = record.InsuplcAdmdvs
- data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
- data["secret_key"] = miConfig.SecretKey
- data["struct_2402"] = struct2402
- var req *http.Request
- bytesData, _ := json.Marshal(data)
- req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2402", bytes.NewReader(bytesData))
- client := &http.Client{}
- resp, _ := client.Do(req)
- defer resp.Body.Close()
- body, ioErr := ioutil.ReadAll(resp.Body)
- if ioErr != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- var respJSON map[string]interface{}
- if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
- result_byte, _ := json.Marshal(respJSON)
- result = string(result_byte)
- } else if miConfig.MdtrtareaAdmvs == "421182" {
- data := make(map[string]interface{})
- data["org_name"] = miConfig.OrgName
- data["doctor"] = role.UserName
- data["fixmedins_code"] = miConfig.Code
- data["insuplc_admdvs"] = record.InsuplcAdmdvs
- data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
- data["secret_key"] = miConfig.SecretKey
- data["struct_2402"] = struct2402
- var req *http.Request
- bytesData, _ := json.Marshal(data)
- req, _ = http.NewRequest("POST", miConfig.Url +"hbyb/2402", bytes.NewReader(bytesData))
- client := &http.Client{}
- resp, _ := client.Do(req)
- defer resp.Body.Close()
- body, ioErr := ioutil.ReadAll(resp.Body)
- if ioErr != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- var respJSON map[string]interface{}
- if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
- result_byte, _ := json.Marshal(respJSON)
- result = string(result_byte)
- } else if miConfig.MdtrtareaAdmvs == "360399" {
- result, request_log = service.Jxyb2402(struct2402, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, role.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, "", miConfig.AccessKey)
- saveLog(result, request_log, "2402", "出院")
-
- } else {
- result, request_log = service.ZHGdyb2402(struct2402, miConfig.OrgName, role.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
- saveLog(result, request_log, "2402", "出院")
- }
-
- var dat map[string]interface{}
- if err := json.Unmarshal([]byte(result), &dat); err == nil {
- fmt.Println(dat)
- } else {
- fmt.Println(err)
- }
- userJSONBytes, _ := json.Marshal(dat)
- var res ResultEmpty
- var resEmpty10265 ResultEmpty10265
-
- if miConfig.Code == "H15049901371" {
-
- if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
- res.Infcode = Infcode
- res.RespondTime = resEmpty10265.RespondTime
- res.ErrMsg = resEmpty10265.ErrMsg
- res.Output = resEmpty10265.Output
- res.WarnMsg = resEmpty10265.WarnMsg
-
- } else {
- if err := json.Unmarshal(userJSONBytes, &res); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- }
-
- if res.Infcode == 0 {
- record.OutHospitalStatus = 1
- record.OutHosptialTime = struct2402.Endtime
- record.OutWay = 1
- service.CreateHospitalRecord(&record)
-
- orders, _ := service.GetHisOrderInfoByNumberFour(record.Number)
- var total float64
- for _, item := range orders {
- total = total + item.DetItemFeeSumamt
- }
-
- order := &models.HisOrder{
- UserOrgId: adminInfo.CurrentOrgId,
- HisPatientId: record.ID,
- PatientId: record.PatientId,
- SettleAccountsDate: recordDateTime,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- Status: 1,
- Number: record.Number,
- Infcode: 0,
- WarnMsg: "",
- Cainfo: "",
- ErrMsg: "",
- RespondTime: "",
- InfRefmsgid: "",
- OrderStatus: 1,
- MdtrtId: record.Number,
- IsMedicineInsurance: 1,
- PType: 1,
- MedfeeSumamt: total,
- }
- err = service.CreateOrder(order)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "出院成功",
- })
-
- } else {
- this.ServeSuccessJSON(map[string]interface{}{
- "failed_code": -10,
- "msg": res.ErrMsg,
- })
- }
-
- }
- func (c *ZHHisApiController) Get4102() {
- order_id, _ := c.GetInt64("order_id")
- admin_user_id, _ := c.GetInt64("admin_user_id")
- stas_type := c.GetString("stas_type")
- adminUser := c.GetAdminUserInfo()
- order, _ := service.GetHisOrderByID(order_id)
- miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
- var user_name string
- role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
- if role.ID == 0 {
- user_name = "管理员"
- } else {
- user_name = role.UserName
- }
- baseParams := models.BaseParams{
- SecretKey: miConfig.SecretKey,
- FixmedinsCode: miConfig.Code,
- InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
- MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
- OrgName: miConfig.OrgName,
- Doctor: user_name,
- RequestUrl: miConfig.Url,
- AccessKey: miConfig.AccessKey,
- }
-
- businessParams := models.BusinessParams{
- PsnNo: order.PsnNo,
- MdtrtId: order.MdtrtId,
- SetlId: order.SetlId,
- StasType: stas_type,
- }
-
- api := "http://172.16.13.254:9532/" + "nmyb/4102?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
- "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
- "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&stas_type=" + stas_type
- resp, requestErr := http.Get(api)
- if requestErr != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- body, ioErr := ioutil.ReadAll(resp.Body)
- if ioErr != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- var respJSON map[string]interface{}
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
- result, _ := json.Marshal(respJSON)
- fmt.Println("log")
- fmt.Println(string(result))
-
- var res2 ResultSix
- var resEmpty10265 ResultEmpty10265
-
- if err := json.Unmarshal(result, &resEmpty10265); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
- res2.Infcode = Infcode
- res2.RespondTime = resEmpty10265.RespondTime
- res2.ErrMsg = resEmpty10265.ErrMsg
- res2.Output = resEmpty10265.Output
- res2.WarnMsg = resEmpty10265.WarnMsg
-
- if res2.Infcode == 0 {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "确认成功",
- })
-
- } else {
- c.ServeSuccessJSON(map[string]interface{}{
- "failed_code": -10,
- "msg": res2.ErrMsg,
- })
-
- }
-
- }
- func (c *ZHHisApiController) Get4103() {
- order_id, _ := c.GetInt64("order_id")
- admin_user_id, _ := c.GetInt64("admin_user_id")
- stas_type := c.GetString("stas_type")
- adminUser := c.GetAdminUserInfo()
- order, _ := service.GetHisOrderByID(order_id)
- miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
- var user_name string
- role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
- if role.ID == 0 {
- user_name = "管理员"
- } else {
- user_name = role.UserName
- }
- baseParams := models.BaseParams{
- SecretKey: miConfig.SecretKey,
- FixmedinsCode: miConfig.Code,
- InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
- MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
- OrgName: miConfig.OrgName,
- Doctor: user_name,
- RequestUrl: miConfig.Url,
- AccessKey: miConfig.AccessKey,
- }
-
- businessParams := models.BusinessParams{
- PsnNo: order.PsnNo,
- MdtrtId: order.MdtrtId,
- SetlId: order.SetlId,
- StasType: stas_type,
- }
-
- api := "http://172.16.13.254:9532/" + "nmyb/4103?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
- "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
- "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&stas_type=" + stas_type
- resp, requestErr := http.Get(api)
- if requestErr != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- body, ioErr := ioutil.ReadAll(resp.Body)
- if ioErr != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- var respJSON map[string]interface{}
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
- result, _ := json.Marshal(respJSON)
- fmt.Println("log")
- fmt.Println(string(result))
- var res2 ResultSix
- var resEmpty10265 ResultEmpty10265
-
- if err := json.Unmarshal(result, &resEmpty10265); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
- res2.Infcode = Infcode
- res2.RespondTime = resEmpty10265.RespondTime
- res2.ErrMsg = resEmpty10265.ErrMsg
- res2.Output = resEmpty10265.Output
- res2.WarnMsg = resEmpty10265.WarnMsg
- if res2.Infcode == 0 {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": string(result),
- })
- } else {
- c.ServeSuccessJSON(map[string]interface{}{
- "failed_code": -10,
- "msg": res2.ErrMsg,
- })
- }
- }
-
- //func (c *ZHHisApiController) Get4104() {
- // order_id, _ := c.GetInt64("order_id")
- // admin_user_id, _ := c.GetInt64("admin_user_id")
- // adminUser := c.GetAdminUserInfo()
- // order, _ := service.GetHisOrderByID(order_id)
- // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
- // var user_name string
- // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
- // if role.ID == 0 {
- // user_name = "管理员"
- // } else {
- // user_name = role.UserName
- // }
- // baseParams := models.BaseParams{
- // SecretKey: miConfig.SecretKey,
- // FixmedinsCode: miConfig.Code,
- // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
- // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
- // OrgName: miConfig.OrgName,
- // Doctor: user_name,
- // RequestUrl: miConfig.Url,
- // AccessKey: miConfig.AccessKey,
- // }
- //
- // businessParams := models.BusinessParams{
- // PsnNo: order.PsnNo,
- // MdtrtId: order.MdtrtId,
- // SetlId: order.SetlId,
- // }
- //
- // api := "http://172.16.13.254:9532/" + "nmyb/4104?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
- // "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
- // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&stas_type=" + stas_type
- // resp, requestErr := http.Get(api)
- // if requestErr != nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // }
- // body, ioErr := ioutil.ReadAll(resp.Body)
- // if ioErr != nil {
- // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // }
- // var respJSON map[string]interface{}
- // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
- // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // }
- //
- // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
- // result, _ := json.Marshal(respJSON)
- // fmt.Println("log")
- // fmt.Println(string(result))
- //
- // var res2 ResultSix
- // var resEmpty10265 ResultEmpty10265
- //
- // if err := json.Unmarshal(result, &resEmpty10265); err != nil {
- // utils.ErrorLog("解析失败:%v", err)
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // }
- // Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
- // res2.Infcode = Infcode
- // res2.RespondTime = resEmpty10265.RespondTime
- // res2.ErrMsg = resEmpty10265.ErrMsg
- // res2.Output = resEmpty10265.Output
- // res2.WarnMsg = resEmpty10265.WarnMsg
- //
- // if res2.Infcode == 0 {
- // c.ServeSuccessJSON(map[string]interface{}{
- // "msg": "确认成功",
- // })
- //
- // } else {
- // c.ServeSuccessJSON(map[string]interface{}{
- // "failed_code": -10,
- // "msg": res2.ErrMsg,
- // })
- //
- // }
- //
- //}
-
- func (c *ZHHisApiController) GetSettleInfo() {
- order_id, _ := c.GetInt64("order_id")
- patient_id, _ := c.GetInt64("patient_id")
- in_hospital_id, _ := c.GetInt64("in_hospital_id")
- admin_user_id, _ := c.GetInt64("admin_user_id")
- pay_way, _ := c.GetInt64("pay_way")
- pay_price, _ := c.GetFloat("pay_price")
- pay_card_no := c.GetString("pay_card_no")
- discount_price, _ := c.GetFloat("discount_price")
- preferential_price, _ := c.GetFloat("preferential_price")
- reality_price, _ := c.GetFloat("reality_price")
- found_price, _ := c.GetFloat("found_price")
- medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
- private_price, _ := c.GetFloat("private_price")
- fapiao_code := c.GetString("fapiao_code")
- fapiao_number := c.GetString("fapiao_number")
-
- record, _ := service.GetInHospitalRecord(in_hospital_id)
- miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
- roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
- order, _ := service.GetHisOrderByID(order_id)
-
- //dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
- //tmp_decimal := c.GetString("tmp_decimal")
- //var decimal float64 //本次使用的押金
-
- dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
- tmp_decimal := c.GetString("tmp_decimal")
- var decimal float64 //本次使用的押金
- var errmsg error
-
- if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
- return
- }
- if len(tmp_decimal) > 0 {
- if tmp_decimal[0] == 45 {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
- return
- }
- }
- tt, errs := strconv.ParseFloat(tmp_decimal, 64)
- if errs != nil {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金金额错误")
- return
- }
- decimal = tt
-
- var rf []*ResultFive
- json.Unmarshal([]byte(record.Iinfo), &rf)
- chrg_bchno := order.Number
- cert_no := record.Certno
- if record.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- if record.InHospitalStatus == 1 && record.OutHospitalStatus == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHospitalNoExistDataException)
- return
- }
- if record.IdCardType == 1 {
- } else {
- cert_no = record.Certno
- }
- var result string
- var src_resquest string
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record.InHosptialTime, loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordStartDateTime := theTime.Unix()
-
- theTimeEnd, err := time.ParseInLocation(timeLayout+" 15:04:05", record.OutHosptialTime, loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordEndDateTime := theTimeEnd.Unix()
-
- prescriptions, _ := service.GetZHSettleMonthHisPrescription(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordStartDateTime, recordEndDateTime)
-
- var total float64
- for _, item := range prescriptions {
- if item.Type == 1 { //药品
- for _, subItem := range item.HisDoctorAdviceInfo {
- total = total + (subItem.Price * subItem.PrescribingNumber)
- }
- }
- if item.Type == 2 { //项目
- for _, subItem := range item.HisPrescriptionProject {
- cnt, _ := strconv.ParseFloat(subItem.Count, 64)
- total = total + (subItem.Price * cnt)
- }
- }
- }
- //allTotal := fmt.Sprintf("%.2f", total)
-
- var allTotal string
- if record.OutHospitalStatus == 0 && order.ID == 0 {
- orders, _ := service.GetHisOrderInfoByNumberFour(record.Number)
- var total float64
- for _, item := range orders {
- total = total + item.DetItemFeeSumamt
- }
- allTotal = fmt.Sprintf("%.4f", total)
-
- } else {
-
- allTotal = fmt.Sprintf("%.4f", order.MedfeeSumamt)
-
- }
-
- if miConfig.MdtrtareaAdmvs == "150499" {
-
- psn_info, _ := service.GetPsnByPatientId(patient_id)
- mdtrt_cert_no := ""
- if record.IdCardType == 1 {
- bas := strings.Split(psn_info.CardInfo, "|")
- cardNumber := bas[2]
- mdtrt_cert_no = cardNumber
-
- } else {
- mdtrt_cert_no = record.Certno
- }
- var acct_used_flag string
- if pay_way == 4 {
- acct_used_flag = "1"
- } else {
- acct_used_flag = "0"
- }
-
- if pay_way == 6 {
- mdtrt_cert_no = psn_info.VerifyNumber
- acct_used_flag = "1"
- record.IdCardType = 4
- } else {
- acct_used_flag = "0"
- }
-
- fmt.Println(mdtrt_cert_no)
- fmt.Println(acct_used_flag)
- fmt.Println(record.IdCardType)
-
- //请求内网数据
- api := "http://172.16.13.254:9532/" + "nmyb/2304?psn_no=" + record.PsnNo + "&mdtrt_id=" + record.Number + "&chrg_bchno=" + chrg_bchno +
- "&insutype_type=" + record.InsutypeType + "&total=" + allTotal +
- "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
- "&insuplc_admdvs=" + record.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(record.IdCardType, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(record.Certificates, 10) + "&name=" + record.Name + "&cert_no=" + mdtrt_cert_no + "&fapiao_number=" + fapiao_number + "&acct_used_flag=" + acct_used_flag
- resp, requestErr := http.Get(api)
- if requestErr != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- body, ioErr := ioutil.ReadAll(resp.Body)
- if ioErr != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- var respJSON map[string]interface{}
-
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
- result_byte, _ := json.Marshal(respJSON)
- result = string(result_byte)
-
- } else if miConfig.MdtrtareaAdmvs == "421182" {
-
- psn_info, _ := service.GetPsnByPatientId(patient_id)
- mdtrt_cert_no := ""
- if record.IdCardType == 1 {
- bas := strings.Split(psn_info.CardInfo, "|")
- cardNumber := bas[2]
- mdtrt_cert_no = cardNumber
-
- } else {
- mdtrt_cert_no = record.Certno
- }
- var acct_used_flag string
- if pay_way == 4 {
- acct_used_flag = "1"
- } else {
- acct_used_flag = "0"
- }
-
- if pay_way == 6 {
- mdtrt_cert_no = psn_info.VerifyNumber
- acct_used_flag = "1"
- record.IdCardType = 4
- } else {
- acct_used_flag = "0"
- }
-
- fmt.Println(mdtrt_cert_no)
- fmt.Println(acct_used_flag)
- fmt.Println(record.IdCardType)
-
- //请求内网数据
- api := miConfig.Url + "hbyb/2304?psn_no=" + record.PsnNo + "&mdtrt_id=" + record.Number + "&chrg_bchno=" + chrg_bchno +
- "&insutype_type=" + record.InsutypeType + "&total=" + allTotal +
- "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
- "&insuplc_admdvs=" + record.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(record.IdCardType, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(record.Certificates, 10) + "&name=" + record.Name + "&cert_no=" + mdtrt_cert_no + "&fapiao_number=" + fapiao_number + "&acct_used_flag=" + acct_used_flag
- resp, requestErr := http.Get(api)
- if requestErr != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- body, ioErr := ioutil.ReadAll(resp.Body)
- if ioErr != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- var respJSON map[string]interface{}
-
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
- result_byte, _ := json.Marshal(respJSON)
- result = string(result_byte)
-
- } else if miConfig.MdtrtareaAdmvs == "360399" {
- psn_info, _ := service.GetPsnByPatientId(patient_id)
- if len(psn_info.CardInfo) > 0 && len(psn_info.VerifyNumber) == 0{
- cert_no = record.Certno
- } else if len(psn_info.CardInfo) == 0 && len(psn_info.VerifyNumber) > 0{
- cert_no = psn_info.VerifyNumber
- }
- //result, src_resquest = service.Jxyb2304(record.PsnNo, record.Number, cert_no, record.InsutypeType, allTotal, record.Certificates, record.IdCardType, "", miConfig.SecretKey, miConfig.OrgName, miConfig.Code, roles.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, "", miConfig.AccessKey, "", "1")
-
- if strings.Contains(record.InsuplcAdmdvs, "3603") {
- bas := strings.Split(psn_info.CardInfo, "|")
- card_sn := bas[3]
-
- result, src_resquest = service.Jxyb2304(record.PsnNo, record.Number, cert_no, record.InsutypeType, allTotal, record.Certificates, record.IdCardType, "", miConfig.SecretKey, miConfig.OrgName, miConfig.Code, roles.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, "", miConfig.AccessKey, "", "1",card_sn,"","","","")
- saveLog(result, src_resquest, "2304", "住院结算")
-
- //if record.IdCardType == 1 {
- //basNumber := bas[2]
- // result, src_resquest = service.Jxyb2303(record.PsnNo, record.Number, cert_no, record.InsutypeType, allTotal, record.Certificates, record.IdCardType, "", miConfig.SecretKey, miConfig.OrgName, miConfig.Code, roles.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, "", miConfig.AccessKey, card_sn, record.PsnType, record.PsnCertType, record.IdCardNo, record.Name)
- // saveLog(result, src_resquest, "2303", "住院预结算")
- //}
- }else{
- bas := strings.Split(psn_info.CardInfo, "|")
- card_sn := bas[3]
- result, src_resquest = service.Jxyb2304a(record.PsnNo, record.Number, cert_no, record.InsutypeType, allTotal, record.Certificates, record.IdCardType, "", miConfig.SecretKey, miConfig.OrgName, miConfig.Code, roles.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, "", miConfig.AccessKey, "", "1",card_sn,record.PsnType,record.PsnCertType,record.IdCardNo,record.Name)
- //result, src_resquest = service.Jxyb2303(record.PsnNo, record.Number, cert_no, record.InsutypeType, allTotal, record.Certificates, record.IdCardType, "", miConfig.SecretKey, miConfig.OrgName, miConfig.Code, roles.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, "", miConfig.AccessKey,"",record.PsnType,record.PsnCertType,record.IdCardNo,record.Name)
- saveLog(result, src_resquest, "2303", "住院预结算")
-
-
- }
-
-
-
- } else {
- result3101 := Check3102(c, record.PatientId, record.ID, admin_user_id, "8", order.ID)
-
- if result3101.Infcode == 0 {
- if len(result3101.Output.Result) > 0 {
- var errMsgs []string
- for _, item := range result3101.Output.Result {
- errMsgs = append(errMsgs, item.VolaCont)
-
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "failed_code": -10,
- "msg": errMsgs,
- })
- return
- } else {
- result, src_resquest = service.ZHGdyb2304(record.PsnNo, record.Number, chrg_bchno, cert_no, record.InsutypeType, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "0", record.IdCardType, 0, 0, 0, 0, record.Certificates, "", "1")
- saveLog(result, src_resquest, "2304", "住院结算")
- }
- } else {
- c.ServeSuccessJSON(map[string]interface{}{
- "failed_code": -10,
- "msg": result3101.ErrMsg,
- })
- return
- }
-
- }
-
- var dat map[string]interface{}
- if err := json.Unmarshal([]byte(result), &dat); err == nil {
- fmt.Println(dat)
- } else {
- fmt.Println(err)
- }
- userJSONBytes, _ := json.Marshal(dat)
- var res ResultSeven
- var resSeven10265 ResultSeven10265
- if miConfig.Code == "H15049901371" {
- if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- Infcode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
- res.Infcode = Infcode
- res.InfRefmsgid = resSeven10265.InfRefmsgid
- res.RespondTime = resSeven10265.RespondTime
- res.ErrMsg = resSeven10265.ErrMsg
- res.Output = resSeven10265.Output
- res.WarnMsg = resSeven10265.WarnMsg
- res.Cainfo = resSeven10265.Cainfo
-
- } else {
- if err := json.Unmarshal(userJSONBytes, &res); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- }
-
- if res.Infcode != 0 {
- errlog := &models.HisOrderError{
- UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- Number: chrg_bchno,
- ErrMsg: res.ErrMsg,
- Status: 1,
- PatientId: patient_id,
- RecordTime: time.Now().Unix(),
- Stage: 6,
- }
- service.CreateErrMsgLog(errlog)
- c.ServeSuccessJSON(map[string]interface{}{
- "failed_code": -10,
- "msg": res.ErrMsg,
- })
- return
- } else {
- //order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
- order.OrderStatus = 2
- order.DiscountPrice = discount_price
- order.MedicalInsurancePrice = medical_insurance_price
- order.FaPiaoNumber = fapiao_number
- order.FaPiaoCode = fapiao_code
- order.PayWay = pay_way
- order.PayPrice = pay_price
- order.PayCardNo = pay_card_no
- order.PreferentialPrice = preferential_price
- order.RealityPrice = reality_price
- order.FoundPrice = found_price
- order.PrivatePrice = private_price
- order.MdtrtId = res.Output.Setlinfo.MdtrtID
- order.SetlId = res.Output.Setlinfo.SetlID
- order.PsnNo = res.Output.Setlinfo.PsnNo
- order.PsnName = res.Output.Setlinfo.PsnName
- order.PsnCertType = res.Output.Setlinfo.PsnCertType
- order.Certno = res.Output.Setlinfo.Certno
- order.Gend = res.Output.Setlinfo.Gend
- order.Naty = res.Output.Setlinfo.Naty
- order.Age = res.Output.Setlinfo.Age
- order.Insutype = res.Output.Setlinfo.Insutype
- order.PsnType = res.Output.Setlinfo.PsnType
- order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
- order.SetlTime = res.Output.Setlinfo.SetlTime
- order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
- if res.Output.Setlinfo.MedType == "140104" {
-
- order.MedType = "14"
-
- } else {
-
- order.MedType = res.Output.Setlinfo.MedType
-
- }
- order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
- order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
- order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
- order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
- order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
- order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
- order.HifpPay = res.Output.Setlinfo.HifpPay
- order.CvlservPay = res.Output.Setlinfo.CvlservPay
- order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
- order.HifesPay = res.Output.Setlinfo.HifesPay
- order.HifobPay = res.Output.Setlinfo.HifobPay
- order.MafPay = res.Output.Setlinfo.MafPay
- order.OthPay = res.Output.Setlinfo.OthPay
- order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
- order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
- order.AcctPay = res.Output.Setlinfo.AcctPay
- order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
- order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
- order.Balc = res.Output.Setlinfo.Balc
- order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
- order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
- order.ClrOptins = res.Output.Setlinfo.ClrOptins
- order.ClrWay = res.Output.Setlinfo.ClrWay
- order.Creator = order.Creator
- order.Modify = roles.AdminUserId
- order.RequestLog = src_resquest
- setlDetail, _ := json.Marshal(res.Output.Setldetail)
- detailStr := string(setlDetail)
- order.SetlDetail = detailStr
- err := service.UpdataOrderStatusTwo(chrg_bchno, c.GetAdminUserInfo().CurrentOrgId)
- err = service.UpDateOrder(order)
- if err == nil {
- //判断是否使用了押金
- if dec_way == "true" {
- tmpstring := strconv.FormatInt(order.ID, 10)
- order.Decimal = decimal
- err = service.UpDateOrder(order)
- //扣押金
- errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, patient_id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
- if errmsg != nil {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
- //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
- return
- }
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "结算成功",
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
- return
- }
- }
-
- }
- func (c *ZHHisApiController) GetPreSettleInfo() {
- order_id, _ := c.GetInt64("order_id")
- patient_id, _ := c.GetInt64("patient_id")
- in_hospital_id, _ := c.GetInt64("in_hospital_id")
- admin_user_id, _ := c.GetInt64("admin_user_id")
-
- record, _ := service.GetInHospitalRecord(in_hospital_id)
- miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
- roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
- order, _ := service.GetHisOrderByID(order_id)
-
- var allTotal string
- if record.OutHospitalStatus == 0 && order.ID == 0 {
-
- orders, _ := service.GetHisOrderInfoByNumberFour(record.Number)
- var total float64
- for _, item := range orders {
- total = total + item.DetItemFeeSumamt
- }
- allTotal = fmt.Sprintf("%.2f", total)
-
- } else {
-
- allTotal = fmt.Sprintf("%.2f", order.MedfeeSumamt)
-
- }
-
- var rf []*ResultFive
- json.Unmarshal([]byte(record.Iinfo), &rf)
- chrg_bchno := order.Number
- cert_no := record.Certno
- if record.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- //if record.InHospitalStatus == 1 && record.OutHospitalStatus == 0 {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHospitalNoExistDataException)
- // return
- //}
- psn_info, _ := service.GetPsnByPatientId(patient_id)
-
- if record.IdCardType == 1 {
- bas := strings.Split(psn_info.CardInfo, "|")
- cardNumber := bas[2]
- cert_no = cardNumber
-
- } else if record.IdCardType == 4 {
- cert_no = psn_info.VerifyNumber
-
- } else {
- cert_no = record.Certno
- }
- var result string
- var src_resquest string
-
- if miConfig.MdtrtareaAdmvs == "150499" {
- //请求内网数据
- api := "http://172.16.13.254:9532/" + "nmyb/2303?psn_no=" + record.PsnNo + "&mdtrt_id=" + record.Number + "&chrg_bchno=" + chrg_bchno +
- "&insutype_type=" + record.InsutypeType + "&total=" + allTotal +
- "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
- "&insuplc_admdvs=" + record.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(record.IdCardType, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(record.Certificates, 10) + "&name=" + record.Name + "&cert_no=" + cert_no
- resp, requestErr := http.Get(api)
- if requestErr != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- body, ioErr := ioutil.ReadAll(resp.Body)
- if ioErr != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- var respJSON map[string]interface{}
-
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
- result_byte, _ := json.Marshal(respJSON)
- result = string(result_byte)
-
- }else if miConfig.MdtrtareaAdmvs == "421182" {
- //请求内网数据
- api := miConfig.Url + "hbyb/2303?psn_no=" + record.PsnNo + "&mdtrt_id=" + record.Number + "&chrg_bchno=" + chrg_bchno +
- "&insutype_type=" + record.InsutypeType + "&total=" + allTotal +
- "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
- "&insuplc_admdvs=" + record.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(record.IdCardType, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(record.Certificates, 10) + "&name=" + record.Name + "&cert_no=" + cert_no
- resp, requestErr := http.Get(api)
- if requestErr != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- body, ioErr := ioutil.ReadAll(resp.Body)
- if ioErr != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- var respJSON map[string]interface{}
-
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
- result_byte, _ := json.Marshal(respJSON)
- result = string(result_byte)
-
- } else if miConfig.MdtrtareaAdmvs == "360399" {
- if !strings.Contains(record.InsuplcAdmdvs, "3603") {
- if record.IdCardType == 1 {
- bas := strings.Split(psn_info.CardInfo, "|")
- //basNumber := bas[2]
- card_sn := bas[3]
- result, src_resquest = service.Jxyb2303(record.PsnNo, record.Number, cert_no, record.InsutypeType, allTotal, record.Certificates, record.IdCardType, "", miConfig.SecretKey, miConfig.OrgName, miConfig.Code, roles.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, "", miConfig.AccessKey, card_sn, record.PsnType, record.PsnCertType, record.IdCardNo, record.Name)
- saveLog(result, src_resquest, "2303", "住院预结算")
- }
- }else{
- result, src_resquest = service.Jxyb2303(record.PsnNo, record.Number, cert_no, record.InsutypeType, allTotal, record.Certificates, record.IdCardType, "", miConfig.SecretKey, miConfig.OrgName, miConfig.Code, roles.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, "", miConfig.AccessKey,"",record.PsnType,record.PsnCertType,record.IdCardNo,record.Name)
- saveLog(result, src_resquest, "2303", "住院预结算")
-
-
- }
-
-
- } else {
- if record.OutHospitalStatus == 1 && order.ID > 0 { //出院的情况下,再去做事中监测
- result3101 := Check3102(c, record.PatientId, record.ID, admin_user_id, "8", order.ID)
- if result3101.Infcode == 0 {
- if len(result3101.Output.Result) > 0 {
- var errMsgs []string
- for _, item := range result3101.Output.Result {
- errMsgs = append(errMsgs, item.VolaCont)
-
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "failed_code": -10,
- "msg": errMsgs,
- })
- return
- } else {
- result, src_resquest = service.ZHGdyb2303(record.PsnNo, record.Number, chrg_bchno, cert_no, record.InsutypeType, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "0", record.IdCardType, 0, 0, 0, 0, record.Certificates)
- saveLog(result, src_resquest, "2303", "住院预结算")
- }
- } else {
- c.ServeSuccessJSON(map[string]interface{}{
- "failed_code": -10,
- "msg": result3101.ErrMsg,
- })
- return
- }
- } else {
- result, src_resquest = service.ZHGdyb2303(record.PsnNo, record.Number, chrg_bchno, cert_no, record.InsutypeType, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "0", record.IdCardType, 0, 0, 0, 0, record.Certificates)
- saveLog(result, src_resquest, "2303", "住院预结算")
-
- }
- }
- var dat map[string]interface{}
- if err := json.Unmarshal([]byte(result), &dat); err == nil {
- fmt.Println(dat)
- } else {
- fmt.Println(err)
- }
- userJSONBytes, _ := json.Marshal(dat)
-
- var res2 ResultSevenTwo
- var res ResultSeven
- var resSeven10265 ResultSeven10265
-
- if miConfig.MdtrtareaAdmvs == "360399" {
- if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- if res2.Infcode != 0 {
- errlog := &models.HisOrderError{
- UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- Number: chrg_bchno,
- ErrMsg: res.ErrMsg,
- Status: 1,
- PatientId: patient_id,
- RecordTime: time.Now().Unix(),
- Stage: 6,
- }
- service.CreateErrMsgLog(errlog)
- c.ServeSuccessJSON(map[string]interface{}{
- "failed_code": -10,
- "msg": res.ErrMsg,
- })
- return
- } else {
- //order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
- order.OrderStatus = 1
- order.MdtrtId = res2.Output.Setlinfo.MdtrtID
- order.SetlId = res2.Output.Setlinfo.SetlID
- order.PsnNo = res2.Output.Setlinfo.PsnNo
- order.PsnName = res2.Output.Setlinfo.PsnName
- order.PsnCertType = res2.Output.Setlinfo.PsnCertType
- order.Certno = res2.Output.Setlinfo.Certno
- order.Gend = res2.Output.Setlinfo.Gend
- order.Naty = res2.Output.Setlinfo.Naty
- val, _ := strconv.ParseFloat(res2.Output.Setlinfo.Age, 64)
- order.Age = val
- order.Insutype = res2.Output.Setlinfo.Insutype
- order.PsnType = res2.Output.Setlinfo.PsnType
- order.CvlservFlag = res2.Output.Setlinfo.CvlservFlag
- order.SetlTime = res2.Output.Setlinfo.SetlTime
- order.MdtrtCertType = res2.Output.Setlinfo.MdtrtCertType
- if res.Output.Setlinfo.MedType == "140104" {
-
- order.MedType = "14"
-
- } else {
-
- order.MedType = res2.Output.Setlinfo.MedType
-
- }
- order.MedfeeSumamt = res2.Output.Setlinfo.MedfeeSumamt
- order.FulamtOwnpayAmt = res2.Output.Setlinfo.FulamtOwnpayAmt
- order.OverlmtSelfPay = res2.Output.Setlinfo.OverlmtSelfpay
- order.PreselfpayAmt = res2.Output.Setlinfo.PreselfpayAmt
- order.InscpScpAmt = res2.Output.Setlinfo.InscpScpAmt
- order.ActPayDedc = res2.Output.Setlinfo.ActPayDedc
- order.HifmiPay = res2.Output.Setlinfo.HifmiPay
- order.HifpPay = res2.Output.Setlinfo.HifpPay
- order.HifesPay = res2.Output.Setlinfo.HifesPay
- order.HifobPay = res2.Output.Setlinfo.HifobPay
- order.MafPay = res2.Output.Setlinfo.MafPay
- order.OthPay = res2.Output.Setlinfo.OthPay
- order.CvlservPay = res2.Output.Setlinfo.CvlservPay
- order.PoolPropSelfpay = res2.Output.Setlinfo.PoolPropSelfpay
- order.FundPaySumamt = res2.Output.Setlinfo.FundPaySumamt
- order.PsnPartAmt = res2.Output.Setlinfo.PsnPartAmt
- order.AcctPay = res2.Output.Setlinfo.AcctPay
- order.PsnCashPay = res2.Output.Setlinfo.PsnCashPay
- order.HospPartAmt = res2.Output.Setlinfo.HospPartAmt
- order.Balc = res2.Output.Setlinfo.Balc
- order.AcctMulaidPay = res2.Output.Setlinfo.AcctMulaidPay
- order.MedinsSetlId = res2.Output.Setlinfo.MedinsSetlID
- order.ClrOptins = res2.Output.Setlinfo.ClrOptins
- order.ClrWay = res2.Output.Setlinfo.ClrWay
- order.Creator = order.Creator
- order.Modify = roles.AdminUserId
- order.RequestLog = src_resquest
- setlDetail, _ := json.Marshal(res2.Output.Setldetail)
- detailStr := string(setlDetail)
- order.SetlDetail = detailStr
- //err := service.UpdataOrderStatusTwo(chrg_bchno, c.GetAdminUserInfo().CurrentOrgId)
- if record.OutHospitalStatus == 1 && order.ID > 0 {
- err := service.UpDateOrder(order)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "预结算成功",
- "order_way": 1,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
- return
- }
- } else if record.OutHospitalStatus == 0 && order.ID == 0 {
-
- var order models.HisOrder
- //order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
- order.OrderStatus = 1
- order.MdtrtId = res2.Output.Setlinfo.MdtrtID
- order.SetlId = res2.Output.Setlinfo.SetlID
- order.PsnNo = res2.Output.Setlinfo.PsnNo
- order.PsnName = res2.Output.Setlinfo.PsnName
- order.PsnCertType = res2.Output.Setlinfo.PsnCertType
- order.Certno = res2.Output.Setlinfo.Certno
- order.Gend = res2.Output.Setlinfo.Gend
- order.Naty = res2.Output.Setlinfo.Naty
- val, _ := strconv.ParseFloat(res2.Output.Setlinfo.Age, 64)
- order.Age = val
- order.Insutype = res2.Output.Setlinfo.Insutype
- order.PsnType = res2.Output.Setlinfo.PsnType
- order.CvlservFlag = res2.Output.Setlinfo.CvlservFlag
- order.SetlTime = res2.Output.Setlinfo.SetlTime
- order.MdtrtCertType = res2.Output.Setlinfo.MdtrtCertType
- if res2.Output.Setlinfo.MedType == "140104" {
-
- order.MedType = "14"
-
- } else {
-
- order.MedType = res2.Output.Setlinfo.MedType
-
- }
- order.MedfeeSumamt = res2.Output.Setlinfo.MedfeeSumamt
- order.FulamtOwnpayAmt = res2.Output.Setlinfo.FulamtOwnpayAmt
- order.OverlmtSelfPay = res2.Output.Setlinfo.OverlmtSelfpay
- order.PreselfpayAmt = res2.Output.Setlinfo.PreselfpayAmt
- order.InscpScpAmt = res2.Output.Setlinfo.InscpScpAmt
- order.ActPayDedc = res2.Output.Setlinfo.ActPayDedc
- order.HifmiPay = res2.Output.Setlinfo.HifmiPay
- order.HifpPay = res2.Output.Setlinfo.HifpPay
- order.HifesPay = res2.Output.Setlinfo.HifesPay
- order.HifobPay = res2.Output.Setlinfo.HifobPay
- order.MafPay = res2.Output.Setlinfo.MafPay
- order.OthPay = res2.Output.Setlinfo.OthPay
- order.CvlservPay = res2.Output.Setlinfo.CvlservPay
- order.PoolPropSelfpay = res2.Output.Setlinfo.PoolPropSelfpay
- order.FundPaySumamt = res2.Output.Setlinfo.FundPaySumamt
- order.PsnPartAmt = res2.Output.Setlinfo.PsnPartAmt
- order.AcctPay = res2.Output.Setlinfo.AcctPay
- order.PsnCashPay = res2.Output.Setlinfo.PsnCashPay
- order.HospPartAmt = res2.Output.Setlinfo.HospPartAmt
- order.Balc = res2.Output.Setlinfo.Balc
- order.AcctMulaidPay = res2.Output.Setlinfo.AcctMulaidPay
- order.MedinsSetlId = res2.Output.Setlinfo.MedinsSetlID
- order.ClrOptins = res2.Output.Setlinfo.ClrOptins
- order.ClrWay = res2.Output.Setlinfo.ClrWay
- order.Creator = order.Creator
- order.Modify = roles.AdminUserId
- order.RequestLog = src_resquest
- setlDetail, _ := json.Marshal(res2.Output.Setldetail)
- detailStr := string(setlDetail)
- order.SetlDetail = detailStr
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "预结算成功",
- "order": order,
- "order_way": 2,
- })
- }
- }
- } else {
- if miConfig.Code == "H15049901371" {
- if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- Infcode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
- res.Infcode = Infcode
- res.InfRefmsgid = resSeven10265.InfRefmsgid
- res.RespondTime = resSeven10265.RespondTime
- res.ErrMsg = resSeven10265.ErrMsg
- res.Output = resSeven10265.Output
- res.WarnMsg = resSeven10265.WarnMsg
- res.Cainfo = resSeven10265.Cainfo
-
- } else {
- if err := json.Unmarshal(userJSONBytes, &res); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- }
- if res.Infcode != 0 {
- errlog := &models.HisOrderError{
- UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- Number: chrg_bchno,
- ErrMsg: res.ErrMsg,
- Status: 1,
- PatientId: patient_id,
- RecordTime: time.Now().Unix(),
- Stage: 6,
- }
- service.CreateErrMsgLog(errlog)
- c.ServeSuccessJSON(map[string]interface{}{
- "failed_code": -10,
- "msg": res.ErrMsg,
- })
- return
- } else {
- //order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
- order.OrderStatus = 1
- order.MdtrtId = res.Output.Setlinfo.MdtrtID
- order.SetlId = res.Output.Setlinfo.SetlID
- order.PsnNo = res.Output.Setlinfo.PsnNo
- order.PsnName = res.Output.Setlinfo.PsnName
- order.PsnCertType = res.Output.Setlinfo.PsnCertType
- order.Certno = res.Output.Setlinfo.Certno
- order.Gend = res.Output.Setlinfo.Gend
- order.Naty = res.Output.Setlinfo.Naty
- order.Age = res.Output.Setlinfo.Age
- order.Insutype = res.Output.Setlinfo.Insutype
- order.PsnType = res.Output.Setlinfo.PsnType
- order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
- order.SetlTime = res.Output.Setlinfo.SetlTime
- order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
- if res.Output.Setlinfo.MedType == "140104" {
-
- order.MedType = "14"
-
- } else {
-
- order.MedType = res.Output.Setlinfo.MedType
-
- }
- order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
- order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
- order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
- order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
- order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
- order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
- order.HifmiPay = res.Output.Setlinfo.HifmiPay
- order.HifpPay = res.Output.Setlinfo.HifpPay
- order.HifesPay = res.Output.Setlinfo.HifesPay
- order.HifobPay = res.Output.Setlinfo.HifobPay
- order.MafPay = res.Output.Setlinfo.MafPay
- order.OthPay = res.Output.Setlinfo.OthPay
- order.CvlservPay = res.Output.Setlinfo.CvlservPay
- order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
- order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
- order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
- order.AcctPay = res.Output.Setlinfo.AcctPay
- order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
- order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
- order.Balc = res.Output.Setlinfo.Balc
- order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
- order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
- order.ClrOptins = res.Output.Setlinfo.ClrOptins
- order.ClrWay = res.Output.Setlinfo.ClrWay
- order.Creator = order.Creator
- order.Modify = roles.AdminUserId
- order.RequestLog = src_resquest
- setlDetail, _ := json.Marshal(res.Output.Setldetail)
- detailStr := string(setlDetail)
- order.SetlDetail = detailStr
- //err := service.UpdataOrderStatusTwo(chrg_bchno, c.GetAdminUserInfo().CurrentOrgId)
- if record.OutHospitalStatus == 1 && order.ID > 0 {
- err := service.UpDateOrder(order)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "预结算成功",
- "order_way": 1,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
- return
- }
- } else if record.OutHospitalStatus == 0 && order.ID == 0 {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "预结算成功",
- "order": order,
- "order_way": 2,
- })
- }
- }
- }
-
- }
-
- func (c *ZHHisApiController) GetUploadInfo() {
- id, _ := c.GetInt64("id")
- record_time := c.GetString("record_time")
- in_hospital_id, _ := c.GetInt64("in_hospital_id")
- settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
- admin_user_id, _ := c.GetInt64("admin_user_id")
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordDateTime := theTime.Unix()
- adminUser := c.GetAdminUserInfo()
- var prescriptions []*models.HisPrescription
- data := make(map[string]interface{})
- if settle_accounts_type == 1 { //日结
- prescriptions, _ = service.GetZHHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
-
- } else { //月结
- start_time_str := c.GetString("start_time")
- end_time_str := c.GetString("end_time")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordStartTime := theStartTime.Unix()
- theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordEndTime := theEndTime.Unix()
- prescriptions, _ = service.GetZHMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
-
- }
- roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
- record, _ := service.GetInHospitalRecord(in_hospital_id)
- if record.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
-
- timestamp := time.Now().Unix()
- tempTime := time.Unix(timestamp, 0)
- timeFormat := tempTime.Format("20060102150405")
- chrgBchno := rand.Intn(100000) + 10000
- chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(record.PatientId, 10)
- miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
- patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
- department, _ := service.GetDepartMentDetail(record.Departments)
- strconv.FormatInt(record.PatientId, 10)
-
- doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.Creator)
-
- //client := &http.Client{}
- data["psn_no"] = record.PsnNo
- data["mdtrt_id"] = record.Number
- data["chrg_bchno"] = chrg_bchno
- data["org_name"] = miConfig.OrgName
- data["doctor"] = roles.UserName
- data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
- data["dept"] = strconv.FormatInt(department.ID, 10)
- data["fixmedins_code"] = miConfig.Code
- if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
- data["dept_code"] = "15"
- } else {
- data["dept_code"] = department.Number
- }
- if miConfig.Code == "H15049901371" {
- if record.MedType == 14 {
- if record.InsutypeType == "390" {
-
- data["med_type"] = ""
-
- } else if record.InsutypeType == "310" {
-
- data["med_type"] = ""
-
- }
-
- } else if record.MedType == 11 {
-
- data["med_type"] = strconv.FormatInt(record.MedType, 10)
-
- }
-
- } else {
- if record.MedType == 1112 {
- data["med_type"] = strconv.FormatInt(11, 10)
- } else {
- data["med_type"] = strconv.FormatInt(record.MedType, 10)
- }
-
- }
- data["insuplc_admdvs"] = record.InsuplcAdmdvs
- data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
- data["secret_key"] = miConfig.SecretKey
- var ids []int64
-
- fmt.Println(data)
-
- for _, item := range prescriptions {
- ids = append(ids, item.ID)
- }
- config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
- if config.IsOpen == 1 { //对接了医保,走医保流程
-
- var pagesize int = 10
- var start int = 1
- var stop int
- var pagecount int
- var curpage int
- var isSuccess bool = true
-
- var customs []*models.NewCustom
-
- var empty_code_errs []string
-
- for _, item := range prescriptions {
- if item.Type == 1 { //药品
- for _, subItem := range item.HisDoctorAdviceInfo {
- if len(subItem.BaseDrugLib.MedicalInsuranceNumber) == 0 {
-
- empty_code_errs = append(empty_code_errs,subItem.BaseDrugLib.DrugName)
- }
- }
- }
-
- if item.Type == 2 { //项目
- for _, subItem := range item.HisPrescriptionProject {
- //var randNum int
- //randNum = rand.Intn(10000) + 1000
- if subItem.Type == 2 {
- if len(subItem.HisProject.MedicalCode) == 0 {
- empty_code_errs = append(empty_code_errs,subItem.HisProject.ProjectName)
-
- }
- } else if subItem.Type == 3 {
- if len(subItem.GoodInfo.MedicalInsuranceNumber) == 0 {
- empty_code_errs = append(empty_code_errs,subItem.GoodInfo.GoodName)
-
- }
- }
- }
- }
-
- }
- if len(empty_code_errs) > 0{
- var err string
- for _, item := range empty_code_errs{
- if len(err) == 0{
- err = item
- }else{
- err = err +"," + item
- }
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "failed_code": -10,
- "msg": err +" "+ "没有填写国家编码",
- })
- return
- }
- for _, item := range prescriptions {
- tm := time.Unix(item.PreTime, 0)
- if item.Type == 1 { //药品
- for _, subItem := range item.HisDoctorAdviceInfo {
- if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 && subItem.BaseDrugLib.IsUser != 1 {
- //var randNum int
- //randNum = rand.Intn(10000) + 1000
- cus := &models.NewCustom{
- DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber),
- Cut: fmt.Sprintf("%.4f", subItem.PrescribingNumber),
- FeedetlSn: subItem.FeedetlSn,
- Price: fmt.Sprintf("%.4f", subItem.Price),
- MedListCodg: subItem.BaseDrugLib.MedicalInsuranceNumber,
- HospApprFlag: subItem.BaseDrugLib.HospApprFlag,
- FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
- DoctorId: item.Creator,
- }
-
- customs = append(customs, cus)
- }
- }
- }
-
- if item.Type == 2 { //项目
- for _, subItem := range item.HisPrescriptionProject {
- //var randNum int
- //randNum = rand.Intn(10000) + 1000
- if subItem.Type == 2 {
- if len(subItem.HisProject.MedicalCode) > 0 {
- cnt, _ := strconv.ParseFloat(subItem.Count, 64)
- cus := &models.NewCustom{
- DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
- Cut: fmt.Sprintf("%.4f", cnt),
- FeedetlSn: subItem.FeedetlSn,
- Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
- MedListCodg: subItem.HisProject.MedicalCode,
- HospApprFlag: -1,
- FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
- DoctorId: item.Creator,
- }
- customs = append(customs, cus)
- }
- } else if subItem.Type == 3 {
- if len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 && subItem.GoodInfo.IsUser != 1 {
- cnt, _ := strconv.ParseFloat(subItem.Count, 64)
-
- cus := &models.NewCustom{
- DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
- Cut: fmt.Sprintf("%.4f", cnt),
- FeedetlSn: subItem.FeedetlSn,
- Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
- MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
- HospApprFlag: -1,
- FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
- DoctorId: item.Creator,
- }
- customs = append(customs, cus)
- }
- }
- }
- }
-
- }
-
- //总页数,向上取整,注意除之前要先转换类型为float64
- pagecount = int(math.Ceil(float64(len(customs)) / float64(pagesize)))
- var ress []*ResultFour
- for curpage = 1; curpage <= pagecount; curpage++ {
- if curpage == 1 {
- start = 1
- } else {
- start = (curpage-1)*pagesize + 1
- }
- stop = curpage * pagesize
- if stop > len(customs) {
- stop = len(customs)
- }
-
- var result string
- var requestLog string
- if miConfig.MdtrtareaAdmvs == "150499" {
- data := make(map[string]interface{})
- if record.MedType == 14 {
- if record.InsutypeType == "390" {
-
- data["med_type"] = "9933"
-
- } else if record.InsutypeType == "310" {
-
- data["med_type"] = "990502"
-
- }
-
- } else if record.MedType == 11 {
-
- data["med_type"] = strconv.FormatInt(record.MedType, 10)
-
- }
- data["psn_no"] = record.PsnNo
- data["number"] = record.Number
- data["customs"] = customs[start-1 : stop]
- data["chrg_bchno"] = chrg_bchno
- data["dept"] = strconv.FormatInt(department.ID, 10)
- data["dept_code"] = department.Number
- data["doctor_code"] = doctor_info.DoctorNumber
- data["doctor_name"] = doctor_info.UserName
- data["org_name"] = miConfig.OrgName
- data["opertor"] = roles.UserName
- data["fixmedins_code"] = miConfig.Code
- data["insuplc_admdvs"] = record.InsuplcAdmdvs
- data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
- data["secret_key"] = miConfig.SecretKey
-
- var req *http.Request
- bytesData, _ := json.Marshal(data)
- req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2301", bytes.NewReader(bytesData))
- client := &http.Client{}
- resp, _ := client.Do(req)
- defer resp.Body.Close()
- body, ioErr := ioutil.ReadAll(resp.Body)
- if ioErr != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- var respJSON map[string]interface{}
- if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
- result_byte, _ := json.Marshal(respJSON)
- result = string(result_byte)
- } else if miConfig.MdtrtareaAdmvs == "421182" {
- data := make(map[string]interface{})
- //if record.MedType == 14 {
- // if record.InsutypeType == "390" {
- //
- // data["med_type"] = "9933"
- //
- // } else if record.InsutypeType == "310" {
- //
- // data["med_type"] = "990502"
- //
- // }
- //
- //} else if record.MedType == 11 {
- //
- //
- //}
- data["med_type"] = strconv.FormatInt(record.MedType, 10)
-
- data["psn_no"] = record.PsnNo
- data["number"] = record.Number
- data["customs"] = customs[start-1 : stop]
- data["chrg_bchno"] = chrg_bchno
- data["dept"] = strconv.FormatInt(department.ID, 10)
- data["dept_code"] = department.Number
- data["doctor_code"] = doctor_info.DoctorNumber
- data["doctor_name"] = doctor_info.UserName
- data["org_name"] = miConfig.OrgName
- data["opertor"] = roles.UserName
- data["fixmedins_code"] = miConfig.Code
- data["insuplc_admdvs"] = record.InsuplcAdmdvs
- data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
- data["secret_key"] = miConfig.SecretKey
-
- var req *http.Request
- bytesData, _ := json.Marshal(data)
- req, _ = http.NewRequest("POST", miConfig.Url +"hbyb/2301", bytes.NewReader(bytesData))
- client := &http.Client{}
- resp, _ := client.Do(req)
- defer resp.Body.Close()
- body, ioErr := ioutil.ReadAll(resp.Body)
- if ioErr != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- var respJSON map[string]interface{}
- if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
- result_byte, _ := json.Marshal(respJSON)
- result = string(result_byte)
- } else if miConfig.MdtrtareaAdmvs == "360399" {
- result, requestLog = service.Jxyb2301(record.PsnNo, record.Number, customs[start-1:stop], data["med_type"].(string), chrg_bchno, department.Number, strconv.FormatInt(department.ID, 10), strconv.FormatInt(roles.AdminUserId, 10), miConfig.SecretKey, miConfig.OrgName, miConfig.Code, roles.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, "", miConfig.AccessKey)
- saveLog(result, requestLog, "2301", "上传明细")
-
- } else {
- fmt.Println("--------")
- fmt.Println(prescriptions)
- fmt.Println("--------")
- res3101 := Check3101(c, record.PatientId, record.ID, admin_user_id, "4", record_time, prescriptions)
- if res3101.Infcode == 0 {
- if len(res3101.Output.Result) > 0 {
- var errMsgs []string
- for _, item := range res3101.Output.Result {
- errMsgs = append(errMsgs, item.VolaCont)
-
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "failed_code": -10,
- "msg": errMsgs,
- })
- return
- } else {
- result, requestLog = service.ZHGdyb2301(record.PsnNo, record.Number, customs[start-1:stop], chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(department.ID, 10), miConfig.Code, department.Number, strconv.FormatInt(roles.AdminUserId, 10), record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, data["med_type"].(string), doctor_info.UserName, doctor_info.DoctorNumber)
- saveLog(result, requestLog, "2301", "上传明细")
- }
- } else {
- c.ServeSuccessJSON(map[string]interface{}{
- "failed_code": -10,
- "msg": res3101.ErrMsg,
- })
- return
- }
- }
- var dat map[string]interface{}
- if err := json.Unmarshal([]byte(result), &dat); err == nil {
- fmt.Println(dat)
- } else {
- fmt.Println(err)
- }
- userJSONBytes, _ := json.Marshal(dat)
- var res ResultFour
- var resFour10265 ResultFour10265
- if miConfig.Code == "H15049901371" {
- if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- res.WarnMsg = resFour10265.WarnMsg
- res.Output = resFour10265.Output
- res.ErrMsg = resFour10265.ErrMsg
- res.RespondTime = resFour10265.RespondTime
- res.InfRefmsgid = resFour10265.InfRefmsgid
- Infcode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
- res.Infcode = Infcode
-
- } else {
- if err := json.Unmarshal(userJSONBytes, &res); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- }
-
- if res.Infcode == 0 {
- ress = append(ress, &res)
- } else {
- isSuccess = false
- errlog := &models.HisOrderError{
- UserOrgId: adminUser.CurrentOrgId,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- Number: chrg_bchno,
- ErrMsg: "",
- Status: 1,
- PatientId: id,
- RecordTime: recordDateTime,
- Stage: 4,
- }
- service.CreateErrMsgLog(errlog)
- c.ServeSuccessJSON(map[string]interface{}{
- "failed_code": -10,
- "msg": "上传明细错误,请联系his厂商",
- })
- return
- }
- }
-
- if isSuccess == true {
- if settle_accounts_type == 1 {
- for _, subItem := range ress {
- for _, item := range subItem.Output.Result {
- temp := strings.Split(item.FeedetlSn, "-")
- var advice_id int64 = 0
- var project_id int64 = 0
- var types int64 = 0
-
- id, _ := strconv.ParseInt(temp[2], 10, 64)
- types, _ = strconv.ParseInt(temp[1], 10, 64)
-
- if temp[1] == "1" {
- advice_id = id
- project_id = 0
- } else if temp[1] == "2" {
- advice_id = 0
- project_id = id
- }
- info := &models.HisOrderInfo{
- OrderNumber: record.Number,
- FeedetlSn: item.FeedetlSn,
- UploadDate: recordDateTime,
- AdviceId: advice_id,
- DetItemFeeSumamt: item.DetItemFeeSumamt,
- Cnt: item.Cnt,
- Pric: float64(item.Pric),
- PatientId: record.PatientId,
- PricUplmtAmt: item.PricUplmtAmt,
- SelfpayProp: item.SelfpayProp,
- FulamtOwnpayAmt: item.FulamtOwnpayAmt,
- OverlmtAmt: item.OverlmtAmt,
- PreselfpayAmt: item.PreselfpayAmt,
- BasMednFlag: item.BasMednFlag,
- MedChrgitmType: item.MedChrgitmType,
- HiNegoDrugFlag: item.HiNegoDrugFlag,
- Status: 1,
- Memo: item.Memo,
- Mtime: time.Now().Unix(),
- InscpScpAmt: item.InscpScpAmt,
- DrtReimFlag: item.DrtReimFlag,
- Ctime: time.Now().Unix(),
- ListSpItemFlag: item.ListSpItemFlag,
- ChldMedcFlag: item.ChldMedcFlag,
- LmtUsedFlag: item.LmtUsedFlag,
- ChrgitmLv: item.ChrgitmLv,
- UserOrgId: adminUser.CurrentOrgId,
- HisPatientId: record.ID,
- OrderId: 0,
- ProjectId: project_id,
- Type: types,
- SettleType: settle_accounts_type,
- }
- service.CreateOrderInfo(info)
- }
- }
-
- err := service.UpDatePrescriptionOrderStatus(adminUser.CurrentOrgId, ids)
- service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, record.Number)
- service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, record.Number, recordDateTime)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "上传费用明细成功",
- })
- return
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
-
- } else {
-
- for _, subItem := range ress {
- for _, item := range subItem.Output.Result {
- temp := strings.Split(item.FeedetlSn, "-")
- var advice_id int64 = 0
- var project_id int64 = 0
- var types int64 = 0
-
- id, _ := strconv.ParseInt(temp[2], 10, 64)
- types, _ = strconv.ParseInt(temp[1], 10, 64)
-
- if temp[1] == "1" {
- advice_id = id
- project_id = 0
- } else if temp[1] == "2" {
- advice_id = 0
- project_id = id
- }
- info := &models.HisOrderInfo{
- OrderNumber: record.Number,
- FeedetlSn: item.FeedetlSn,
- UploadDate: time.Now().Unix(),
- AdviceId: advice_id,
- DetItemFeeSumamt: item.DetItemFeeSumamt,
- Cnt: item.Cnt,
- Pric: float64(item.Pric),
- PatientId: record.PatientId,
- PricUplmtAmt: item.PricUplmtAmt,
- SelfpayProp: item.SelfpayProp,
- FulamtOwnpayAmt: item.FulamtOwnpayAmt,
- OverlmtAmt: item.OverlmtAmt,
- PreselfpayAmt: item.PreselfpayAmt,
- BasMednFlag: item.BasMednFlag,
- MedChrgitmType: item.MedChrgitmType,
- HiNegoDrugFlag: item.HiNegoDrugFlag,
- Status: 1,
- Memo: item.Memo,
- Mtime: time.Now().Unix(),
- InscpScpAmt: item.InscpScpAmt,
- DrtReimFlag: item.DrtReimFlag,
- Ctime: time.Now().Unix(),
- ListSpItemFlag: item.ListSpItemFlag,
- ChldMedcFlag: item.ChldMedcFlag,
- LmtUsedFlag: item.LmtUsedFlag,
- ChrgitmLv: item.ChrgitmLv,
- UserOrgId: adminUser.CurrentOrgId,
- HisPatientId: record.ID,
- ProjectId: project_id,
- Type: types,
- SettleType: settle_accounts_type,
- }
- service.CreateOrderInfo(info)
- }
- }
- service.UpDatePrescriptionOrderStatus(adminUser.CurrentOrgId, ids)
- service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, record.Number)
- service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, record.Number, recordDateTime)
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "上传费用明细成功",
- })
-
- }
-
- }
-
- }
- }
- func (c *ZHHisApiController) ZHRefund() {
- order_id, _ := c.GetInt64("order_id")
- admin_user_id, _ := c.GetInt64("admin_user_id")
- adminUser := c.GetAdminUserInfo()
- var order models.HisOrder
- order, _ = service.GetHisOrderByID(order_id)
- record, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
- roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
- miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
- config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
- if config.IsOpen == 1 { //对接了医保,走医保流程
-
- var result string
- var requestLog string
- if miConfig.MdtrtareaAdmvs == "150499" {
- //请求内网数据
- api := "http://172.16.13.254:9532/" + "nmyb/2305?mdtrt_id=" + record.Number + "&psn_no=" + record.PsnNo + "&setl_id=" + order.SetlId +
- "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
- "&insuplc_admdvs=" + record.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
- resp, requestErr := http.Get(api)
- if requestErr != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- body, ioErr := ioutil.ReadAll(resp.Body)
-
- if ioErr != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- var respJSON map[string]interface{}
-
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
- result_byte, _ := json.Marshal(respJSON)
- result = string(result_byte)
- //saveLog(result, requestLog, "2404", "入院登记撤销")
- saveLog(result, requestLog, "2305", "退费")
-
- } else if miConfig.MdtrtareaAdmvs == "421182" {
- //请求内网数据
- api := miConfig.Url + "hbyb/2305?mdtrt_id=" + record.Number + "&psn_no=" + record.PsnNo + "&setl_id=" + order.SetlId +
- "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
- "&insuplc_admdvs=" + record.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
- resp, requestErr := http.Get(api)
- if requestErr != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- body, ioErr := ioutil.ReadAll(resp.Body)
-
- if ioErr != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- var respJSON map[string]interface{}
-
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
- result_byte, _ := json.Marshal(respJSON)
- result = string(result_byte)
- saveLog(result, requestLog, "2305", "退费")
-
- } else if miConfig.MdtrtareaAdmvs == "360399" {
-
- result, requestLog := service.Jxyb2305(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, roles.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, "", miConfig.AccessKey)
- saveLog(result, requestLog, "2305", "退费")
-
- } else {
- result, requestLog := service.Gdyb2305(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
- saveLog(result, requestLog, "2305", "退费")
-
- }
-
- var dat map[string]interface{}
- if err := json.Unmarshal([]byte(result), &dat); err == nil {
- fmt.Println(dat)
- } else {
- fmt.Println(err)
- }
-
- userJSONBytes, _ := json.Marshal(dat)
-
- var res ResultSixteen
- var resSixteen ResultSixteen10265
- if miConfig.Code == "H15049901371" {
- if err := json.Unmarshal(userJSONBytes, &resSixteen); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- res.Cainfo = resSixteen.Cainfo
- res.WarnMsg = resSixteen.WarnMsg
- res.Output = resSixteen.Output
- res.ErrMsg = resSixteen.ErrMsg
- res.RespondTime = resSixteen.RespondTime
- Infcode, _ := strconv.ParseInt(resSixteen.Infcode, 10, 64)
- res.Infcode = Infcode
-
- } else {
-
- if err := json.Unmarshal(userJSONBytes, &res); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- }
-
- if res.Infcode == 0 {
- err := service.UpdataOrderStatusThree(order_id, order.Number, adminUser.CurrentOrgId, "", result)
- //不同地区退费流程不一样,肇庆那边退费就包括撤销出院,内蒙古退费不包括撤销明细,所以下面需要根据不同情况进行判断
- if miConfig.UserOrgId == 10215 {
- record.OutHospitalStatus = 0
- service.CreateHospitalRecord(&record)
- }
- service.UpdataOrderStatusByNumber(record.Number)
- if err == nil {
- ////当押金不为零时产生退费记录
- if order.Decimal != 0 {
- tmp := strconv.FormatInt(order.ID, 10)
- err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "退费成功",
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- } else {
- c.ServeSuccessJSON(map[string]interface{}{
- "code": -10,
- "msg": res.ErrMsg,
- })
- }
-
- } else {
- err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, "", "")
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "退费成功",
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- }
-
- }
- func (c *ZHHisApiController) ZHRefundDetail() {
- patient_id, _ := c.GetInt64("patient_id")
- his_patient_id, _ := c.GetInt64("his_patient_id")
- record_time := c.GetString("record_time")
- settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
- //order_id, _ := c.GetInt64("order_id")
- admin_user_id, _ := c.GetInt64("admin_user_id")
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordDateTime := theTime.Unix()
- adminUser := c.GetAdminUserInfo()
-
- theTimeTwo, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 23:59:59", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordDateTimeTwo := theTimeTwo.Unix()
-
- //var prescriptions []*models.HisPrescription
- miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
- roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
-
- if settle_accounts_type == 1 { //日结
- record, _ := service.GetInHospitalRecord(his_patient_id)
- infos, _ := service.GetZHHisUploadOrderInfo(adminUser.CurrentOrgId, patient_id, recordDateTime, recordDateTimeTwo, record.Number)
- var isSuccess bool = true
-
- for _, item := range infos {
- var result string
- var requestLog string
- if miConfig.MdtrtareaAdmvs == "150499" {
- //请求内网数据
- api := "http://172.16.13.254:9532/" + "nmyb/2302?psn_no=" + record.PsnNo + "&mdtrtId=" + record.Number + "&feedetl_sn=" + item.FeedetlSn +
- "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
- "&insuplc_admdvs=" + record.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&refund_type=" + "1"
- resp, requestErr := http.Get(api)
- if requestErr != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- body, ioErr := ioutil.ReadAll(resp.Body)
- if ioErr != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- var respJSON map[string]interface{}
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
- result_byte, _ := json.Marshal(respJSON)
- result = string(result_byte)
- saveLog(result, requestLog, "2302", "日结退明细")
-
- } else if miConfig.MdtrtareaAdmvs == "421182" {
- //请求内网数据
- api := miConfig.Url + "hbyb/2302?psn_no=" + record.PsnNo + "&mdtrtId=" + record.Number + "&feedetl_sn=" + item.FeedetlSn +
- "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
- "&insuplc_admdvs=" + record.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&refund_type=" + "1"
- resp, requestErr := http.Get(api)
- if requestErr != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- body, ioErr := ioutil.ReadAll(resp.Body)
- if ioErr != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- var respJSON map[string]interface{}
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
- result_byte, _ := json.Marshal(respJSON)
- result = string(result_byte)
- saveLog(result, requestLog, "2302", "日结退明细")
-
- } else if miConfig.MdtrtareaAdmvs == "360399" {
- result, requestLog := service.Jxyb2302(record.PsnNo, record.Number, 1, item.FeedetlSn, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, roles.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, "", miConfig.AccessKey)
- saveLog(result, requestLog, "2302", "日结退明细")
- } else {
- result, requestLog := service.Gdyb2302(record.PsnNo, record.Number, miConfig.OrgName, roles.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, item.FeedetlSn, 1)
- saveLog(result, requestLog, "2302", "日结退明细")
-
- }
-
- var dat map[string]interface{}
- if err := json.Unmarshal([]byte(result), &dat); err == nil {
- fmt.Println(dat)
- } else {
- fmt.Println(err)
- }
- userJSONBytes, _ := json.Marshal(dat)
- var res2 ResultEmpty
- var resEmpty10265 ResultEmpty10265
- if miConfig.Code == "H15049901371" {
- if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
- res2.Infcode = Infcode
- res2.RespondTime = resEmpty10265.RespondTime
- res2.ErrMsg = resEmpty10265.ErrMsg
- res2.Output = resEmpty10265.Output
- res2.WarnMsg = resEmpty10265.WarnMsg
- } else {
- if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- }
-
- if res2.Infcode == -1 {
- isSuccess = false
- }
- }
- if isSuccess {
- err := service.UpDateOrderInfoStatus(patient_id, recordDateTime, adminUser.CurrentOrgId, recordDateTimeTwo)
-
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- err1 := service.UpDatePrescriptionOrderStatusTwo(patient_id, recordDateTime, adminUser.CurrentOrgId)
- if err1 != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "撤销明细成功",
- })
-
- }
-
- } else {
- //prescriptions, _ = service.GetZHMonthHisUploadPrescription(adminUser.CurrentOrgId, patient_id, recordDateTime)
- //var order models.HisOrder
- //order, _ = service.GetHisOrderByID(order_id)
- //record, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
- var result string
- var requestLog string
- record, _ := service.GetInHospitalRecord(his_patient_id)
- config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
- if config.IsOpen == 1 { //对接了医保,走医保流程
-
- if miConfig.MdtrtareaAdmvs == "150499" {
- //请求内网数据
- api := "http://172.16.13.254:9532/" + "nmyb/2302?psn_no=" + record.PsnNo + "&mdtrtId=" + record.Number + "&number=0000" +
- "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
- "&insuplc_admdvs=" + record.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&refund_type=" + "0"
- resp, requestErr := http.Get(api)
- if requestErr != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- body, ioErr := ioutil.ReadAll(resp.Body)
- if ioErr != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- var respJSON map[string]interface{}
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
- result_byte, _ := json.Marshal(respJSON)
- result = string(result_byte)
- //saveLog(result, requestLog, "2302", "日结退明细")
-
- } else if miConfig.MdtrtareaAdmvs == "421182" {
- //请求内网数据
- api := miConfig.Url + "hbyb/2302?psn_no=" + record.PsnNo + "&mdtrtId=" + record.Number + "&number=0000" +
- "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
- "&insuplc_admdvs=" + record.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&refund_type=" + "0"
- resp, requestErr := http.Get(api)
- if requestErr != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- body, ioErr := ioutil.ReadAll(resp.Body)
- if ioErr != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- var respJSON map[string]interface{}
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
- result_byte, _ := json.Marshal(respJSON)
- result = string(result_byte)
- //saveLog(result, requestLog, "2302", "日结退明细")
-
- } else if miConfig.MdtrtareaAdmvs == "360399" {
- result, requestLog = service.Jxyb2302(record.PsnNo, record.Number, 0, "0000", miConfig.SecretKey, miConfig.OrgName, miConfig.Code, roles.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, "", miConfig.AccessKey)
- saveLog(result, requestLog, "2302", "月结退明细")
-
- } else {
- result, requestLog = service.Gdyb2302(record.PsnNo, record.Number, miConfig.OrgName, roles.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, "0000", 0)
- saveLog(result, requestLog, "2302", "月结退明细")
- }
-
- var dat map[string]interface{}
- if err := json.Unmarshal([]byte(result), &dat); err == nil {
- fmt.Println(dat)
- } else {
- fmt.Println(err)
- }
-
- userJSONBytes, _ := json.Marshal(dat)
-
- var res2 ResultEmpty
- var resEmpty10265 ResultEmpty10265
- if miConfig.Code == "H15049901371" {
- if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
- res2.Infcode = Infcode
- res2.RespondTime = resEmpty10265.RespondTime
- res2.ErrMsg = resEmpty10265.ErrMsg
- res2.Output = resEmpty10265.Output
- res2.WarnMsg = resEmpty10265.WarnMsg
- } else {
- if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- }
-
- if res2.Infcode == 0 {
- err := service.UpdataHospitalOrderStatus(record.Number, adminUser.CurrentOrgId)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "撤销明细成功",
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- } else {
- c.ServeSuccessJSON(map[string]interface{}{
- "code": -10,
- "msg": res2.ErrMsg,
- })
- }
- }
- }
-
- }
- func (this *ZHHisApiController) GetZHOutHospitalUnCheck() {
- id, _ := this.GetInt64("id")
- admin_user_id, _ := this.GetInt64("admin_user_id")
-
- adminInfo := this.GetAdminUserInfo()
- miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
- role, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
-
- record, _ := service.GetInHospitalRecord(id)
- if record.ID == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInHospitalNoExistDataException)
- return
- }
-
- var result string
- var requestLog string
- if miConfig.MdtrtareaAdmvs == "150499" {
- //请求内网数据
- api := "http://172.16.13.254:9532/" + "nmyb/2405?mdtrt_id=" + record.Number + "&psn_no=" + record.PsnNo +
- "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
- "&insuplc_admdvs=" + record.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
- fmt.Println(api)
- resp, requestErr := http.Get(api)
- if requestErr != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- body, ioErr := ioutil.ReadAll(resp.Body)
-
- if ioErr != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- var respJSON map[string]interface{}
-
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
- result_byte, _ := json.Marshal(respJSON)
- result = string(result_byte)
-
- } else if miConfig.MdtrtareaAdmvs == "421182" {
- //请求内网数据
- api := miConfig.Url + "hbyb/2405?mdtrt_id=" + record.Number + "&psn_no=" + record.PsnNo +
- "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
- "&insuplc_admdvs=" + record.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
- fmt.Println(api)
- resp, requestErr := http.Get(api)
- if requestErr != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- body, ioErr := ioutil.ReadAll(resp.Body)
-
- if ioErr != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- var respJSON map[string]interface{}
-
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
- result_byte, _ := json.Marshal(respJSON)
- result = string(result_byte)
-
- } else if miConfig.MdtrtareaAdmvs == "360399" {
-
- result, requestLog = service.Jxyb2405(record.Number, record.PsnNo, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, role.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, "", miConfig.AccessKey)
- saveLog(result, requestLog, "2405", "出院登记撤销")
-
- } else {
- result, requestLog = service.ZHGdyb2405(record.Number, record.PsnNo, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, role.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
- saveLog(result, requestLog, "2405", "出院登记撤销")
-
- }
-
- var dat map[string]interface{}
- if err := json.Unmarshal([]byte(result), &dat); err == nil {
- fmt.Println(dat)
- } else {
- fmt.Println(err)
- }
- userJSONBytes, _ := json.Marshal(dat)
- var res ResultEmpty
- var resEmpty10265 ResultEmpty10265
- if miConfig.Code == "H15049901371" {
- if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
- res.Infcode = Infcode
- res.RespondTime = resEmpty10265.RespondTime
- res.ErrMsg = resEmpty10265.ErrMsg
- res.Output = resEmpty10265.Output
- res.WarnMsg = resEmpty10265.WarnMsg
- } else {
- if err := json.Unmarshal(userJSONBytes, &res); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- }
-
- if res.Infcode == 0 {
- record.OutHospitalStatus = 0
- service.CreateHospitalRecord(&record)
- service.UpdataOrderStatusByNumber(record.Number)
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "撤销出院成功",
- })
-
- } else {
- this.ServeSuccessJSON(map[string]interface{}{
- "failed_code": -10,
- "msg": res.ErrMsg,
- })
- }
-
- }
- func (this *ZHHisApiController) GetZHInHospitalUnCheck() {
- id, _ := this.GetInt64("id")
- admin_user_id, _ := this.GetInt64("admin_user_id")
- adminInfo := this.GetAdminUserInfo()
- miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
- role, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
- record, _ := service.GetInHospitalRecord(id)
-
- if record.ID == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInHospitalNoExistDataException)
- return
- }
-
- var result string
- var requestLog string
- orders, _ := service.GetHisOrderInfoByNumber(record.Number)
-
- if len(orders) > 0 { //判断是否上传过明细,有的话需要退明细,后撤销入院
- if miConfig.MdtrtareaAdmvs == "150499" {
- //请求内网数据
- api := "http://172.16.13.254:9532/" + "nmyb/2302?psn_no=" + record.PsnNo + "&mdtrtId=" + record.Number + "&number=" + "0000" +
- "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
- "&insuplc_admdvs=" + record.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&refund_type=0"
- resp, requestErr := http.Get(api)
- if requestErr != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- body, ioErr := ioutil.ReadAll(resp.Body)
-
- if ioErr != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- var respJSON map[string]interface{}
-
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
- result_byte, _ := json.Marshal(respJSON)
- result = string(result_byte)
- saveLog(result, requestLog, "2302", "月结退明细")
-
- }else if miConfig.MdtrtareaAdmvs == "421182" {
- //请求内网数据
- api := miConfig.Url + "hbyb/2302?psn_no=" + record.PsnNo + "&mdtrtId=" + record.Number + "&number=" + "0000" +
- "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
- "&insuplc_admdvs=" + record.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&refund_type=0"
- resp, requestErr := http.Get(api)
- if requestErr != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- body, ioErr := ioutil.ReadAll(resp.Body)
-
- if ioErr != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- var respJSON map[string]interface{}
-
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
- result_byte, _ := json.Marshal(respJSON)
- result = string(result_byte)
- saveLog(result, requestLog, "2302", "月结退明细")
-
- } else if miConfig.MdtrtareaAdmvs == "360399" {
- result, requestLog = service.Jxyb2302(record.PsnNo, record.Number, 0, "0000", miConfig.SecretKey, miConfig.OrgName, miConfig.Code, role.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, "", miConfig.AccessKey)
- saveLog(result, requestLog, "2302", "月结退明细")
- } else {
- result, requestLog = service.Gdyb2302(record.PsnNo, record.Number, miConfig.OrgName, role.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, "0000", 0)
- saveLog(result, requestLog, "2302", "月结退明细")
-
- }
-
- var dat map[string]interface{}
- if err := json.Unmarshal([]byte(result), &dat); err == nil {
- fmt.Println(dat)
- } else {
- fmt.Println(err)
- }
-
- userJSONBytes, _ := json.Marshal(dat)
-
- var res2 ResultEmpty
- var resEmpty10265 ResultEmpty10265
- if miConfig.Code == "H15049901371" {
- if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
- res2.Infcode = Infcode
- res2.RespondTime = resEmpty10265.RespondTime
- res2.ErrMsg = resEmpty10265.ErrMsg
- res2.Output = resEmpty10265.Output
- res2.WarnMsg = resEmpty10265.WarnMsg
- } else {
- if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- }
-
- if res2.Infcode == 0 {
-
- service.UpdataHospitalOrderStatus(record.Number, adminInfo.CurrentOrgId)
-
- var result string
- var requestLog string
- if miConfig.MdtrtareaAdmvs == "150499" {
- //请求内网数据
- api := "http://172.16.13.254:9532/" + "nmyb/2404?mdtrt_id=" + record.Number + "&psn_no=" + record.PsnNo +
- "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
- "&insuplc_admdvs=" + record.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
- resp, requestErr := http.Get(api)
- if requestErr != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- body, ioErr := ioutil.ReadAll(resp.Body)
-
- if ioErr != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- var respJSON map[string]interface{}
-
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
- result_byte, _ := json.Marshal(respJSON)
- result = string(result_byte)
-
- } else if miConfig.MdtrtareaAdmvs == "421182" {
- //请求内网数据
- api := miConfig.Url + "hbyb/2404?mdtrt_id=" + record.Number + "&psn_no=" + record.PsnNo +
- "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
- "&insuplc_admdvs=" + record.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
- resp, requestErr := http.Get(api)
- if requestErr != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- body, ioErr := ioutil.ReadAll(resp.Body)
-
- if ioErr != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- var respJSON map[string]interface{}
-
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
- result_byte, _ := json.Marshal(respJSON)
- result = string(result_byte)
-
- } else if miConfig.MdtrtareaAdmvs == "360399" {
- result, requestLog = service.Jxyb2404(record.Number, record.PsnNo, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, role.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, "", miConfig.AccessKey)
- saveLog(result, requestLog, "2404", "入院登记撤销")
-
- } else {
- result, requestLog = service.ZHGdyb2404(record.Number, record.PsnNo, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, role.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
- saveLog(result, requestLog, "2404", "入院登记撤销")
-
- }
-
- var dat map[string]interface{}
- if err := json.Unmarshal([]byte(result), &dat); err == nil {
- fmt.Println(dat)
- } else {
- fmt.Println(err)
- }
- userJSONBytes, _ := json.Marshal(dat)
- var res ResultEmpty
- var resEmpty10265 ResultEmpty10265
- if miConfig.Code == "H15049901371" {
- if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
- res.Infcode = Infcode
- res.RespondTime = resEmpty10265.RespondTime
- res.ErrMsg = resEmpty10265.ErrMsg
- res.Output = resEmpty10265.Output
- res.WarnMsg = resEmpty10265.WarnMsg
- } else {
- if err := json.Unmarshal(userJSONBytes, &res); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- }
-
- if res.Infcode == 0 {
- record.Status = 0
- service.CreateHospitalRecord(&record)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "撤销入院成功",
- })
-
- } else {
- this.ServeSuccessJSON(map[string]interface{}{
- "failed_code": -10,
- "msg": res.ErrMsg,
- })
- }
-
- } else {
- this.ServeSuccessJSON(map[string]interface{}{
- "code": -10,
- "msg": res2.ErrMsg,
- })
- }
- } else { //没有上传过明细的,直接撤销入院
-
- var result string
- var requestLog string
- if miConfig.MdtrtareaAdmvs == "150499" {
- //请求内网数据
- api := "http://172.16.13.254:9532/" + "nmyb/2404?mdtrt_id=" + record.Number + "&psn_no=" + record.PsnNo +
- "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
- "&insuplc_admdvs=" + record.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
- resp, requestErr := http.Get(api)
- if requestErr != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- body, ioErr := ioutil.ReadAll(resp.Body)
-
- if ioErr != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- var respJSON map[string]interface{}
-
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
- result_byte, _ := json.Marshal(respJSON)
- result = string(result_byte)
-
- } else if miConfig.MdtrtareaAdmvs == "421182" {
- //请求内网数据
- api := miConfig.Url + "hbyb/2404?mdtrt_id=" + record.Number + "&psn_no=" + record.PsnNo +
- "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
- "&insuplc_admdvs=" + record.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
- resp, requestErr := http.Get(api)
- if requestErr != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- body, ioErr := ioutil.ReadAll(resp.Body)
-
- if ioErr != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- var respJSON map[string]interface{}
-
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
- result_byte, _ := json.Marshal(respJSON)
- result = string(result_byte)
-
- } else if miConfig.MdtrtareaAdmvs == "360399" {
- result, requestLog = service.Jxyb2404(record.Number, record.PsnNo, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, role.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, "", miConfig.AccessKey)
- saveLog(result, requestLog, "2404", "入院登记撤销")
-
- } else {
- result, requestLog = service.ZHGdyb2404(record.Number, record.PsnNo, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, role.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
- saveLog(result, requestLog, "2404", "入院登记撤销")
-
- }
-
- var dat map[string]interface{}
- if err := json.Unmarshal([]byte(result), &dat); err == nil {
- fmt.Println(dat)
- } else {
- fmt.Println(err)
- }
- userJSONBytes, _ := json.Marshal(dat)
- var res ResultEmpty
- var resEmpty10265 ResultEmpty10265
- if miConfig.Code == "H15049901371" {
- if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
- res.Infcode = Infcode
- res.RespondTime = resEmpty10265.RespondTime
- res.ErrMsg = resEmpty10265.ErrMsg
- res.Output = resEmpty10265.Output
- res.WarnMsg = resEmpty10265.WarnMsg
- } else {
- if err := json.Unmarshal(userJSONBytes, &res); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- }
-
- if res.Infcode == 0 {
- record.Status = 0
- service.CreateHospitalRecord(&record)
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "撤销入院成功",
- })
-
- } else {
- this.ServeSuccessJSON(map[string]interface{}{
- "failed_code": -10,
- "msg": res.ErrMsg,
- })
- }
- }
- }
-
- func saveLog(result string, request string, infno string, desc string) {
-
- org_id, _ := beego.AppConfig.Int64("org_id")
- miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
- dir := miConfig.OrgName + "日志"
- utils.Mkdir(dir)
- month := time.Unix(1557042972, 0).Format("1")
- year := time.Now().Format("2006")
- month = time.Now().Format("01")
- day := time.Now().Format("02")
- hour := time.Now().Format("15")
- min := time.Now().Format("04")
- sec := time.Now().Format("05")
-
- result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
-
- file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
- file_name := file + ".txt"
- file_path := miConfig.OrgName + "日志" + "/" + file_name
- exist, _ := utils.PathExists(file_path)
- if exist { //存在
- fmt.Println("存在")
- f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
- if err != nil {
- fmt.Println("read fail")
- }
- content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
- n, _ := f.Seek(0, 2)
- _, err = f.WriteAt([]byte(content), n)
-
- } else { //不存在
- fmt.Println("文件不存在,创建文件")
- f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
- defer f.Close()
- if err != nil {
- } else {
- _, err = f.Write([]byte("记录日志"))
- }
- }
-
- }
-
- type Charset string
-
- const (
- UTF8 = Charset("UTF-8")
- GB18030 = Charset("GB18030")
- )
-
- func ConvertToString(src string, srcCode string, tagCode string) string {
- srcCoder := mahonia.NewDecoder(srcCode)
- srcResult := srcCoder.ConvertString(src)
- tagCoder := mahonia.NewDecoder(tagCode)
- _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
- result := string(cdata)
- return result
- }
-
- type ELeData struct {
- Data struct {
- IdNo string `json:"idNo"`
- IdType string `json:"idType"`
- UserName string `json:"userName"`
- EcToken string `json:"ecToken"`
- InsuOrg string `json:"insuOrg"`
- Gender string `json:"gender"`
- Birthday string `json:"birthday"`
- Nationality string `json:"nationality"`
- Email string `json:"email"`
- Extra string `json:"extra"`
- } `json:"data"`
- Code int `json:"code"`
- Message string `json:"message"`
- }
-
- var initFlagTwo int64 = 0
-
- func (c *ZHHisApiController) TestGetJiangXiBasBaseInit() {
- DllDef := syscall.MustLoadDLL("SSCard.dll")
- Iinit := DllDef.MustFindProc("Init")
- //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
- //http://10.77.211.236/CSB/hsa-fsi-1303
- ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360399"))
- if ret != 0 {
- fmt.Println("SSCard的报错原因:", err)
- fmt.Println("SSCard的运算结果为:", ret)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
- return
- }
-
- result := int(ret)
- fmt.Println("SSCard的运算结果为1:", result)
- initFlag = 1
- return
- }
- func (c *ZHHisApiController) GetBasBaseInfoxxx() string {
- DllDef := syscall.MustLoadDLL("SSCard.dll")
- readCard := DllDef.MustFindProc("ReadCardBas")
- if readCard == nil {
- fmt.Println("readcard is nil")
- readCard = DllDef.MustFindProc("ReadCardBas")
- }
- str := make([]byte, 1024)
- str1 := make([]byte, 1024)
- ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
- fmt.Println(string(str1))
- fmt.Println(string(str))
- fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
- fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
- if ret2 != 0 {
- return ""
- }
- return string(str)
- }
-
- func (c *ZHHisApiController) ReadEleCardfordevice() {
- admin_user_id, _ := c.GetInt64("admin_user_id")
- roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
- miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
- GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
- }
-
-
- func (c *ZHHisApiController) ReadCard() {
- id_card_type, _ := c.GetInt64("id_card_type")
- admin_user_id, _ := c.GetInt64("admin_user_id")
- is_settle := c.GetString("is_settle")
-
- roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
- miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
-
- switch id_card_type {
- case 1: //社保卡
- if miConfig.MdtrtareaAdmvs == "150499" {
- var api string
- api = "http://172.16.13.254:9532/" + "nmyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
- "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
-
- fmt.Println(api)
-
- resp, requestErr := http.Get(api)
- if requestErr != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- body, ioErr := ioutil.ReadAll(resp.Body)
- if ioErr != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- var respJSON map[string]interface{}
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- var status string
- status = respJSON["data"].(map[string]interface{})["status"].(string)
- card_type := respJSON["data"].(map[string]interface{})["type"].(string)
- //console.log()
- fmt.Println("type===")
-
- fmt.Println(card_type)
-
- var token string
- var res ResultTwo //1101结果
- var res10265 ResultTwo10265 //1101结果
- var card_info string //卡信息
- var busi_card_info string
-
- card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
- busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
-
- if status == "0" { //读卡成功
- if card_type == "1" {
-
- respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
- result, _ := json.Marshal(respJSON)
-
- if err := json.Unmarshal([]byte(result), &res10265); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- res.ErrMsg = res10265.ErrMsg
- infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
- res.Infcode = infocode
- res.Output = res10265.Output
- res.InfRefmsgid = res10265.InfRefmsgid
-
- } else {
- //var card_info string //卡信息
- //var busi_card_info string
-
- token = respJSON["data"].(map[string]interface{})["token"].(string)
- //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
-
- //fmt.Println(card_info)
- //fmt.Println(busi_card_info)
-
- respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
- result, _ := json.Marshal(respJSON)
-
- if err := json.Unmarshal([]byte(result), &res10265); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- res.ErrMsg = res10265.ErrMsg
- infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
- res.Infcode = infocode
- res.Output = res10265.Output
- res.InfRefmsgid = res10265.InfRefmsgid
-
- }
-
- if res.Infcode == 0 {
- var insutypes []string
- var insutype string
- var is390 int = 0
- var is310 int = 0
- for _, item := range res.Output.Iinfo {
- if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
- insutypes = append(insutypes, item.Insutype)
- }
- }
- if len(insutypes) == 1 {
- insutype = insutypes[0]
- } else {
- for _, i := range insutypes {
- if i == "390" {
- is390 = 1
- }
-
- if i == "310" {
- is310 = 1
- }
- }
- }
- if is390 == 1 {
- insutype = "390"
- }
- if is310 == 1 {
- insutype = "310"
- }
- if len(insutypes) == 0 {
- insutype = "310"
- }
-
- patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
- if err == gorm.ErrRecordNotFound {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
- return
- } else if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
-
- } else {
-
- if card_type == "1" {
- bas := strings.Split(card_info, "|")
- basNumber := bas[2]
- Iinfos, _ := json.Marshal(res.Output.Iinfo)
- Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
- infoStr := string(Iinfos)
- idetinfoStr := string(Idetinfos)
- psn := &models.HisPsn{
- PsnNo: res.Output.Baseinfo.PsnNo,
- Age: res.Output.Baseinfo.Age,
- PatientId: patient.ID,
- Certno: res.Output.Baseinfo.Certno,
- Gend: res.Output.Baseinfo.Gend,
- Naty: res.Output.Baseinfo.Naty,
- PsnCertType: res.Output.Baseinfo.PsnCertType,
- PsnName: res.Output.Baseinfo.PsnName,
- Idetinfo: idetinfoStr,
- Insuinfo: infoStr,
- UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
- CardInfo: card_info,
- VerifyNumber: busi_card_info,
- }
- service.CreateHisPsn(psn)
- c.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- "number": basNumber,
- "info": res,
- "insutype": insutype,
- })
- } else {
- Iinfos, _ := json.Marshal(res.Output.Iinfo)
- Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
- infoStr := string(Iinfos)
- idetinfoStr := string(Idetinfos)
- psn := &models.HisPsn{
- PsnNo: res.Output.Baseinfo.PsnNo,
- Age: res.Output.Baseinfo.Age,
- PatientId: patient.ID,
- Certno: res.Output.Baseinfo.Certno,
- Gend: res.Output.Baseinfo.Gend,
- Naty: res.Output.Baseinfo.Naty,
- PsnCertType: res.Output.Baseinfo.PsnCertType,
- PsnName: res.Output.Baseinfo.PsnName,
- Idetinfo: idetinfoStr,
- Insuinfo: infoStr,
- UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
- CardInfo: card_info,
- VerifyNumber: token,
- }
- service.CreateHisPsn(psn)
- c.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- "number": token,
- "info": res,
- "insutype": insutype,
- })
- }
- }
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
- return
- }
- } else { //读卡失败
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
- return
-
- }
-
- } else if miConfig.MdtrtareaAdmvs == "421182" {
- var res ResultTwohb
- api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
- "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
- "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&card_sn=" + "" + "&certificates=1"
-
- resp, requestErr := http.Get(api)
- if requestErr != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- body, ioErr := ioutil.ReadAll(resp.Body)
- if ioErr != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- var respJSON map[string]interface{}
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
- result, _ := json.Marshal(respJSON)
- fmt.Println("log")
- fmt.Println(string(result))
-
- if err := json.Unmarshal([]byte(result), &res); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- if res.Infcode == 0 {
- patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
- if err == gorm.ErrRecordNotFound {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
- return
- } else if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
-
- } else {
- var insuplc_admdvs_temp string
- var insutypes []string
- var insutype string
- var is390 int = 0
- var is310 int = 0
- for _, item := range res.Output.Iinfo {
- if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
- insutypes = append(insutypes, item.Insutype)
- }
- }
- if len(insutypes) == 1 {
- insutype = insutypes[0]
- } else {
- for _, i := range insutypes {
- if i == "390" {
- is390 = 1
- }
-
- if i == "310" {
- is310 = 1
- }
- }
- }
- if is390 == 1 {
- insutype = "390"
- }
- if is310 == 1 {
- insutype = "310"
- }
- if len(insutypes) == 0 {
- insutype = "310"
- }
-
- for _, item := range insutypes {
- if item == insutype {
- insuplc_admdvs_temp = item
- }
- }
- //insuplcAdmdvs := strconv.Itoa(insuplc_admdvs_temp)
- card_info_two := insuplc_admdvs_temp + "|" + res.Output.Baseinfo.Certno + "|" + res.Output.Baseinfo.ExpContent.MdtrtCertNo
-
- Iinfos, _ := json.Marshal(res.Output.Iinfo)
- Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
- infoStr := string(Iinfos)
- idetinfoStr := string(Idetinfos)
- psn := &models.HisPsn{
- PsnNo: res.Output.Baseinfo.PsnNo,
-
- PatientId: patient.ID,
- Certno: res.Output.Baseinfo.Certno,
-
- Gend: res.Output.Baseinfo.Gend,
- Naty: res.Output.Baseinfo.Naty,
- PsnCertType: res.Output.Baseinfo.PsnCertType,
- PsnName: res.Output.Baseinfo.PsnName,
- Idetinfo: idetinfoStr,
- Insuinfo: infoStr,
- UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
- InsuplcAdmdvs: insuplc_admdvs_temp,
- CardInfo:card_info_two,
-
-
- }
- service.CreateHisPsn(psn)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- "number": res.Output.Baseinfo.Certno,
- })
- }
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
- return
- }
-
- } else if miConfig.MdtrtareaAdmvs == "360399" {
- fmt.Println(initFlag)
- fmt.Println("initFlag")
-
- if initFlag == 0 {
- c.TestGetJiangXiBasBaseInit()
- }
- basStr := c.GetBasBaseInfoxxx()
- if len(basStr) == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
- return
- }
- fmt.Println(basStr)
- bas := strings.Split(basStr, "|")
- basNumber := bas[1]
- fmt.Println(basNumber)
- card_sn := bas[3]
- fmt.Println(card_sn)
- result, _ := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, "1", miConfig.Url, miConfig.AccessKey, "")
-
- //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
- var dat map[string]interface{}
- if err := json.Unmarshal([]byte(result), &dat); err == nil {
- fmt.Println(dat)
- } else {
- fmt.Println(err)
- }
-
- userJSONBytes, _ := json.Marshal(dat)
- var res ResultTwo
- if err := json.Unmarshal(userJSONBytes, &res); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- if res.Infcode == 0 {
- patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
- if err == gorm.ErrRecordNotFound {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
- return
- } else if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
-
- } else {
- Iinfos, _ := json.Marshal(res.Output.Iinfo)
- Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
- infoStr := string(Iinfos)
- idetinfoStr := string(Idetinfos)
- psn := &models.HisPsn{
- PsnNo: res.Output.Baseinfo.PsnNo,
- Age: res.Output.Baseinfo.Age,
- PatientId: patient.ID,
- Certno: res.Output.Baseinfo.Certno,
- Gend: res.Output.Baseinfo.Gend,
- Naty: res.Output.Baseinfo.Naty,
- PsnCertType: res.Output.Baseinfo.PsnCertType,
- PsnName: res.Output.Baseinfo.PsnName,
- Idetinfo: idetinfoStr,
- Insuinfo: infoStr,
- UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
- CardInfo: basStr,
- VerifyNumber: "",
- }
- service.CreateHisPsn(psn)
- var rf []*ResultFive
- json.Unmarshal([]byte(infoStr), &rf)
-
- var insutypes []*ResultFive
- var insutype string
- var is390 int = 0
- var is310 int = 0
-
- for _, item := range rf {
- if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
- insutypes = append(insutypes, item)
- }
- }
-
- if len(insutypes) == 1 {
- insutype = insutypes[0].Insutype
- //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
- } else {
- for _, i := range insutypes {
- if i.Insutype == "390" {
- is390 = 1
- }
-
- if i.Insutype == "310" {
- is310 = 1
- }
- }
- }
- if is390 == 1 {
- insutype = "390"
- }
-
- if is310 == 1 {
- insutype = "310"
- }
-
- if len(insutypes) == 0 {
- insutype = "310"
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- "number": basNumber,
- "info": res,
- "insutype": insutype,
- })
- }
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
- return
- }
-
- } else {
-
- if initFlagTwo == 0 {
- c.TestGetBasBaseInitTwo()
- }
- basStr := c.GetBasBaseInfoTwo()
- if len(basStr) == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
- return
- }
- fmt.Println(basStr)
- bas := strings.Split(basStr, "|")
- id_card_no := bas[1]
-
- result, _ := service.ZHGdyb1101B(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "", 1, "")
-
- //result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
- var dat map[string]interface{}
- if err := json.Unmarshal([]byte(result), &dat); err == nil {
- fmt.Println(dat)
- } else {
- fmt.Println(err)
- }
-
- userJSONBytes, _ := json.Marshal(dat)
- var res ResultTwo
- if err := json.Unmarshal(userJSONBytes, &res); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- if res.Infcode == 0 {
- patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
- if err == gorm.ErrRecordNotFound {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
- return
- } else if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
-
- } else {
- var insutypes []string
- var insutype string
- var is390 int = 0
- var is310 int = 0
- for _, item := range res.Output.Iinfo {
- if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
- insutypes = append(insutypes, item.Insutype)
- }
- }
- if len(insutypes) == 1 {
- insutype = insutypes[0]
- } else {
- for _, i := range insutypes {
- if i == "390" {
- is390 = 1
- }
-
- if i == "310" {
- is310 = 1
- }
- }
- }
- if is390 == 1 {
- insutype = "390"
- }
- if is310 == 1 {
- insutype = "310"
- }
- if len(insutypes) == 0 {
- insutype = "310"
- }
-
- Iinfos, _ := json.Marshal(res.Output.Iinfo)
- Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
- infoStr := string(Iinfos)
- idetinfoStr := string(Idetinfos)
- psn := &models.HisPsn{
- PsnNo: res.Output.Baseinfo.PsnNo,
- Age: res.Output.Baseinfo.Age,
- PatientId: patient.ID,
- Certno: res.Output.Baseinfo.Certno,
- Gend: res.Output.Baseinfo.Gend,
- Naty: res.Output.Baseinfo.Naty,
- PsnCertType: res.Output.Baseinfo.PsnCertType,
- PsnName: res.Output.Baseinfo.PsnName,
- Idetinfo: idetinfoStr,
- Insuinfo: infoStr,
- UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
- CardInfo: basStr,
- VerifyNumber: "",
- }
- service.CreateHisPsn(psn)
- c.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- "number": id_card_no,
- "info": res,
- "insutype": insutype,
- })
- }
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
- return
- }
-
- }
- break
- case 2:
- if miConfig.MdtrtareaAdmvs == "421182" {
- var res ResultTwohb
- api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
- "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
- "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&card_sn=" + "" + "&certificates=1"
-
- resp, requestErr := http.Get(api)
- if requestErr != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- body, ioErr := ioutil.ReadAll(resp.Body)
- if ioErr != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- var respJSON map[string]interface{}
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
- result, _ := json.Marshal(respJSON)
- fmt.Println("log")
- fmt.Println(string(result))
-
- if err := json.Unmarshal([]byte(result), &res); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- if res.Infcode == 0 {
- patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
- if err == gorm.ErrRecordNotFound {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
- return
- } else if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
-
- } else {
- var insuplc_admdvs_temp string
- var insutypes []string
- var insutype string
- var is390 int = 0
- var is310 int = 0
- for _, item := range res.Output.Iinfo {
- if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
- insutypes = append(insutypes, item.Insutype)
- }
- }
- if len(insutypes) == 1 {
- insutype = insutypes[0]
- } else {
- for _, i := range insutypes {
- if i == "390" {
- is390 = 1
- }
-
- if i == "310" {
- is310 = 1
- }
- }
- }
- if is390 == 1 {
- insutype = "390"
- }
- if is310 == 1 {
- insutype = "310"
- }
- if len(insutypes) == 0 {
- insutype = "310"
- }
-
- for _, item := range insutypes {
- if item == insutype {
- insuplc_admdvs_temp = item
- }
- }
- //insuplcAdmdvs := strconv.Itoa(insuplc_admdvs_temp)
- card_info_two := insuplc_admdvs_temp + "|" + res.Output.Baseinfo.Certno + "|" + res.Output.Baseinfo.ExpContent.MdtrtCertNo
-
- Iinfos, _ := json.Marshal(res.Output.Iinfo)
- Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
- infoStr := string(Iinfos)
- idetinfoStr := string(Idetinfos)
- psn := &models.HisPsn{
- PsnNo: res.Output.Baseinfo.PsnNo,
-
- PatientId: patient.ID,
- Certno: res.Output.Baseinfo.Certno,
-
- Gend: res.Output.Baseinfo.Gend,
- Naty: res.Output.Baseinfo.Naty,
- PsnCertType: res.Output.Baseinfo.PsnCertType,
- PsnName: res.Output.Baseinfo.PsnName,
- Idetinfo: idetinfoStr,
- Insuinfo: infoStr,
- UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
- InsuplcAdmdvs: insuplc_admdvs_temp,
- CardInfo:card_info_two,
-
-
- }
- service.CreateHisPsn(psn)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- "number": res.Output.Baseinfo.Certno,
- })
- }
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
- return
- }
-
- }
- case 4: //电子凭证
- if miConfig.MdtrtareaAdmvs == "150499" {
- var api string
- api = "http://172.16.13.254:9532/" + "nmyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
- "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName + "&is_settle=" + is_settle
-
- resp, requestErr := http.Get(api)
- if requestErr != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- body, ioErr := ioutil.ReadAll(resp.Body)
- if ioErr != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- var respJSON map[string]interface{}
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- var status string
- status = respJSON["data"].(map[string]interface{})["status"].(string)
- //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
- var token string
- var res ResultTwo //1101结果
- var res10265 ResultTwo10265 //1101结果
- if status == "0" { //读卡成功
- token = respJSON["data"].(map[string]interface{})["token"].(string)
- respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
- result, _ := json.Marshal(respJSON)
- if err := json.Unmarshal([]byte(result), &res10265); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- res.ErrMsg = res10265.ErrMsg
- infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
- res.Infcode = infocode
- res.Output = res10265.Output
- res.InfRefmsgid = res10265.InfRefmsgid
-
- if res.Infcode == 0 {
- patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
- if err == gorm.ErrRecordNotFound {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
- return
- } else if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- } else {
- Iinfos, _ := json.Marshal(res.Output.Iinfo)
- Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
- infoStr := string(Iinfos)
- idetinfoStr := string(Idetinfos)
- psn := &models.HisPsn{
- PsnNo: res.Output.Baseinfo.PsnNo,
- Age: res.Output.Baseinfo.Age,
- PatientId: patient.ID,
- Certno: res.Output.Baseinfo.Certno,
- Gend: res.Output.Baseinfo.Gend,
- Naty: res.Output.Baseinfo.Naty,
- PsnCertType: res.Output.Baseinfo.PsnCertType,
- PsnName: res.Output.Baseinfo.PsnName,
- Idetinfo: idetinfoStr,
- Insuinfo: infoStr,
- UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
- CardInfo: "",
- VerifyNumber: token,
- }
- service.CreateHisPsn(psn)
-
- var insutypes []string
- var insutype string
- var is390 int = 0
- var is310 int = 0
- for _, item := range res.Output.Iinfo {
- if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
- insutypes = append(insutypes, item.Insutype)
- }
- }
- if len(insutypes) == 1 {
- insutype = insutypes[0]
- } else {
- for _, i := range insutypes {
- if i == "390" {
- is390 = 1
- }
-
- if i == "310" {
- is310 = 1
- }
- }
- }
- if is390 == 1 {
- insutype = "390"
- }
- if is310 == 1 {
- insutype = "310"
- }
- if len(insutypes) == 0 {
- insutype = "390"
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "failed_code": 0,
- "info": res,
- "insutype": insutype,
- "patient": patient,
- })
- }
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
- return
- }
- }
- } else if miConfig.MdtrtareaAdmvs == "421182" {
- var res ResultTwohb
- api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
- "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
- "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&card_sn=" + "" + "&certificates=1"
-
- resp, requestErr := http.Get(api)
- if requestErr != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- body, ioErr := ioutil.ReadAll(resp.Body)
- if ioErr != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- var respJSON map[string]interface{}
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
- result, _ := json.Marshal(respJSON)
- fmt.Println("log")
- fmt.Println(string(result))
-
- if err := json.Unmarshal([]byte(result), &res); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- if res.Infcode == 0 {
- patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
- if err == gorm.ErrRecordNotFound {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
- return
- } else if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
-
- } else {
- var insuplc_admdvs_temp string
- var insutypes []string
- var insutype string
- var is390 int = 0
- var is310 int = 0
- for _, item := range res.Output.Iinfo {
- if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
- insutypes = append(insutypes, item.Insutype)
- }
- }
- if len(insutypes) == 1 {
- insutype = insutypes[0]
- } else {
- for _, i := range insutypes {
- if i == "390" {
- is390 = 1
- }
-
- if i == "310" {
- is310 = 1
- }
- }
- }
- if is390 == 1 {
- insutype = "390"
- }
- if is310 == 1 {
- insutype = "310"
- }
- if len(insutypes) == 0 {
- insutype = "310"
- }
-
- for _, item := range insutypes {
- if item == insutype {
- insuplc_admdvs_temp = item
- }
- }
- //insuplcAdmdvs := strconv.Itoa(insuplc_admdvs_temp)
- card_info_two := insuplc_admdvs_temp + "|" + res.Output.Baseinfo.Certno + "|" + res.Output.Baseinfo.ExpContent.MdtrtCertNo
-
- Iinfos, _ := json.Marshal(res.Output.Iinfo)
- Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
- infoStr := string(Iinfos)
- idetinfoStr := string(Idetinfos)
- psn := &models.HisPsn{
- PsnNo: res.Output.Baseinfo.PsnNo,
-
- PatientId: patient.ID,
- Certno: res.Output.Baseinfo.Certno,
-
- Gend: res.Output.Baseinfo.Gend,
- Naty: res.Output.Baseinfo.Naty,
- PsnCertType: res.Output.Baseinfo.PsnCertType,
- PsnName: res.Output.Baseinfo.PsnName,
- Idetinfo: idetinfoStr,
- Insuinfo: infoStr,
- UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
- InsuplcAdmdvs: insuplc_admdvs_temp,
- CardInfo:card_info_two,
-
-
- }
- service.CreateHisPsn(psn)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- "number": res.Output.Baseinfo.Certno,
- })
- }
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
- return
- }
-
- } else if miConfig.MdtrtareaAdmvs =="360399"{
- //if initFlag == 0 {
- //c.TestGetJiangXiBasBaseInit()
- //}
- //if initEleFlag == 0 {
- // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
- //}
- //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
-
- _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
-
- //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
- type ELeData struct {
- Data struct {
- IdNo string `json:"idNo"`
- IdType string `json:"idType"`
- UserName string `json:"userName"`
- EcToken string `json:"ecToken"`
- InsuOrg string `json:"insuOrg"`
- Gender string `json:"gender"`
- Birthday string `json:"birthday"`
- Nationality string `json:"nationality"`
- Email string `json:"email"`
- Extra string `json:"extra"`
- } `json:"data"`
- Code int `json:"code"`
- Message string `json:"message"`
- }
-
- var ele ELeData
- err := json.Unmarshal([]byte(result), &ele)
- if err != nil {
- utils.ErrorLog("解析失败:%v", err)
- }
- token := ele.Data.EcToken
- token = Remove0000(token)
- result2, requestLog2 := service.Jxyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
- saveLog(result2, requestLog2, "1101", "获取人员信息")
- var res ResultTwo
- if err := json.Unmarshal([]byte(result2), &res); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- if res.Infcode == 0 {
- patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
- if err == gorm.ErrRecordNotFound {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
- return
- } else if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- } else {
- Iinfos, _ := json.Marshal(res.Output.Iinfo)
- Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
- infoStr := string(Iinfos)
- idetinfoStr := string(Idetinfos)
- psn := &models.HisPsn{
- PsnNo: res.Output.Baseinfo.PsnNo,
- Age: res.Output.Baseinfo.Age,
- PatientId: patient.ID,
- Certno: res.Output.Baseinfo.Certno,
- Gend: res.Output.Baseinfo.Gend,
- Naty: res.Output.Baseinfo.Naty,
- PsnCertType: res.Output.Baseinfo.PsnCertType,
- PsnName: res.Output.Baseinfo.PsnName,
- Idetinfo: idetinfoStr,
- Insuinfo: infoStr,
- UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
- CardInfo: "",
- VerifyNumber: token,
- }
- service.CreateHisPsn(psn)
- var rf []*ResultFive
- json.Unmarshal([]byte(infoStr), &rf)
-
- var insutypes []*ResultFive
- var insutype string
- var is390 int = 0
- var is310 int = 0
-
- for _, item := range rf {
- if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
- insutypes = append(insutypes, item)
- }
- }
-
- if len(insutypes) == 1 {
- insutype = insutypes[0].Insutype
- //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
- } else {
- for _, i := range insutypes {
- if i.Insutype == "390" {
- is390 = 1
- }
-
- if i.Insutype == "310" {
- is310 = 1
- }
- }
- }
- if is390 == 1 {
- insutype = "390"
- }
-
- if is310 == 1 {
- insutype = "310"
- }
-
- if len(insutypes) == 0 {
- insutype = "310"
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- "number": token,
- "info": res,
- "insutype": insutype,
- })
- }
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
- return
- }
-
-
-
-
- }else {
- if initFlagTwo == 0 {
- c.TestGetBasBaseInitTwo()
- }
- token := c.GetEleBaseInfoTwo()
- token = Remove0000(token)
- result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
- saveLog(result2, requestLog2, "1101", "获取人员信息")
- //
- var res ResultTwo
- if err := json.Unmarshal([]byte(result2), &res); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- if res.Infcode == 0 {
- patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
- if err == gorm.ErrRecordNotFound {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
- return
- } else if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
-
- } else {
- var insutypes []string
- var insutype string
- var is390 int = 0
- var is310 int = 0
- for _, item := range res.Output.Iinfo {
- if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
- insutypes = append(insutypes, item.Insutype)
- }
- }
- if len(insutypes) == 1 {
- insutype = insutypes[0]
- } else {
- for _, i := range insutypes {
- if i == "390" {
- is390 = 1
- }
-
- if i == "310" {
- is310 = 1
- }
- }
- }
- if is390 == 1 {
- insutype = "390"
- }
- if is310 == 1 {
- insutype = "310"
- }
- if len(insutypes) == 0 {
- insutype = "310"
- }
-
- Iinfos, _ := json.Marshal(res.Output.Iinfo)
- Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
- infoStr := string(Iinfos)
- idetinfoStr := string(Idetinfos)
- psn := &models.HisPsn{
- PsnNo: res.Output.Baseinfo.PsnNo,
- Age: res.Output.Baseinfo.Age,
- PatientId: patient.ID,
- Certno: res.Output.Baseinfo.Certno,
- Gend: res.Output.Baseinfo.Gend,
- Naty: res.Output.Baseinfo.Naty,
- PsnCertType: res.Output.Baseinfo.PsnCertType,
- PsnName: res.Output.Baseinfo.PsnName,
- Idetinfo: idetinfoStr,
- Insuinfo: infoStr,
- UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
- CardInfo: "",
- VerifyNumber: token,
- }
- service.CreateHisPsn(psn)
- c.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- "number": token,
- "info": res,
- "insutype": insutype,
- })
- }
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
- return
- }
-
- }
- break
- }
- }
- func GetjxELekeyInfo(code string, operator_id string, operator_name string) (string, string) {
- // WebSocket服务器地址
- serverURL := "ws://127.0.0.1:8899"
-
- // 解析WebSocket服务器地址
- u, err := url.Parse(serverURL)
- if err != nil {
-
- }
-
- // 建立WebSocket连接
- conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
- if err != nil {
-
- }
- defer conn.Close()
- input2 := make(map[string]interface{})
-
- input := make(map[string]interface{})
- inputData := make(map[string]interface{})
- inputData["orgId"] = code
- inputData["businessType"] = "01101"
- inputData["operatorId"] = operator_id
- inputData["operatorName"] = operator_name
- inputData["officeId"] = "001"
- inputData["officeName"] = "血透室"
- inputData["deviceType"] = ""
- input["data"] = inputData
- input["orgId"] = code
- input["transType"] = "ec.query"
- //if md == ""
-
- input2["url"] = "http://10.77.211.236/1.0.0/getEncDynamicKey"
-
-
- input2["indata"] = input
- fmt.Println(input2)
-
- bytesData, _ := json.Marshal(input2)
- err = conn.WriteMessage(websocket.TextMessage, bytesData)
- if err != nil {
- fmt.Println(err)
- }
-
- // 接收消息
- _, receivedMessage, err := conn.ReadMessage()
- if err != nil {
- fmt.Println(err)
- }
-
- return "", string(receivedMessage)
- }
-
- func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
- // WebSocket服务器地址
- serverURL := "ws://127.0.0.1:8899"
-
- // 解析WebSocket服务器地址
- u, err := url.Parse(serverURL)
- if err != nil {
-
- }
-
- // 建立WebSocket连接
- conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
- if err != nil {
-
- }
- defer conn.Close()
- input2 := make(map[string]interface{})
-
- input := make(map[string]interface{})
- inputData := make(map[string]interface{})
- inputData["orgId"] = code
- inputData["businessType"] = "01103"
- inputData["operatorId"] = operator_id
- inputData["operatorName"] = operator_name
- inputData["officeId"] = "001"
- inputData["officeName"] = "血透室"
- inputData["deviceType"] = ""
- input["data"] = inputData
- input["orgId"] = code
- input["transType"] = "ec.query"
- //if md ==
- input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
-
- input2["indata"] = input
- fmt.Println(input2)
-
- bytesData, _ := json.Marshal(input2)
- err = conn.WriteMessage(websocket.TextMessage, bytesData)
- if err != nil {
- fmt.Println(err)
- }
-
- // 接收消息
- _, receivedMessage, err := conn.ReadMessage()
- if err != nil {
- fmt.Println(err)
- }
-
- return "", string(receivedMessage)
- }
-
-
- func (c *ZHHisApiController) GetEleBaseInfoTwo() string {
- DllDef := syscall.MustLoadDLL("SSCard.dll")
- readCard := DllDef.MustFindProc("GetQRBase")
- fmt.Println(readCard)
-
- if readCard == nil {
- fmt.Println("readcard is nil")
- readCard = DllDef.MustFindProc("GetQRBase")
- }
- str := make([]byte, 1024)
- str1 := make([]byte, 1024)
- ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
- fmt.Println(ret2)
- fmt.Println(string(str1))
- fmt.Println(string(str))
- fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
- fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
- if ret2 != 0 {
- return ""
- }
- return string(str)
- }
-
- func (c *ZHHisApiController) TestGetBasBaseInitTwo() {
- DllDef := syscall.MustLoadDLL("SSCard.dll")
- Iinit := DllDef.MustFindProc("Init")
- miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
-
- ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.MdtrtareaAdmvs))
- if ret != 0 {
- fmt.Println("SSCard的报错原因:", err)
- fmt.Println("SSCard的运算结果为:", ret)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
- return
- }
-
- result := int(ret)
- fmt.Println("SSCard的运算结果为1:", result)
- initFlagTwo = 1
- return
- }
-
- func (c *ZHHisApiController) GetBasBaseInfoTwo() string {
- DllDef := syscall.MustLoadDLL("SSCard.dll")
- readCard := DllDef.MustFindProc("ReadCardBas")
- if readCard == nil {
- fmt.Println("readcard is nil")
- readCard = DllDef.MustFindProc("ReadCardBas")
- }
- str := make([]byte, 1024)
- str1 := make([]byte, 1024)
- ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
- fmt.Println(string(str1))
- fmt.Println(string(str))
- fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
- fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
- if ret2 != 0 {
- return ""
- }
- return string(str)
- }
-
- var initFlag int64 = 0
-
- func (c *ZHHisApiController) TestGetBasBaseInit() {
- DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
- Iinit := DllDef.MustFindProc("Init")
- //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
- str := make([]byte, 2048)
- inputData := make(map[string]interface{})
- inputData["IP"] = "10.144.211.75"
- inputData["PORT"] = 7021
- inputData["TIMEOUT"] = 180
- inputData["LOG_PATH"] = "C:\\log\\"
- //inputData["SFZ_DRIVER_TYPE"] = 0
- inputData["URL"] = "/call1"
-
- bytesData, _ := json.Marshal(inputData)
- fmt.Println(inputData)
- fmt.Println(bytesData)
-
- ret, _, err := Iinit.Call((uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str[0])))
- if ret != 0 {
- fmt.Println("SSCard的报错原因:", err)
- fmt.Println("SSCard的运算结果为:", ret)
- fmt.Println("SSCard的返回结果为:", string(str))
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
- return
- }
- fmt.Println("SSCard的返回结果为:", string(str))
-
- result := int(ret)
- fmt.Println("SSCard的运算结果为1:", result)
- //initFlag = 1
- return
- }
-
- func (c *ZHHisApiController) GetSFZBaseInfo() string {
- DllDef := syscall.MustLoadDLL("SSCard.dll")
- readCard := DllDef.MustFindProc("ReadSFZ")
- if readCard == nil {
- fmt.Println("readcard is nil")
- readCard = DllDef.MustFindProc("ReadSFZ")
- }
-
- str := make([]byte, 256)
- str1 := make([]byte, 256)
- r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
-
- fmt.Println(r)
- return string(str)
- }
-
- func (c *ZHHisApiController) GetBasBaseInfo(fixmedins_code string, mdtrtarea_admvs string, opter_name string, opter_id string, fixmedins_name string) string {
- DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
- readCard := DllDef.MustFindProc("ReadCardBas")
- fmt.Println(readCard)
- fmt.Println("!!!!!")
-
- month := time.Unix(1557042972, 0).Format("1")
- year := time.Now().Format("2006")
- month = time.Now().Format("01")
- day := time.Now().Format("02")
-
- hour := time.Now().Format("15")
- min := time.Now().Format("04")
- sec := time.Now().Format("05")
-
- msec := time.Now().Format("000")
- timestamp := time.Now().Unix()
-
- tempTime := time.Unix(timestamp, 0)
- //timeFormat := tempTime.Format("20060102150405")
- timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
- //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
-
- inputData := make(map[string]interface{})
- inputData["infno"] = "1199"
- //inputData["msgid"] = "7021"
- inputData["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
- inputData["mdtrtarea_admvs"] = mdtrtarea_admvs // 发送方报文 ID
- inputData["recer_sys_code"] = "01"
- inputData["infver"] = "V1.0"
- inputData["opter_type"] = "1"
- inputData["opter"] = opter_id
- inputData["opter_name"] = opter_name
- inputData["inf_time"] = timeFormatOne
- inputData["fixmedins_code"] = fixmedins_code
- inputData["fixmedins_name"] = fixmedins_name
-
- inputData["dev_no"] = ""
- inputData["dev_safe_info"] = ""
- inputData["cainfo"] = ""
- inputData["signtype"] = ""
- inputData["sign_no"] = ""
-
- bytesData, _ := json.Marshal(inputData)
- fmt.Println(string(bytesData))
- pBusiCardInfo := make([]byte, 8192)
- ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
- fmt.Println(ret2)
- fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
- fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
- if ret2 != 0 {
- return ""
- }
- return DeleteExtraSpace(string(pBusiCardInfo))
- }
-
- func DeleteExtraSpace(s string) string {
- //删除字符串中的多余空格,有多个空格时,仅保留一个空格
- s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
- regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
- reg, _ := regexp.Compile(regstr) //编译正则表达式
- s2 := make([]byte, len(s1)) //定义字符数组切片
- copy(s2, s1) //将字符串复制到切片
- spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
- for len(spc_index) > 0 { //找到适配项
- s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
- spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
- }
- return string(s2)
- }
-
- func (c *ZHHisApiController) GetELeInfo(code string, operator_id string, operator_name string) (string, string) {
- DllDef := syscall.MustLoadDLL("NationECCode.dll")
- readCard := DllDef.MustFindProc("NationEcTrans")
- fmt.Println(readCard)
- fmt.Println("!!!!!")
- pBusiCardInfo := make([]byte, 8192)
- input := make(map[string]interface{})
- inputData := make(map[string]interface{})
- inputData["orgId"] = code
- inputData["businessType"] = "01101"
- inputData["operatorId"] = operator_id
- inputData["operatorName"] = operator_name
- inputData["officeId"] = "001"
- inputData["officeName"] = "血透室"
- inputData["deviceType"] = ""
- input["data"] = inputData
- input["orgId"] = code
- input["transType"] = "ec.query"
-
- bytesData, _ := json.Marshal(input)
- gdyb_url := beego.AppConfig.String("gdyb_url")
-
- url := gdyb_url + "/localcfc/api/hsecfc/localQrCodeQuery"
- ret2, _, _ := readCard.Call(StrPtr(url), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
- fmt.Println(ret2)
- fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
- fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
- if ret2 != 0 {
- return "", ""
- }
- return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
- }
-
- func StrPtr(s string) uintptr {
- return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
- }
-
- func Remove0000(s string) string {
- str := make([]rune, 0, len(s))
- for _, v := range []rune(s) {
- if v == 0 {
- continue
- }
- str = append(str, v)
- }
- return string(str)
- }
-
- func IntPtr(n int) uintptr {
- return uintptr(n)
- }
-
- func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
- newArr = make([]string, 0)
- for i := 0; i < len(arr); i++ {
- repeat := false
- for j := i + 1; j < len(arr); j++ {
- if arr[i] == arr[j] {
- repeat = true
- break
- }
- }
- if !repeat {
- newArr = append(newArr, arr[i])
- }
- }
- return
- }
-
- type Result3101 struct {
- Infcode int64 `json:"infcode"`
- InfRefmsgid string `json:"inf_refmsgid"`
- RefmsgTime string `json:"refmsg_time"`
- RespondTime string `json:"respond_time"`
- Enctype string `json:"enctype"`
- Signtype string `json:"signtype"`
- ErrMsg string `json:"err_msg"`
- Output struct {
- Result []struct {
- JudgeResultDetailDtos []struct {
- VolaItemType string `json:"vola_item_type"`
- MdtrtID string `json:"mdtrt_id"`
- JrdID string `json:"jrd_id"`
- PatnID string `json:"patn_id"`
- RxID string `json:"rx_id"`
- VolaAmt interface{} `json:"vola_amt"`
- } `json:"judge_result_detail_dtos"`
- RuleID string `json:"rule_id"`
- VolaEvid string `json:"vola_evid"`
- MdtrtID string `json:"mdtrt_id"`
- RuleName string `json:"rule_name"`
- VolaAmtStas string `json:"vola_amt_stas"`
- JrID string `json:"jr_id"`
- PatnID string `json:"patn_id"`
- SevDeg string `json:"sev_deg"`
- VolaAmt float64 `json:"vola_amt"`
- VolaBhvrType string `json:"vola_bhvr_type"`
- VolaCont string `json:"vola_cont"`
- } `json:"result"`
- } `json:"output"`
- }
-
- func Check3101ForOne(c *ZHHisApiController, patient_id int64, his service.Struct2401, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription, ress ResultTwo, record_date int64) (res2 Result3101) {
- var res Result3101
- adminUser := c.GetAdminUserInfo()
- roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
- //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
- miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
- //record_time := c.GetString("record_time")
- //trig_scen := c.GetString("trig_scen")
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return res
- }
- recordDateTime := theTime.Unix()
- p, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
- var patientPrescription models.HisPrescriptionInfo
- //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
- //if patientPrescription.ID == 0 {
- patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
- //}
- department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
- doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
- //
- diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
-
- //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
-
- var pp models.PublicParams
- pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
- pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
- pp.FixmedinsName = miConfig.OrgName
- pp.FixmedinsCode = miConfig.Code
-
- pp.RequestUrl = miConfig.Url
- pp.Cainfo = miConfig.Cainfo
- pp.SecretKey = miConfig.SecretKey
- pp.AccessKey = miConfig.AccessKey
- pp.OpterName = roles.UserName
-
- var config []*models.HisXtDiagnoseConfig
- for _, item := range diagnosis_ids {
- id, _ := strconv.ParseInt(item, 10, 64)
- if id > 0 {
- diagnosisConfig, _ := service.FindDiagnoseById(id)
- config = append(config, &diagnosisConfig)
- }
- }
-
- var pd models.PatientDtos
- pd.PatnID = his.PsnNo
- pd.PatnName = p.Name
- pd.Gend = ress.Output.Baseinfo.Gend
- pd.Poolarea = miConfig.MdtrtareaAdmvs
- pd.CurrMdtrtID = strconv.FormatInt(patientPrescription.ID, 10)
-
- var fed models.FsiEncounterDtos
- fed.MdtrtID = p.IdCardNo
- fed.MedinsID = miConfig.Code
- fed.MedinsName = miConfig.OrgName
- fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
- fed.MedMdtrtType = "1"
- fed.MedinsType = "1"
- fed.MedinsLv = "11"
- tm := time.Unix(record_date, 0)
- s_tm := tm.Format("2006-01-02 15:04:05")
- fed.AdmDate = s_tm
- fed.DscgDate = s_tm
- fed.DscgMainDiseCodg = config[0].CountryCode
- fed.DscgMainDiseName = config[0].CountryContentName
- //诊断信息
- var fdds []*models.FsiDiagnoseDtos
- for index, item := range config {
- if index == 0 {
- var fdd models.FsiDiagnoseDtos
- fdd.DiseID = strconv.FormatInt(item.ID, 10)
- fdd.InoutDiseType = "1"
- fdd.MaindiseFlag = "1"
- fdd.DiseDate = s_tm
- fdd.DiasSrtNo = "1"
- fdd.DiseName = item.CountryContentName
- fdd.DiseCodg = item.CountryCode
- fdds = append(fdds, &fdd)
-
- } else {
- var fdd models.FsiDiagnoseDtos
- fdd.DiseID = strconv.FormatInt(item.ID, 10)
- fdd.InoutDiseType = "1"
- fdd.MaindiseFlag = "1"
- fdd.DiseDate = s_tm
- fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
- fdd.DiseName = item.CountryContentName
- fdd.DiseCodg = item.CountryCode
- fdds = append(fdds, &fdd)
- }
- }
- fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
- fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
- fed.AdmDeptName = department.Name
- fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
- fed.DscgDeptName = department.Name
- fed.MedMdtrtType = "1"
- fed.MedType = "11"
- //if his.Insutype == "390" {
- // fed.MedType = "1402"
- //} else {
- // fed.MedType = "9933"
- //}
- var orders []*models.FsiOrderDtos
-
- if trig_scen == "4" {
- //处方医嘱信息
- for _, item := range prescriptions {
- for _, subItem := range item.HisDoctorAdviceInfo {
- if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 && subItem.BaseDrugLib.IsUser != 1 {
- spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
- var order models.FsiOrderDtos
- order.RxID = strconv.FormatInt(item.ID, 10)
- order.Rxno = strconv.FormatInt(item.ID, 10)
- order.LongDrordFlag = "0"
- order.HilistType = "1"
- order.ChrgType = "1"
- order.DrordBhvr = "0"
- order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
- order.HosplistName = subItem.BaseDrugLib.DrugName
- order.HilistLv = "1"
- order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
- order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
- order.HosplistName = subItem.BaseDrugLib.DrugName
- order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
- order.Pric = fmt.Sprintf("%.2f", subItem.Price)
- order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
- order.OwnpayAmt = ""
- order.SelfpayAmt = ""
- order.Spec = spec
- order.SpecUnt = subItem.PrescribingNumberUnit
- order.DrordBegnDate = s_tm
- order.DrordStopDate = ""
- order.DrordDrCodg = doctor_info.DoctorNumber
- order.DrordDeptName = department.Name
- order.DrordDeptCodg = department.Number
- order.DrordDrName = doctor_info.UserName
- order.DrordDrProfttl = "234"
- order.CurrDrordFlag = "1"
- orders = append(orders, &order)
- }
- }
- for _, subItem := range item.HisPrescriptionProject {
- if len(subItem.HisProject.MedicalCode) > 0 {
- if subItem.Type == 2 {
- var order models.FsiOrderDtos
- order.RxID = strconv.FormatInt(item.ID, 10)
- order.Rxno = strconv.FormatInt(item.ID, 10)
- order.LongDrordFlag = "0"
- order.HilistType = "1"
- order.ChrgType = "1"
- order.DrordBhvr = "0"
- order.HilistCode = subItem.HisProject.MedicalCode
- order.HosplistName = subItem.HisProject.ProjectName
- order.HilistLv = "1"
- order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
- order.HosplistCode = subItem.HisProject.MedicalCode
- order.HosplistName = subItem.HisProject.ProjectName
- order.Cnt = subItem.Count
- cnt, _ := strconv.ParseFloat(subItem.Count, 64)
- order.Pric = fmt.Sprintf("%.2f", subItem.Price)
- order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
- order.OwnpayAmt = ""
- order.SelfpayAmt = ""
- order.Spec = subItem.Unit
- order.SpecUnt = subItem.Unit
- order.DrordBegnDate = s_tm
- order.DrordStopDate = ""
- order.DrordDrCodg = doctor_info.DoctorNumber
- order.DrordDeptName = department.Name
- order.DrordDeptCodg = department.Number
- order.DrordDrName = doctor_info.UserName
- order.DrordDrProfttl = "234"
- order.CurrDrordFlag = "1"
- orders = append(orders, &order)
- }
- }
- if subItem.Type == 3 {
- if len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 && subItem.GoodInfo.IsUser != 1 {
- var order models.FsiOrderDtos
- order.RxID = strconv.FormatInt(item.ID, 10)
- order.Rxno = strconv.FormatInt(item.ID, 10)
- order.LongDrordFlag = "0"
- order.HilistType = "1"
- order.ChrgType = "1"
- order.DrordBhvr = "0"
- order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
- order.HosplistName = subItem.GoodInfo.GoodName
- order.HilistLv = "1"
- order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
- order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
- order.HosplistName = subItem.GoodInfo.GoodName
- order.Cnt = subItem.Count
- cnt, _ := strconv.ParseFloat(subItem.Count, 64)
- order.Pric = fmt.Sprintf("%.2f", subItem.Price)
- order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
- order.OwnpayAmt = ""
- order.SelfpayAmt = ""
- order.Spec = subItem.GoodInfo.SpecificationName
- order.SpecUnt = subItem.Unit
- order.DrordBegnDate = s_tm
- order.DrordStopDate = ""
- order.DrordDrCodg = doctor_info.DoctorNumber
- order.DrordDeptName = department.Name
- order.DrordDeptCodg = department.Number
- order.DrordDrName = doctor_info.UserName
- order.DrordDrProfttl = "234"
- order.CurrDrordFlag = "1"
- orders = append(orders, &order)
-
- }
- }
- }
- }
- //处方医嘱信息
- }
- fed.MatnStas = "0"
- fed.MedfeeSumamt = "0"
- fed.OwnpayAmt = "0"
- fed.SelfpayAmt = "0"
- fed.AcctPayamt = "0"
- fed.MaAmt = "0"
- fed.HifpPayamt = "0"
- fed.SetlTotlnum = "1"
- fed.Insutype = his.Insutype
- fed.ReimFlag = "0"
- fed.OutSetlFlag = "0"
-
- var fopd []*models.FsiOperationDtosData
- data := make(map[string]interface{})
- data["fed"] = fed
- data["fdd"] = fdds
- data["fod"] = orders
- data["pd"] = pd
- data["pp"] = pp
- data["fopd"] = fopd
- data["trig_scen"] = trig_scen
- fmt.Println(data)
- fmt.Println(fed)
- fmt.Println(fdds)
- fmt.Println(orders)
- fmt.Println(pd)
- fmt.Println(pp)
- fmt.Println(fopd)
-
- client := &http.Client{}
- bytesData, _ := json.Marshal(data)
- var req *http.Request
-
- if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
-
- if miConfig.MdtrtareaAdmvs == "320921" {
- req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
- } else {
- req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
- }
- resp, _ := client.Do(req)
- defer resp.Body.Close()
- body, ioErr := ioutil.ReadAll(resp.Body)
- if ioErr != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return res
- }
- var respJSON map[string]interface{}
- if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return res
- }
- respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
- fmt.Println(respJSON)
- result, _ := json.Marshal(respJSON)
- fmt.Println(result)
- if err := json.Unmarshal([]byte(result), &res); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return res
- }
-
- return res
- } else {
- //if miConfig.MdtrtareaAdmvs == "441202" {
- output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
- saveLog(output, input, "3101", "事前")
- if err := json.Unmarshal([]byte(output), &res); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- return res
- //}
- }
- }
- func Check3101(c *ZHHisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res Result3101) {
-
- adminUser := c.GetAdminUserInfo()
- roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
- his, _ := service.GetInHospitalRecord(his_patient_id)
- miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
- //record_time := c.GetString("record_time")
- //trig_scen := c.GetString("trig_scen")
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return res
- }
- recordDateTime := theTime.Unix()
-
- var patientPrescription models.HisPrescriptionInfo
- patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
- if patientPrescription.ID == 0 {
- patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
- }
- department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
- doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
- //
- diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
- p, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
-
- //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
-
- var pp models.PublicParams
- pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
- pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
- pp.FixmedinsName = miConfig.OrgName
- pp.FixmedinsCode = miConfig.Code
-
- pp.RequestUrl = miConfig.Url
- pp.Cainfo = miConfig.Cainfo
- pp.SecretKey = miConfig.SecretKey
- pp.AccessKey = miConfig.AccessKey
- pp.OpterName = roles.UserName
-
- var config []*models.HisXtDiagnoseConfig
- for _, item := range diagnosis_ids {
-
- id, _ := strconv.ParseInt(item, 10, 64)
- if id > 0 {
-
- diagnosisConfig, _ := service.FindDiagnoseById(id)
- config = append(config, &diagnosisConfig)
- }
- }
-
- var pd models.PatientDtos
- pd.PatnID = his.PsnNo
- pd.PatnName = his.Name
- pd.Gend = his.Gend
- pd.Poolarea = his.InsuplcAdmdvs
- pd.CurrMdtrtID = his.Number
- birthday := time.Unix(p.Birthday, 0)
-
- // 格式化为生日字符串
- birthdayStr := birthday.Format("2006-01-02") // 格式化模板为 "年-月-日"
- pd.Brdy = birthdayStr
- var fed models.FsiEncounterDtos
- fed.MdtrtID = his.Number
- fed.MedinsID = miConfig.Code
- fed.MedinsName = miConfig.OrgName
- fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
- fed.MedMdtrtType = "1"
- fed.MedinsType = "1"
- fed.MedinsLv = "11"
- tm := time.Unix(his.RecordDate, 0)
- s_tm := tm.Format("2006-01-02 15:04:05")
- fed.AdmDate = s_tm
- fed.DscgDate = s_tm
- fed.DscgMainDiseCodg = config[0].CountryCode
- fed.DscgMainDiseName = config[0].CountryContentName
- //诊断信息
- var fdds []*models.FsiDiagnoseDtos
- for index, item := range config {
- if index == 0 {
- var fdd models.FsiDiagnoseDtos
- fdd.DiseID = strconv.FormatInt(item.ID, 10)
- fdd.InoutDiseType = "1"
- fdd.MaindiseFlag = "1"
- fdd.DiseDate = s_tm
- fdd.DiasSrtNo = "1"
- fdd.DiseName = item.CountryContentName
- fdd.DiseCodg = item.CountryCode
- fdds = append(fdds, &fdd)
-
- } else {
- var fdd models.FsiDiagnoseDtos
- fdd.DiseID = strconv.FormatInt(item.ID, 10)
- fdd.InoutDiseType = "1"
- fdd.MaindiseFlag = "1"
- fdd.DiseDate = s_tm
- fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
- fdd.DiseName = item.CountryContentName
- fdd.DiseCodg = item.CountryCode
- fdds = append(fdds, &fdd)
- }
- }
- fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
- fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
- fed.AdmDeptName = department.Name
- fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
- fed.DscgDeptName = department.Name
- fed.MedMdtrtType = "1"
- fed.MedType = "11"
- //if his.Insutype == "390" {
- // fed.MedType = "1402"
- //} else {
- // fed.MedType = "9933"
- //}
- var orders []*models.FsiOrderDtos
-
- if trig_scen == "4" {
- //处方医嘱信息
- for _, item := range prescriptions {
- for _, subItem := range item.HisDoctorAdviceInfo {
- if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 && subItem.BaseDrugLib.IsUser != 1 {
-
- spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
-
- var order models.FsiOrderDtos
- order.RxID = strconv.FormatInt(item.ID, 10)
- order.Rxno = strconv.FormatInt(item.ID, 10)
- order.LongDrordFlag = "0"
- order.HilistType = "1"
- order.ChrgType = "1"
- order.DrordBhvr = "0"
- order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
- order.HosplistName = subItem.BaseDrugLib.DrugName
- order.HilistLv = "1"
- order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
- order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
- order.HosplistName = subItem.BaseDrugLib.DrugName
- order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
- order.Pric = fmt.Sprintf("%.2f", subItem.Price)
- order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
- order.OwnpayAmt = ""
- order.SelfpayAmt = ""
- order.Spec = spec
- order.SpecUnt = subItem.PrescribingNumberUnit
- order.DrordBegnDate = s_tm
- order.DrordStopDate = ""
- order.DrordDrCodg = doctor_info.DoctorNumber
- order.DrordDeptName = department.Name
- order.DrordDeptCodg = department.Number
- order.DrordDrName = doctor_info.UserName
- order.DrordDrProfttl = "234"
- order.CurrDrordFlag = "1"
- orders = append(orders, &order)
- }
- }
- for _, subItem := range item.HisPrescriptionProject {
- if len(subItem.HisProject.MedicalCode) > 0 {
-
- if subItem.Type == 2 {
- var order models.FsiOrderDtos
- order.RxID = strconv.FormatInt(item.ID, 10)
- order.Rxno = strconv.FormatInt(item.ID, 10)
- order.LongDrordFlag = "0"
- order.HilistType = "1"
- order.ChrgType = "1"
- order.DrordBhvr = "0"
- order.HilistCode = subItem.HisProject.MedicalCode
- order.HosplistName = subItem.HisProject.ProjectName
- order.HilistLv = "1"
- order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
- order.HosplistCode = subItem.HisProject.MedicalCode
- order.HosplistName = subItem.HisProject.ProjectName
- order.Cnt = subItem.Count
- cnt, _ := strconv.ParseFloat(subItem.Count, 64)
- order.Pric = fmt.Sprintf("%.2f", subItem.Price)
- order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
- order.OwnpayAmt = ""
- order.SelfpayAmt = ""
- order.Spec = subItem.Unit
- order.SpecUnt = subItem.Unit
- order.DrordBegnDate = s_tm
- order.DrordStopDate = ""
- order.DrordDrCodg = doctor_info.DoctorNumber
- order.DrordDeptName = department.Name
- order.DrordDeptCodg = department.Number
- order.DrordDrName = doctor_info.UserName
- order.DrordDrProfttl = "234"
- order.CurrDrordFlag = "1"
- orders = append(orders, &order)
- }
- }
- if subItem.Type == 3 {
- if len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 && subItem.GoodInfo.IsUser != 1 {
-
- var order models.FsiOrderDtos
- order.RxID = strconv.FormatInt(item.ID, 10)
- order.Rxno = strconv.FormatInt(item.ID, 10)
- order.LongDrordFlag = "0"
- order.HilistType = "1"
- order.ChrgType = "1"
- order.DrordBhvr = "0"
- order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
- order.HosplistName = subItem.GoodInfo.GoodName
- order.HilistLv = "1"
- order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
- order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
- order.HosplistName = subItem.GoodInfo.GoodName
- order.Cnt = subItem.Count
- cnt, _ := strconv.ParseFloat(subItem.Count, 64)
- order.Pric = fmt.Sprintf("%.2f", subItem.Price)
- order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
- order.OwnpayAmt = ""
- order.SelfpayAmt = ""
- order.Spec = subItem.GoodInfo.SpecificationName
- order.SpecUnt = subItem.Unit
- order.DrordBegnDate = s_tm
- order.DrordStopDate = ""
- order.DrordDrCodg = doctor_info.DoctorNumber
- order.DrordDeptName = department.Name
- order.DrordDeptCodg = department.Number
- order.DrordDrName = doctor_info.UserName
- order.DrordDrProfttl = "234"
- order.CurrDrordFlag = "1"
- orders = append(orders, &order)
- }
- }
- }
- }
- //处方医嘱信息
- }
- fed.MatnStas = "0"
- fed.MedfeeSumamt = "0"
- fed.OwnpayAmt = "0"
- fed.SelfpayAmt = "0"
- fed.AcctPayamt = "0"
- fed.MaAmt = "0"
- fed.HifpPayamt = "0"
- fed.SetlTotlnum = "1"
- fed.Insutype = his.InsutypeType
- fed.ReimFlag = "0"
- fed.OutSetlFlag = "0"
-
- var fopd []*models.FsiOperationDtosData
- data := make(map[string]interface{})
- data["fed"] = fed
- data["fdd"] = fdds
- data["fod"] = orders
- data["pd"] = pd
- data["pp"] = pp
- data["fopd"] = fopd
- data["trig_scen"] = trig_scen
- fmt.Println(data)
- fmt.Println(fed)
- fmt.Println(fdds)
- fmt.Println(orders)
- fmt.Println(pd)
- fmt.Println(pp)
- fmt.Println(fopd)
-
- client := &http.Client{}
- bytesData, _ := json.Marshal(data)
- var req *http.Request
-
- if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
-
- if miConfig.MdtrtareaAdmvs == "320921" {
- req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
- } else {
- req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
- }
- resp, _ := client.Do(req)
- defer resp.Body.Close()
- body, ioErr := ioutil.ReadAll(resp.Body)
- if ioErr != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return res
- }
- var respJSON map[string]interface{}
- if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return res
- }
- respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
- fmt.Println(respJSON)
- result, _ := json.Marshal(respJSON)
- fmt.Println(result)
- if err := json.Unmarshal([]byte(result), &res); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return res
- }
-
- return res
- } else {
- output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
- saveLog(output, input, "3101", "事前")
- if err := json.Unmarshal([]byte(output), &res); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- return res
- }
- return res
- }
- func Check3102(c *ZHHisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
- ////patient_id, _ := c.GetInt64("patient_id")
- //order_id, _ := c.GetInt64("order_id")
- ////his_patient_id, _ := c.GetInt64("his_patient_id")
- ////admin_user_id, _ := c.GetInt64("admin_user_id")
- //trig_scen := c.GetString("trig_scen")
-
- adminUser := c.GetAdminUserInfo()
- roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
- //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
- his, _ := service.GetInHospitalRecord(his_patient_id)
- p, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
-
-
- miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
- record_time := c.GetString("record_time")
- order, _ := service.GetHisOrderByID(order_id)
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordDateTime := theTime.Unix()
-
- var patientPrescription models.HisPrescriptionInfo
- patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
- if patientPrescription.ID == 0 {
- patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
- }
- department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
- doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
- //
- diagnosis_ids := strings.Split(his.Diagnosis, ",")
-
- prescriptions, _ := service.GetNewHisPrescriptionTenone(adminUser.CurrentOrgId, his.Number)
-
- var pp models.PublicParams
- pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
- pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
- pp.FixmedinsName = miConfig.OrgName
- pp.FixmedinsCode = miConfig.Code
- pp.RequestUrl = miConfig.Url
- pp.Cainfo = miConfig.Cainfo
- pp.SecretKey = miConfig.SecretKey
- pp.AccessKey = miConfig.AccessKey
- pp.OpterName = roles.UserName
-
- var config []*models.HisXtDiagnoseConfig
- for _, item := range diagnosis_ids {
- id, _ := strconv.ParseInt(item, 10, 64)
- if id > 0 {
- diagnosisConfig, _ := service.FindDiagnoseById(id)
- config = append(config, &diagnosisConfig)
- }
- }
-
- var pd models.PatientDtos
- pd.PatnID = his.PsnNo
- pd.PatnName = his.Name
- pd.Gend = his.Gend
- pd.Poolarea = his.InsuplcAdmdvs
- pd.CurrMdtrtID = his.Number
- // 将时间戳转换为 time.Time 类型
- birthday := time.Unix(p.Birthday, 0)
-
- // 格式化为生日字符串
- birthdayStr := birthday.Format("2006-01-02") // 格式化模板为 "年-月-日"
- pd.Brdy = birthdayStr
-
- var fed models.FsiEncounterDtos
- fed.MdtrtID = his.Number
- fed.MedinsID = miConfig.Code
- fed.MedinsName = miConfig.OrgName
- fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
- fed.MedMdtrtType = "1"
- fed.MedinsType = "1"
- fed.MedinsLv = "11"
- tm := time.Unix(his.RecordDate, 0)
- s_tm := tm.Format("2006-01-02 15:04:05")
- fed.AdmDate = s_tm
- fed.DscgDate = s_tm
- fed.DscgMainDiseCodg = config[0].CountryCode
- fed.DscgMainDiseName = config[0].CountryContentName
- //诊断信息
- var fdds []*models.FsiDiagnoseDtos
- for index, item := range config {
- if index == 0 {
- var fdd models.FsiDiagnoseDtos
- fdd.DiseID = strconv.FormatInt(item.ID, 10)
- fdd.InoutDiseType = "1"
- fdd.MaindiseFlag = "1"
- fdd.DiseDate = s_tm
- fdd.DiasSrtNo = "1"
- fdd.DiseName = item.CountryContentName
- fdd.DiseCodg = item.CountryCode
- fdds = append(fdds, &fdd)
-
- } else {
- var fdd models.FsiDiagnoseDtos
- fdd.DiseID = strconv.FormatInt(item.ID, 10)
- fdd.InoutDiseType = "1"
- fdd.MaindiseFlag = "1"
- fdd.DiseDate = s_tm
- fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
- fdd.DiseName = item.CountryContentName
- fdd.DiseCodg = item.CountryCode
- fdds = append(fdds, &fdd)
- }
- }
- fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
- fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
- fed.AdmDeptName = department.Name
- fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
- fed.DscgDeptName = department.Name
-
- fed.MedType = "14"
- //处方医嘱信息
- var orders []*models.FsiOrderDtos
- //for _, item := range prescriptions {
- // for _, subItem := range item.HisDoctorAdviceInfo {
- // var order models.FsiOrderDtos
- // order.RxID = strconv.FormatInt(item.ID, 10)
- // order.Rxno = strconv.FormatInt(item.ID, 10)
- // order.LongDrordFlag = "0"
- // order.HilistType = "1"
- // order.ChrgType = "1"
- // order.DrordBhvr = "-"
- // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
- // order.HosplistName = subItem.BaseDrugLib.DrugName
- // order.HilistLv = "1"
- // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
- // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
- // order.HosplistName = subItem.BaseDrugLib.DrugName
- // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
- // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
- // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
- // order.OwnpayAmt = ""
- // order.SelfpayAmt = ""
- // order.Spec = ""
- // order.SpecUnt = ""
- // order.DrordBegnDate = s_tm
- // order.DrordStopDate = ""
- // order.DrordDrCodg = "1"
- // order.DrordDeptName = department.Name
- // order.DrordDrCodg = "1"
- // order.DrordDrName = doctor_info.UserName
- // order.DrordDrProfttl = ""
- // order.CurrDrordFlag = "1"
- // orders = append(orders, &order)
- // }
- // for _, subItem := range item.HisPrescriptionProject {
- // if subItem.Type == 2 {
- // var order models.FsiOrderDtos
- // order.RxID = strconv.FormatInt(item.ID, 10)
- // order.Rxno = strconv.FormatInt(item.ID, 10)
- // order.LongDrordFlag = "0"
- // order.HilistType = "1"
- // order.ChrgType = "1"
- // order.DrordBhvr = "-"
- // order.HilistCode = subItem.HisProject.MedicalCode
- // order.HosplistName = subItem.HisProject.ProjectName
- // order.HilistLv = "1"
- // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
- // order.HosplistCode = subItem.HisProject.MedicalCode
- // order.HosplistName = subItem.HisProject.ProjectName
- // order.Cnt = subItem.Count
- // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
- //
- // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
- // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
- // order.OwnpayAmt = ""
- // order.SelfpayAmt = ""
- // order.Spec = ""
- // order.SpecUnt = ""
- // order.DrordBegnDate = s_tm
- // order.DrordStopDate = ""
- // order.DrordDrCodg = "1"
- // order.DrordDeptName = department.Name
- // order.DrordDrCodg = "1"
- // order.DrordDrName = doctor_info.UserName
- // order.DrordDrProfttl = ""
- // order.CurrDrordFlag = "1"
- // orders = append(orders, &order)
- //
- // }
- // if subItem.Type == 3 {
- //
- // var order models.FsiOrderDtos
- // order.RxID = strconv.FormatInt(item.ID, 10)
- // order.Rxno = strconv.FormatInt(item.ID, 10)
- // order.LongDrordFlag = "0"
- // order.HilistType = "1"
- // order.ChrgType = "1"
- // order.DrordBhvr = "-"
- // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
- // order.HosplistName = subItem.GoodInfo.GoodName
- // order.HilistLv = "1"
- // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
- // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
- // order.HosplistName = subItem.GoodInfo.GoodName
- // order.Cnt = subItem.Count
- // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
- // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
- // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
- // order.OwnpayAmt = ""
- // order.SelfpayAmt = ""
- // order.Spec = ""
- // order.SpecUnt = ""
- // order.DrordBegnDate = s_tm
- // order.DrordStopDate = ""
- // order.DrordDrCodg = "1"
- // order.DrordDeptName = department.Name
- // order.DrordDrCodg = "1"
- // order.DrordDrName = doctor_info.UserName
- // order.DrordDrProfttl = ""
- // order.CurrDrordFlag = "1"
- // orders = append(orders, &order)
- //
- // }
- // }
- //}
- for _, item := range prescriptions {
- for _, subItem := range item.HisDoctorAdviceInfo {
- if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 && subItem.BaseDrugLib.IsUser != 1 {
-
- spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
-
- var order models.FsiOrderDtos
- order.RxID = strconv.FormatInt(item.ID, 10)
- order.Rxno = strconv.FormatInt(item.ID, 10)
- order.LongDrordFlag = "0"
- order.HilistType = "1"
- order.ChrgType = "1"
- order.DrordBhvr = "0"
- order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
- order.HosplistName = subItem.BaseDrugLib.DrugName
- order.HilistLv = "1"
- order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
- order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
- order.HosplistName = subItem.BaseDrugLib.DrugName
- order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
- order.Pric = fmt.Sprintf("%.2f", subItem.Price)
- order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
- order.OwnpayAmt = ""
- order.SelfpayAmt = ""
- order.Spec = spec
- order.SpecUnt = subItem.PrescribingNumberUnit
- order.DrordBegnDate = s_tm
- order.DrordStopDate = ""
- order.DrordDrCodg = doctor_info.DoctorNumber
- order.DrordDeptName = department.Name
- order.DrordDeptCodg = department.Number
- order.DrordDrName = doctor_info.UserName
- order.DrordDrProfttl = "234"
- order.CurrDrordFlag = "1"
- orders = append(orders, &order)
- }
- }
- for _, subItem := range item.HisPrescriptionProject {
- if len(subItem.HisProject.MedicalCode) > 0 {
-
- if subItem.Type == 2 {
- var order models.FsiOrderDtos
- order.RxID = strconv.FormatInt(item.ID, 10)
- order.Rxno = strconv.FormatInt(item.ID, 10)
- order.LongDrordFlag = "0"
- order.HilistType = "1"
- order.ChrgType = "1"
- order.DrordBhvr = "0"
- order.HilistCode = subItem.HisProject.MedicalCode
- order.HosplistName = subItem.HisProject.ProjectName
- order.HilistLv = "1"
- order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
- order.HosplistCode = subItem.HisProject.MedicalCode
- order.HosplistName = subItem.HisProject.ProjectName
- order.Cnt = subItem.Count
- cnt, _ := strconv.ParseFloat(subItem.Count, 64)
- order.Pric = fmt.Sprintf("%.2f", subItem.Price)
- order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
- order.OwnpayAmt = ""
- order.SelfpayAmt = ""
- order.Spec = subItem.Unit
- order.SpecUnt = subItem.Unit
- order.DrordBegnDate = s_tm
- order.DrordStopDate = ""
- order.DrordDrCodg = doctor_info.DoctorNumber
- order.DrordDeptName = department.Name
- order.DrordDeptCodg = department.Number
- order.DrordDrName = doctor_info.UserName
- order.DrordDrProfttl = "234"
- order.CurrDrordFlag = "1"
- orders = append(orders, &order)
- }
- }
- if subItem.Type == 3 {
- if len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 && subItem.GoodInfo.IsUser != 1 {
-
- var order models.FsiOrderDtos
- order.RxID = strconv.FormatInt(item.ID, 10)
- order.Rxno = strconv.FormatInt(item.ID, 10)
- order.LongDrordFlag = "0"
- order.HilistType = "1"
- order.ChrgType = "1"
- order.DrordBhvr = "0"
- order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
- order.HosplistName = subItem.GoodInfo.GoodName
- order.HilistLv = "1"
- order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
- order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
- order.HosplistName = subItem.GoodInfo.GoodName
- order.Cnt = subItem.Count
- cnt, _ := strconv.ParseFloat(subItem.Count, 64)
- order.Pric = fmt.Sprintf("%.2f", subItem.Price)
- order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
- order.OwnpayAmt = ""
- order.SelfpayAmt = ""
- order.Spec = subItem.GoodInfo.SpecificationName
- order.SpecUnt = subItem.Unit
- order.DrordBegnDate = s_tm
- order.DrordStopDate = ""
- order.DrordDrCodg = doctor_info.DoctorNumber
- order.DrordDeptName = department.Name
- order.DrordDeptCodg = department.Number
- order.DrordDrName = doctor_info.UserName
- order.DrordDrProfttl = "234"
- order.CurrDrordFlag = "1"
- orders = append(orders, &order)
- }
- }
- }
- }
-
- //for _, item := range prescriptions {
- // for _, subItem := range item.HisDoctorAdviceInfo {
- // spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
- //
- // var order models.FsiOrderDtos
- // order.RxID = strconv.FormatInt(item.ID, 10)
- // order.Rxno = strconv.FormatInt(item.ID, 10)
- // order.LongDrordFlag = "0"
- // order.HilistType = "1"
- // order.ChrgType = "1"
- // order.DrordBhvr = "0"
- // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
- // order.HosplistName = subItem.BaseDrugLib.DrugName
- // order.HilistLv = "1"
- // order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
- // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
- // order.HosplistName = subItem.BaseDrugLib.DrugName
- // order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
- // order.Pric = fmt.Sprintf("%.2f", subItem.Price)
- // order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
- // order.OwnpayAmt = ""
- // order.SelfpayAmt = ""
- // order.Spec = spec
- // order.SpecUnt = subItem.PrescribingNumberUnit
- // order.DrordBegnDate = s_tm
- // order.DrordStopDate = ""
- // order.DrordDrCodg = doctor_info.DoctorNumber
- // order.DrordDeptName = department.Name
- // order.DrordDeptCodg = department.Number
- // order.DrordDrName = doctor_info.UserName
- // order.DrordDrProfttl = "234"
- // order.CurrDrordFlag = "1"
- // orders = append(orders, &order)
- // }
- // for _, subItem := range item.HisPrescriptionProject {
- // if subItem.Type == 2 {
- // var order models.FsiOrderDtos
- // order.RxID = strconv.FormatInt(item.ID, 10)
- // order.Rxno = strconv.FormatInt(item.ID, 10)
- // order.LongDrordFlag = "0"
- // order.HilistType = "1"
- // order.ChrgType = "1"
- // order.DrordBhvr = "0"
- // order.HilistCode = subItem.HisProject.MedicalCode
- // order.HosplistName = subItem.HisProject.ProjectName
- // order.HilistLv = "1"
- // order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
- // order.HosplistCode = subItem.HisProject.MedicalCode
- // order.HosplistName = subItem.HisProject.ProjectName
- // order.Cnt = subItem.Count
- // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
- // order.Pric = fmt.Sprintf("%.2f", subItem.Price)
- // order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
- // order.OwnpayAmt = ""
- // order.SelfpayAmt = ""
- // order.Spec = subItem.Unit
- // order.SpecUnt = subItem.Unit
- // order.DrordBegnDate = s_tm
- // order.DrordStopDate = ""
- // order.DrordDrCodg = doctor_info.DoctorNumber
- // order.DrordDeptName = department.Name
- // order.DrordDeptCodg = department.Number
- // order.DrordDrName = doctor_info.UserName
- // order.DrordDrProfttl = "234"
- // order.CurrDrordFlag = "1"
- // orders = append(orders, &order)
- //
- // }
- // if subItem.Type == 3 {
- //
- // var order models.FsiOrderDtos
- // order.RxID = strconv.FormatInt(item.ID, 10)
- // order.Rxno = strconv.FormatInt(item.ID, 10)
- // order.LongDrordFlag = "0"
- // order.HilistType = "1"
- // order.ChrgType = "1"
- // order.DrordBhvr = "0"
- // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
- // order.HosplistName = subItem.GoodInfo.GoodName
- // order.HilistLv = "1"
- // order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
- // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
- // order.HosplistName = subItem.GoodInfo.GoodName
- // order.Cnt = subItem.Count
- // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
- // order.Pric = fmt.Sprintf("%.2f", subItem.Price)
- // order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
- // order.OwnpayAmt = ""
- // order.SelfpayAmt = ""
- // order.Spec = subItem.GoodInfo.SpecificationName
- // order.SpecUnt = subItem.Unit
- // order.DrordBegnDate = s_tm
- // order.DrordStopDate = ""
- // order.DrordDrCodg = doctor_info.DoctorNumber
- // order.DrordDeptName = department.Name
- // order.DrordDeptCodg = department.Number
- // order.DrordDrName = doctor_info.UserName
- // order.DrordDrProfttl = "234"
- // order.CurrDrordFlag = "1"
- // orders = append(orders, &order)
- //
- // }
- // }
- //}
- //处方医嘱信息
- fed.MatnStas = "0"
- fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
- fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
- fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
- fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
- fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
- fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
- fed.SetlTotlnum = "1"
- fed.Insutype = his.InsutypeType
- fed.ReimFlag = "0"
- fed.OutSetlFlag = "0"
-
- var fopd []*models.FsiOperationDtosData
- data := make(map[string]interface{})
- data["fed"] = fed
- data["fdd"] = fdds
- data["fod"] = orders
- data["pd"] = pd
- data["pp"] = pp
- data["fopd"] = fopd
- data["trig_scen"] = trig_scen
-
- client := &http.Client{}
- bytesData, _ := json.Marshal(data)
- var req *http.Request
-
- if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
-
- if miConfig.MdtrtareaAdmvs == "320921" {
- req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
- } else {
- req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
- }
-
- resp, _ := client.Do(req)
- defer resp.Body.Close()
- body, ioErr := ioutil.ReadAll(resp.Body)
- if ioErr != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return res
- }
- var respJSON map[string]interface{}
- if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return res
- }
-
- respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
- result, _ := json.Marshal(respJSON)
- if err := json.Unmarshal([]byte(result), &res); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return res
- }
-
- return res
- } else {
- output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
- saveLog(output, input, "3102", "事中")
- if err := json.Unmarshal([]byte(output), &res); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- return res
- }
- return res
- }
|